From patchwork Fri Aug 25 10:49:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 110993 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp811011qge; Fri, 25 Aug 2017 03:52:24 -0700 (PDT) X-Received: by 10.28.66.157 with SMTP id k29mr989297wmi.19.1503658344536; Fri, 25 Aug 2017 03:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503658344; cv=none; d=google.com; s=arc-20160816; b=pYy+FTblkEY+Yi6K1bpyix7rLq1TNk0sxMPhP+snGX4Trm5EpwDuipK2iJclEkcbG4 CgB3T9IfAa8em+fLmlMm54f4K/tCrwSXjn5l6SyhQxUefYawmkSDsjwxYZFaBh7Jj9gx bfizYj7S2cSk211LWyhs0ybNZCTHF/qAW5YnYp/7lxqZSokIKuvaYlFPteHxSd+QPg6u 5xwZZ9R3kkTqxwJAxisJqmnWn2dYBBshGN3YB+ECUvISjS6ug4NOSlFEzkB+xbd+w8TC LURhWpxsX841TOkllPABpPCe+b7r0hLTKHdTP7YIVI/Ry7MWMp9VovdyaI2j1vqjDaP9 fK8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=TrKGecUaZPIO2mrfFucXof7rtK9Q0wU59LO9FuJ+rJQ=; b=Zhx54GtNaKJdz9OnLEvo4cLKOJgtCjOia36GVcYCDtOMCDFQCIKJGG3+wd4Wl8dtqf OgqpFv7UynWvkZtnUhXzsJYv4vWyJTRDFZwPXC6ZeagEjo+BHBQ69qGYtOWoG28kPqN4 P6w9ZdVvWqtX4ckYJkFBpz6iItdU9frSGaZEQAhTvtGNPxyV/mDFfEchEBmLxJi+tC5+ SiZq5lcoMsVwefjXbBGfOf9/ytM7AWsvDBJ7PdaUB0lX8Xne4W8TKfT4UJLo/F/LAvPv O99u99mFceE2if4y8KxxjUY4W8wSFILNfeBszZ+EGCxsggp/glV7gnWossjQZKBIS78Q oYDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org ([2001:4b98:dc0:41:216:3eff:fe72:dd13]) by mx.google.com with ESMTP id p80si1046013wmf.208.2017.08.25.03.52.24; Fri, 25 Aug 2017 03:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) client-ip=2001:4b98:dc0:41:216:3eff:fe72:dd13; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 2001:4b98:dc0:41:216:3eff:fe72:dd13 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 28292917F; Fri, 25 Aug 2017 12:50:27 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0055.outbound.protection.outlook.com [104.47.36.55]) by dpdk.org (Postfix) with ESMTP id 268F1916B for ; Fri, 25 Aug 2017 12:50:24 +0200 (CEST) Received: from BN6PR03CA0054.namprd03.prod.outlook.com (10.173.137.16) by BN6PR03MB3316.namprd03.prod.outlook.com (10.174.233.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Fri, 25 Aug 2017 10:50:20 +0000 Received: from BY2FFO11FD021.protection.gbl (2a01:111:f400:7c0c::125) by BN6PR03CA0054.outlook.office365.com (2603:10b6:404:4c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9 via Frontend Transport; Fri, 25 Aug 2017 10:50:20 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD021.mail.protection.outlook.com (10.1.15.210) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Fri, 25 Aug 2017 10:50:20 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7PAnw6E032070; Fri, 25 Aug 2017 03:50:18 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 25 Aug 2017 16:19:26 +0530 Message-ID: <1503658183-4078-11-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131481318205261591; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(51234002)(189002)(199003)(48376002)(2351001)(5660300001)(50466002)(97736004)(47776003)(33646002)(68736007)(105606002)(77096006)(104016004)(305945005)(5003940100001)(189998001)(626005)(106466001)(50226002)(356003)(16200700003)(36756003)(5890100001)(8656003)(8676002)(85426001)(53946003)(54906002)(53936002)(86362001)(4326008)(8936002)(6666003)(2906002)(81166006)(498600001)(81156014)(2950100002)(6916009)(15650500001)(110136004)(50986999)(76176999)(2004002)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB3316; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD021; 1:CDAKVMTAcErg5/Rty/DVy5k7vTkaFsvqqQq8Tc6OwJFtFaFRh0v6uUrb5OvKweh3xYF1dMHqLY8+zhrODgVNqRL9UjQn2+4YXivSAWR3ECfxEVs6mezrP27Bnk0gED3J MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ab8f952-f3f3-4656-1ab7-08d4eba7149b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR03MB3316; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3316; 3:FA/KNpkd0Lm0uP2BZ8gAdwwWsiHWNmIX73nSL62/SqFUVWOBz6mKZDrHj3nPgBp0YKHzm8rm7Kwb3BPQjH5IMxtsV8zDyl9qQjgtDtazRM/kNGLu4ey/PusagT22HMJFlAG6NbedYREgHqd2TnXW9nOvJS9q4Uj7mw1KR67/OBS6stuxhfdbysTKamkvkvo0tclzRx25oY4Rf8PXqUfgZt+JWcWXWU3d68xWNg8irO7oZrpvwA9tES3fCnQr0GdhsgYfjkQ/7jzSklblQmaBR6veg0rJdkXSzigpyfzCVfoBXKTyi863Cb5F3sSjzsOtvOKHHtaUS2TRbaTGJtgCGkGKjUkpEPqUnXgmi948syo=; 25:KI65Yozpl7ihxorCbzBrC+ruw+9cS4elaEZeyRknUot9qDvb5H++Dh5qmzBhN9QfbDiTJT02vrA9iwSTVU9M4W0AyEkXKm+YqLmAd/TMrjukPtD+K60AWXYM+9XWLbZFG0cYP8VK0lPO9KbWXOUg14l+a5R39KfGVCWUpogUtcLVP8q0KiDYbLK96zLWZ2DbAZfRPXyKiH+CDR9fnftoz3E11XzC9b/qqqDMYJg/yzEircCaPLsqJk/G/MImY/2XheAltOa6np7FF922hZh3SVBUe8wF+yuoeXcfWqJaj8zAWuZewsFTFRjDEX+V/2YMTrb5vXK4KzOe31K0tcFV5Q== X-MS-TrafficTypeDiagnostic: BN6PR03MB3316: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3316; 31:oIj0kAFBPjfxzV/DLC5MAS+vDkQlIV3eB6jV8/UioLqHpMIZ9DJsOEQDGuDIDuQsZ9iKTVEEE1W2gzbcWCZ9tSfkSPZzFmukLGUMaW2HaatZbtrhDBm1K5L2OT4FTmBC90F+PC0NtHjdVugPuiHsdsvpLJDCHFuhZAxV09+1nueFr3XxS02ZhiDw2pN1p+2lHFTRyGUuzz3SDJZ1bA+R7Uae1/cg8KI3BczFy67Y/K4=; 4:qHcy/YWv6/OggTH+cRQPAQjRRHyGk2OV7jefz/x1vZDS51AnMK1sPwP5IbKDP6gtU7rimLhkHsUDaaWBkabKwG4oaMGHDa1+ER80CrSyx8mJ9HH6//qX64V+4EbuCrIbyTYxOHu1Asfy1yp+8twor4+np/j5FJgA2G95bXWUCCMapjiwETj5xryP9DVGDkPKm7UEonKZpMlV5zlYn26S2twEmT2jD06nlTfNCTt41hgGb5zJMxZ5EqK+WBdtLO585uZDNL/kt9RJANJa79LutUXbWf5nYpKvqDb9IABZzgXGlOQHDci3XqzXfja1V0t3i6DFR4rnZexp2ICoskHavSDhZs9xkNwG6eiq0YnwXTVAFnN/MwQTQdRtDxcKDQLl X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(185117386973197)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(5005006)(13016025)(8121501046)(13018025)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6096035)(20161123565025)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123556025)(20161123563025)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR03MB3316; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR03MB3316; X-Forefront-PRVS: 041032FF37 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB3316; 23:PuGxgU/8CU3ZUasMylOBVvNzFUs9lP38GoZOQMmV2?= 8s/sCwxadIE7ij5oxoLIgDAYyrAcfAr6xxM70GetQ78w62d5UZSz7U9G4bmdPAYaA2lAwUs/J8SMOX/iYPuk32/vkmMaJAjjzuM9WP3oeByoGAW++567/2fZB9rbUhyi/PwKlXH8VYydadi1rXNYQTqpjkZ07jYXJXZ+e48w3fT/tpXSENozmtDrurVLIZooALCcSd+Crcl1v3Mv2wHiUS35/z1E6op/sTrLFqxjefDZYCz7EjCAzdqz5MHIK+4QV9VB4PqywZdhkH7uMkyA/BZ5up5F4BlPkliJfdb0v/gamHwdPBFO8SXmlhgdB6VJZkik1fbRtHSRtKEpEwpkvjLgo0V1l84Zrb6t2IUnKAubWPtkezEiye7ImNMjLuiEqb2wArbDcl1njhOuObGQnsrjWrbXmXLkdhadK9hckGMZuF/m59xhSF63obeF2BVcN3aB8avkylTnGHm6Dw11kyjuOtAJwmwNrcmiXJcwXdXVv0RhuPo/hpQFOKG2tpTm8KHqFJoHANUfFbKNCaAQywWSC+HX96J4nDZpfnfPu59tuagUsAmC0+m+Ff9GbVQHPgwPmucj40tR7If4bEgdBhFDqQ7VVsnLXOi0y104oJ+kjA1oiHbba+9mpG4sjCYKVfJJmhptm0Vk2PDM2GdBK2Qm34d0+XpPXUgW9rW/AKSo9va7p9UmtgAa9NUSSxRuWbktnL5g//R92+spsgJMBV7sffjoOTA4v6D9BcdU+zNNSnPC6PrbIcA6G2Au3aBlytR1Z/wvUJ78vk+KzdDzx8hJIWhDEDJfv6xPAv1ioqyBlDPVBQzTgWPii7Ug8awxM4asO+xHgjFaWhcHHLpI8Ms1czciyjCwhrFw2D7cUzZWV0YPRSAgkITKYhZJ8qa1RmFZs/VuGdvL5K5ixqk5t0h2Tn7u4fFMnLzYB1gahe0RMC/CMSOj6T3shcBtbno1pXft5/RQ7a+Fap8MYwJERBJXRUqqMSaKAoJ68HaXTj/qTT75Ok7kmVkgDVMTFdwEmzzAPyDwVqEVR3Sk5AIwdqRcl3BWq1qEYE7EMdt6rlVCmygbCuk2hxAvbucKMdzuz+VMn/qoRkZYHxkpumGEanq6712lo+ztalj3KIhQGd2fjHiINfN9+BrlxbX1WsQRkX7Ampz1k+e2ZqjbIUWSh9IMuHqYgWqQW8R5kGQgCNuy4fRjP9QuXeH4qY0bHC8oY+XZlj71RxwXeRT2EK50UDL0vDLq41JmjM6T/JQMYdleg== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3316; 6:MvgrxZUpjR3tin220snyUCPLKAqa5NNPvNgW+hbJUN56SrSJqhSeZG4egGtwvR6ubmsvHlwjNncl99NDrCYo05YLg4U1ZfYONPsgol0sQnW/6dfMtfcrr7vSCTdGnNitHqyok0DN3NOkOAmZM59W4c75BG4Fg4bWYq+r62lpJ1+LSYRxRlmSjZrz0NZN5Kl3ThycVbbm5Loun50IOOD+sSLLV4s4wMQD84Zv//ad0TvBnik9r78raS24tw8v+3NRGQniPokqwakAaavpkQhzkjxhIgX0LX5DrZhXf3lodaZnRIvbYz+nY1cSQmtelvA840tFNAMCUElAS3erTCrlpg==; 5:Tt5QytXD2WU/rDoEz/gGQdNnzzVPT1C751N3RowW0g29QaH3Ug6HyhIpkvm9nb0iMVqsPlG9zFQh0CCA13KvIVI2S2CoPJh1iKASzMQLcmzLy9VRc2PtpQPoC5FQO6nvV8W8WogFyfVy1f07YipngA==; 24:5MPCx/DCngHXhiXhwo5GY9d1D/ligdCpaT7Q76KxOVqvNEuYQgLL3npXg7nKSzIq7QdWYJFSrl5d+7zRyH6kKwXuSgewbHmjU4ox3ZLsj3s=; 7:ENBxnp3L47fee3/PUKCGYUTxYWq0Z0OekZQmKqN4MIkQI9wLrAIrjAjKzJnzom+jipwpNyb4Gy0WyB1p1+T/DU5cM5arI8SuPhIRMIeIt+H7xihmkYDRZOO44+et1GdR11eydGy04pVtuZkVPvHH5nRRPv1ksEYhJ0sCG0AIKEaR6IL0dfXqKcUkDOMd/E7yTx4TLTAyvgrwFhsUFTmJd0pka6u2Hd2dUbpKAuB4uzE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 10:50:20.1985 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB3316 Subject: [dpdk-dev] [PATCH 10/27] net/dpaa2: update MC to 10.3.x X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shreyansh Jain Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- drivers/net/dpaa2/Makefile | 1 + drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 11 +- drivers/net/dpaa2/dpaa2_ethdev.c | 21 +- drivers/net/dpaa2/dpaa2_ethdev.h | 2 +- drivers/net/dpaa2/mc/dpkg.c | 107 ++++ drivers/net/dpaa2/mc/dpni.c | 1093 ++++++++++++++++++++++++++------ drivers/net/dpaa2/mc/fsl_dpkg.h | 69 +- drivers/net/dpaa2/mc/fsl_dpni.h | 1083 +++++++++---------------------- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 970 +++++++++++++++------------- drivers/net/dpaa2/mc/fsl_net.h | 2 +- 10 files changed, 1939 insertions(+), 1420 deletions(-) create mode 100644 drivers/net/dpaa2/mc/dpkg.c -- 2.7.4 diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile index 32cd819..2f551d5 100644 --- a/drivers/net/dpaa2/Makefile +++ b/drivers/net/dpaa2/Makefile @@ -63,6 +63,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c LDLIBS += -lrte_bus_fslmc LDLIBS += -lrte_mempool_dpaa2 diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c index 4c82aa8..1269dd2 100644 --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c @@ -79,7 +79,7 @@ dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev, tc_cfg.dist_size = eth_dev->data->nb_rx_queues; tc_cfg.dist_mode = DPNI_DIST_MODE_HASH; - ret = dpni_prepare_key_cfg(&kg_cfg, p_params); + ret = dpkg_prepare_key_cfg(&kg_cfg, p_params); if (ret) { RTE_LOG(ERR, PMD, "Unable to prepare extract parameters\n"); rte_free(p_params); @@ -118,12 +118,12 @@ int dpaa2_remove_flow_dist( } memset(p_params, 0, DIST_PARAM_IOVA_SIZE); memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg)); - + kg_cfg.num_extracts = 0; tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params)); tc_cfg.dist_size = 0; tc_cfg.dist_mode = DPNI_DIST_MODE_NONE; - ret = dpni_prepare_key_cfg(&kg_cfg, p_params); + ret = dpkg_prepare_key_cfg(&kg_cfg, p_params); if (ret) { RTE_LOG(ERR, PMD, "Unable to prepare extract parameters\n"); rte_free(p_params); @@ -133,12 +133,10 @@ int dpaa2_remove_flow_dist( ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index, &tc_cfg); rte_free(p_params); - if (ret) { + if (ret) RTE_LOG(ERR, PMD, "Setting distribution for Rx failed with err: %d\n", ret); - return ret; - } return ret; } @@ -337,6 +335,7 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, bpool_cfg.pools[0].backup_pool = 0; bpool_cfg.pools[0].buffer_size = RTE_ALIGN_CEIL(bp_list->buf_pool.size, DPAA2_PACKET_LAYOUT_ALIGN); + bpool_cfg.pools[0].priority_mask = 0; retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, &bpool_cfg); if (retcode != 0) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 360109e..945dcc7 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -941,7 +941,7 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, /*Get Counters from page_0*/ retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, - page0, &value); + page0, 0, &value); if (retcode) goto err; @@ -950,7 +950,7 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, /*Get Counters from page_1*/ retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, - page1, &value); + page1, 0, &value); if (retcode) goto err; @@ -959,7 +959,7 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, /*Get Counters from page_2*/ retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token, - page2, &value); + page2, 0, &value); if (retcode) goto err; @@ -1384,22 +1384,19 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } - priv->num_tc = attr.num_tcs; + priv->num_rx_tc = attr.num_rx_tcs; - /* Resetting the "num_rx_vqueues" to equal number of queues in first TC + /* Resetting the "num_rx_queues" to equal number of queues in first TC * as only one TC is supported on Rx Side. Once Multiple TCs will be * in use for Rx processing then this will be changed or removed. */ priv->nb_rx_queues = attr.num_queues; - /* TODO:Using hard coded value for number of TX queues due to dependency - * in MC. - */ - priv->nb_tx_queues = 8; + /* Using number of TX queues as number of TX TCs */ + priv->nb_tx_queues = attr.num_tx_tcs; - PMD_INIT_LOG(DEBUG, "num TC - RX %d", priv->num_tc); - PMD_INIT_LOG(DEBUG, "nb_tx_queues %d", priv->nb_tx_queues); - PMD_INIT_LOG(DEBUG, "nb_rx_queues %d", priv->nb_rx_queues); + PMD_DRV_LOG(DEBUG, "RX-TC= %d, nb_rx_queues= %d, nb_tx_queues=%d", + priv->num_tc, priv->nb_rx_queues, priv->nb_tx_queues); priv->hw = dpni_dev; priv->hw_id = hw_id; diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index a2902da..07e1da6 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -87,7 +87,7 @@ struct dpaa2_dev_priv { uint32_t options; uint8_t max_mac_filters; uint8_t max_vlan_filters; - uint8_t num_tc; + uint8_t num_rx_tc; uint8_t flags; /*dpaa2 config flags */ }; diff --git a/drivers/net/dpaa2/mc/dpkg.c b/drivers/net/dpaa2/mc/dpkg.c new file mode 100644 index 0000000..3f98907 --- /dev/null +++ b/drivers/net/dpaa2/mc/dpkg.c @@ -0,0 +1,107 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * BSD LICENSE + * + * Copyright 2017 NXP + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * GPL LICENSE SUMMARY + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include + +/** + * dpkg_prepare_key_cfg() - function prepare extract parameters + * @cfg: defining a full Key Generation profile (rule) + * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA + * + * This function has to be called before the following functions: + * - dpni_set_rx_tc_dist() + * - dpni_set_qos_table() + * - dpkg_prepare_key_cfg() + */ +int +dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, uint8_t *key_cfg_buf) +{ + int i, j; + struct dpni_ext_set_rx_tc_dist *dpni_ext; + struct dpni_dist_extract *extr; + + if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS) + return -EINVAL; + + dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf; + dpni_ext->num_extracts = cfg->num_extracts; + + for (i = 0; i < cfg->num_extracts; i++) { + extr = &dpni_ext->extracts[i]; + + switch (cfg->extracts[i].type) { + case DPKG_EXTRACT_FROM_HDR: + extr->prot = cfg->extracts[i].extract.from_hdr.prot; + dpkg_set_field(extr->efh_type, EFH_TYPE, + cfg->extracts[i].extract.from_hdr.type); + extr->size = cfg->extracts[i].extract.from_hdr.size; + extr->offset = cfg->extracts[i].extract.from_hdr.offset; + extr->field = cpu_to_le32( + cfg->extracts[i].extract.from_hdr.field); + extr->hdr_index = + cfg->extracts[i].extract.from_hdr.hdr_index; + break; + case DPKG_EXTRACT_FROM_DATA: + extr->size = cfg->extracts[i].extract.from_data.size; + extr->offset = + cfg->extracts[i].extract.from_data.offset; + break; + case DPKG_EXTRACT_FROM_PARSE: + extr->size = cfg->extracts[i].extract.from_parse.size; + extr->offset = + cfg->extracts[i].extract.from_parse.offset; + break; + default: + return -EINVAL; + } + + extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks; + dpkg_set_field(extr->extract_type, EXTRACT_TYPE, + cfg->extracts[i].type); + + for (j = 0; j < DPKG_NUM_OF_MASKS; j++) { + extr->masks[j].mask = cfg->extracts[i].masks[j].mask; + extr->masks[j].offset = + cfg->extracts[i].masks[j].offset; + } + } + + return 0; +} diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c index c2d3969..f95e669 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -42,100 +42,39 @@ #include #include -int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, - uint8_t *key_cfg_buf) -{ - int i, j; - int offset = 0; - int param = 1; - uint64_t *params = (uint64_t *)key_cfg_buf; - - if (!key_cfg_buf || !cfg) - return -EINVAL; - - params[0] |= mc_enc(0, 8, cfg->num_extracts); - params[0] = cpu_to_le64(params[0]); - - if (cfg->num_extracts >= DPKG_MAX_NUM_OF_EXTRACTS) - return -EINVAL; - - for (i = 0; i < cfg->num_extracts; i++) { - switch (cfg->extracts[i].type) { - case DPKG_EXTRACT_FROM_HDR: - params[param] |= mc_enc(0, 8, - cfg->extracts[i].extract.from_hdr.prot); - params[param] |= mc_enc(8, 4, - cfg->extracts[i].extract.from_hdr.type); - params[param] |= mc_enc(16, 8, - cfg->extracts[i].extract.from_hdr.size); - params[param] |= mc_enc(24, 8, - cfg->extracts[i].extract. - from_hdr.offset); - params[param] |= mc_enc(32, 32, - cfg->extracts[i].extract. - from_hdr.field); - params[param] = cpu_to_le64(params[param]); - param++; - params[param] |= mc_enc(0, 8, - cfg->extracts[i].extract. - from_hdr.hdr_index); - break; - case DPKG_EXTRACT_FROM_DATA: - params[param] |= mc_enc(16, 8, - cfg->extracts[i].extract. - from_data.size); - params[param] |= mc_enc(24, 8, - cfg->extracts[i].extract. - from_data.offset); - params[param] = cpu_to_le64(params[param]); - param++; - break; - case DPKG_EXTRACT_FROM_PARSE: - params[param] |= mc_enc(16, 8, - cfg->extracts[i].extract. - from_parse.size); - params[param] |= mc_enc(24, 8, - cfg->extracts[i].extract. - from_parse.offset); - params[param] = cpu_to_le64(params[param]); - param++; - break; - default: - return -EINVAL; - } - params[param] |= mc_enc( - 24, 8, cfg->extracts[i].num_of_byte_masks); - params[param] |= mc_enc(32, 4, cfg->extracts[i].type); - params[param] = cpu_to_le64(params[param]); - param++; - for (offset = 0, j = 0; - j < DPKG_NUM_OF_MASKS; - offset += 16, j++) { - params[param] |= mc_enc( - (offset), 8, cfg->extracts[i].masks[j].mask); - params[param] |= mc_enc( - (offset + 8), 8, - cfg->extracts[i].masks[j].offset); - } - params[param] = cpu_to_le64(params[param]); - param++; - } - return 0; -} - +/** + * dpni_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpni_id: DPNI unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpni_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpni_id, uint16_t *token) { struct mc_command cmd = { 0 }; + struct dpni_cmd_open *cmd_params; + int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN, cmd_flags, 0); - DPNI_CMD_OPEN(cmd, dpni_id); + cmd_params = (struct dpni_cmd_open *)cmd.params; + cmd_params->dpni_id = cpu_to_le32(dpni_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -143,11 +82,22 @@ int dpni_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } +/** + * dpni_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -163,12 +113,35 @@ int dpni_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } -int dpni_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpni_cfg *cfg, - uint32_t *obj_id) +/** + * dpni_create() - Create the DPNI object + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPNI object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpni_cfg *cfg, + uint32_t *obj_id) { + struct dpni_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -176,7 +149,14 @@ int dpni_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE, cmd_flags, dprc_token); - DPNI_CMD_CREATE(cmd, cfg); + cmd_params = (struct dpni_cmd_create *)cmd.params; + cmd_params->options = cpu_to_le32(cfg->options); + cmd_params->num_queues = cfg->num_queues; + cmd_params->num_tcs = cfg->num_tcs; + cmd_params->mac_filter_entries = cfg->mac_filter_entries; + cmd_params->vlan_filter_entries = cfg->vlan_filter_entries; + cmd_params->qos_entries = cfg->qos_entries; + cmd_params->fs_entries = cpu_to_le16(cfg->fs_entries); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -184,16 +164,32 @@ int dpni_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } -int dpni_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) +/** + * dpni_destroy() - Destroy the DPNI object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; error code otherwise. + */ +int dpni_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id) { + struct dpni_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ @@ -201,28 +197,63 @@ int dpni_destroy(struct fsl_mc_io *mc_io, cmd_flags, dprc_token); /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); + cmd_params = (struct dpni_cmd_destroy *)cmd.params; + cmd_params->dpsw_id = cpu_to_le32(object_id); + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_set_pools() - Set buffer pools configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cfg: Buffer pools configuration + * + * mandatory for DPNI operation + * warning:Allowed only when DPNI is disabled + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_pools(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, const struct dpni_pools_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_pools *cmd_params; + int i; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS, cmd_flags, token); - DPNI_CMD_SET_POOLS(cmd, cfg); + cmd_params = (struct dpni_cmd_set_pools *)cmd.params; + cmd_params->num_dpbp = cfg->num_dpbp; + for (i = 0; i < DPNI_MAX_DPBP; i++) { + cmd_params->pool[i].dpbp_id = + cpu_to_le16(cfg->pools[i].dpbp_id); + cmd_params->pool[i].priority_mask = + cfg->pools[i].priority_mask; + cmd_params->buffer_size[i] = + cpu_to_le16(cfg->pools[i].buffer_size); + cmd_params->backup_pool_mask |= + DPNI_BACKUP_POOL(cfg->pools[i].backup_pool, i); + } /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_enable() - Enable the DPNI, allow sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -238,6 +269,14 @@ int dpni_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpni_disable() - Disable the DPNI, stop sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -253,15 +292,27 @@ int dpni_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpni_is_enabled() - Check if the DPNI is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { struct mc_command cmd = { 0 }; + struct dpni_rsp_is_enabled *rsp_params; int err; + /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED, cmd_flags, + cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED, + cmd_flags, token); /* send command to mc*/ @@ -270,11 +321,20 @@ int dpni_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_IS_ENABLED(cmd, *en); + rsp_params = (struct dpni_rsp_is_enabled *)cmd.params; + *en = dpni_get_field(rsp_params->enabled, ENABLE); return 0; } +/** + * dpni_reset() - Reset the DPNI, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -290,12 +350,23 @@ int dpni_reset(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_attributes() - Retrieve DPNI attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @attr: Object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_attributes(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, struct dpni_attr *attr) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_attr *rsp_params; + int err; /* prepare command */ @@ -309,28 +380,65 @@ int dpni_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_ATTR(cmd, attr); + rsp_params = (struct dpni_rsp_get_attr *)cmd.params; + attr->options = le32_to_cpu(rsp_params->options); + attr->num_queues = rsp_params->num_queues; + attr->num_rx_tcs = rsp_params->num_rx_tcs; + attr->num_tx_tcs = rsp_params->num_tx_tcs; + attr->mac_filter_entries = rsp_params->mac_filter_entries; + attr->vlan_filter_entries = rsp_params->vlan_filter_entries; + attr->qos_entries = rsp_params->qos_entries; + attr->fs_entries = le16_to_cpu(rsp_params->fs_entries); + attr->qos_key_size = rsp_params->qos_key_size; + attr->fs_key_size = rsp_params->fs_key_size; + attr->wriop_version = le16_to_cpu(rsp_params->wriop_version); return 0; } +/** + * dpni_set_errors_behavior() - Set errors behavior + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cfg: Errors configuration + * + * This function may be called numerous times with different + * error masks + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, - struct dpni_error_cfg *cfg) + struct dpni_error_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_errors_behavior *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR, cmd_flags, token); - DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg); + cmd_params = (struct dpni_cmd_set_errors_behavior *)cmd.params; + cmd_params->errors = cpu_to_le32(cfg->errors); + dpni_set_field(cmd_params->flags, ERROR_ACTION, cfg->error_action); + dpni_set_field(cmd_params->flags, FRAME_ANN, cfg->set_frame_annotation); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_buffer_layout() - Retrieve buffer layout attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue to retrieve configuration for + * @layout: Returns buffer layout attributes + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -338,13 +446,16 @@ int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, struct dpni_buffer_layout *layout) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_buffer_layout *cmd_params; + struct dpni_rsp_get_buffer_layout *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_BUFFER_LAYOUT, cmd_flags, token); - DPNI_CMD_GET_BUFFER_LAYOUT(cmd, qtype); + cmd_params = (struct dpni_cmd_get_buffer_layout *)cmd.params; + cmd_params->qtype = qtype; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -352,29 +463,72 @@ int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_BUFFER_LAYOUT(cmd, layout); + rsp_params = (struct dpni_rsp_get_buffer_layout *)cmd.params; + layout->pass_timestamp = dpni_get_field(rsp_params->flags, PASS_TS); + layout->pass_parser_result = dpni_get_field(rsp_params->flags, PASS_PR); + layout->pass_frame_status = dpni_get_field(rsp_params->flags, PASS_FS); + layout->private_data_size = le16_to_cpu(rsp_params->private_data_size); + layout->data_align = le16_to_cpu(rsp_params->data_align); + layout->data_head_room = le16_to_cpu(rsp_params->head_room); + layout->data_tail_room = le16_to_cpu(rsp_params->tail_room); return 0; } +/** + * dpni_set_buffer_layout() - Set buffer layout configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue this configuration applies to + * @layout: Buffer layout configuration + * + * Return: '0' on Success; Error code otherwise. + * + * @warning Allowed only when DPNI is disabled + */ int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - const struct dpni_buffer_layout *layout) + uint16_t token, + enum dpni_queue_type qtype, + const struct dpni_buffer_layout *layout) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_buffer_layout *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT, cmd_flags, token); - DPNI_CMD_SET_BUFFER_LAYOUT(cmd, qtype, layout); + cmd_params = (struct dpni_cmd_set_buffer_layout *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->options = cpu_to_le16(layout->options); + dpni_set_field(cmd_params->flags, PASS_TS, layout->pass_timestamp); + dpni_set_field(cmd_params->flags, PASS_PR, layout->pass_parser_result); + dpni_set_field(cmd_params->flags, PASS_FS, layout->pass_frame_status); + cmd_params->private_data_size = cpu_to_le16(layout->private_data_size); + cmd_params->data_align = cpu_to_le16(layout->data_align); + cmd_params->head_room = cpu_to_le16(layout->data_head_room); + cmd_params->tail_room = cpu_to_le16(layout->data_tail_room); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_set_offload() - Set DPNI offload configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @type: Type of DPNI offload + * @config: Offload configuration. + * For checksum offloads, non-zero value enables the offload + * + * Return: '0' on Success; Error code otherwise. + * + * @warning Allowed only when DPNI is disabled + */ + int dpni_set_offload(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -382,17 +536,32 @@ int dpni_set_offload(struct fsl_mc_io *mc_io, uint32_t config) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_offload *cmd_params; - /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_OFFLOAD, cmd_flags, token); - DPNI_CMD_SET_OFFLOAD(cmd, type, config); + cmd_params = (struct dpni_cmd_set_offload *)cmd.params; + cmd_params->dpni_offload = type; + cmd_params->config = cpu_to_le32(config); - /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_offload() - Get DPNI offload configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @type: Type of DPNI offload + * @config: Offload configuration. + * For checksum offloads, a value of 1 indicates that the + * offload is enabled. + * + * Return: '0' on Success; Error code otherwise. + * + * @warning Allowed only when DPNI is disabled + */ int dpni_get_offload(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -400,13 +569,16 @@ int dpni_get_offload(struct fsl_mc_io *mc_io, uint32_t *config) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_offload *cmd_params; + struct dpni_rsp_get_offload *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_OFFLOAD, cmd_flags, token); - DPNI_CMD_GET_OFFLOAD(cmd, type); + cmd_params = (struct dpni_cmd_get_offload *)cmd.params; + cmd_params->dpni_offload = type; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -414,11 +586,24 @@ int dpni_get_offload(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_OFFLOAD(cmd, *config); + rsp_params = (struct dpni_rsp_get_offload *)cmd.params; + *config = le32_to_cpu(rsp_params->config); return 0; } +/** + * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used + * for enqueue operations + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue to receive QDID for + * @qdid: Returned virtual QDID value that should be used as an argument + * in all enqueue operations + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_qdid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -426,13 +611,51 @@ int dpni_get_qdid(struct fsl_mc_io *mc_io, uint16_t *qdid) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_qdid *cmd_params; + struct dpni_rsp_get_qdid *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID, cmd_flags, token); - DPNI_CMD_GET_QDID(cmd, qtype); + cmd_params = (struct dpni_cmd_get_qdid *)cmd.params; + cmd_params->qtype = qtype; + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpni_rsp_get_qdid *)cmd.params; + *qdid = le16_to_cpu(rsp_params->qdid); + + return 0; +} + +/** + * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer) + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @data_offset: Tx data offset (from start of buffer) + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t *data_offset) +{ + struct mc_command cmd = { 0 }; + struct dpni_rsp_get_tx_data_offset *rsp_params; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET, + cmd_flags, + token); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -440,34 +663,57 @@ int dpni_get_qdid(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_QDID(cmd, *qdid); + rsp_params = (struct dpni_rsp_get_tx_data_offset *)cmd.params; + *data_offset = le16_to_cpu(rsp_params->data_offset); return 0; } +/** + * dpni_set_link_cfg() - set the link configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cfg: Link configuration + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_link_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, const struct dpni_link_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_link_cfg *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG, cmd_flags, token); - DPNI_CMD_SET_LINK_CFG(cmd, cfg); + cmd_params = (struct dpni_cmd_set_link_cfg *)cmd.params; + cmd_params->rate = cpu_to_le32(cfg->rate); + cmd_params->options = cpu_to_le64(cfg->options); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_link_state() - Return the link state (either up or down) + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @state: Returned link state; + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_link_state(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, struct dpni_link_state *state) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_link_state *rsp_params; int err; /* prepare command */ @@ -481,34 +727,60 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_LINK_STATE(cmd, state); + rsp_params = (struct dpni_rsp_get_link_state *)cmd.params; + state->up = dpni_get_field(rsp_params->flags, LINK_STATE); + state->rate = le32_to_cpu(rsp_params->rate); + state->options = le64_to_cpu(rsp_params->options); return 0; } +/** + * dpni_set_max_frame_length() - Set the maximum received frame length. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @max_frame_length: Maximum received frame length (in bytes); + * frame is discarded if its length exceeds this value + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_max_frame_length(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint16_t max_frame_length) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_max_frame_length *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MAX_FRAME_LENGTH, cmd_flags, token); - DPNI_CMD_SET_MAX_FRAME_LENGTH(cmd, max_frame_length); + cmd_params = (struct dpni_cmd_set_max_frame_length *)cmd.params; + cmd_params->max_frame_length = cpu_to_le16(max_frame_length); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_max_frame_length() - Get the maximum received frame length. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @max_frame_length: Maximum received frame length (in bytes); + * frame is discarded if its length exceeds this value + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_max_frame_length(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint16_t *max_frame_length) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_max_frame_length *rsp_params; int err; /* prepare command */ @@ -522,34 +794,56 @@ int dpni_get_max_frame_length(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_MAX_FRAME_LENGTH(cmd, *max_frame_length); + rsp_params = (struct dpni_rsp_get_max_frame_length *)cmd.params; + *max_frame_length = le16_to_cpu(rsp_params->max_frame_length); return 0; } +/** + * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Set to '1' to enable; '0' to disable + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int en) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_multicast_promisc *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC, cmd_flags, token); - DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en); + cmd_params = (struct dpni_cmd_set_multicast_promisc *)cmd.params; + dpni_set_field(cmd_params->enable, ENABLE, en); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_multicast_promisc() - Get multicast promiscuous mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Returns '1' if enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_multicast_promisc *rsp_params; int err; /* prepare command */ @@ -563,34 +857,56 @@ int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_MULTICAST_PROMISC(cmd, *en); + rsp_params = (struct dpni_rsp_get_multicast_promisc *)cmd.params; + *en = dpni_get_field(rsp_params->enabled, ENABLE); return 0; } +/** + * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Set to '1' to enable; '0' to disable + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int en) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_unicast_promisc *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_UNICAST_PROMISC, cmd_flags, token); - DPNI_CMD_SET_UNICAST_PROMISC(cmd, en); + cmd_params = (struct dpni_cmd_set_unicast_promisc *)cmd.params; + dpni_set_field(cmd_params->enable, ENABLE, en); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_unicast_promisc() - Get unicast promiscuous mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Returns '1' if enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_unicast_promisc *rsp_params; int err; /* prepare command */ @@ -604,35 +920,59 @@ int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_UNICAST_PROMISC(cmd, *en); + rsp_params = (struct dpni_rsp_get_unicast_promisc *)cmd.params; + *en = dpni_get_field(rsp_params->enabled, ENABLE); return 0; } +/** + * dpni_set_primary_mac_addr() - Set the primary MAC address + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: MAC address to set as primary address + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, const uint8_t mac_addr[6]) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_primary_mac_addr *cmd_params; + int i; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC, cmd_flags, token); - DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr); + cmd_params = (struct dpni_cmd_set_primary_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + cmd_params->mac_addr[i] = mac_addr[5 - i]; /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_primary_mac_addr() - Get the primary MAC address + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: Returned MAC address + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t mac_addr[6]) { struct mc_command cmd = { 0 }; - int err; + struct dpni_rsp_get_primary_mac_addr *rsp_params; + int i, err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC, @@ -645,45 +985,85 @@ int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr); + rsp_params = (struct dpni_rsp_get_primary_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + mac_addr[5 - i] = rsp_params->mac_addr[i]; return 0; } +/** + * dpni_add_mac_addr() - Add MAC address filter + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: MAC address to add + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_add_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, const uint8_t mac_addr[6]) { struct mc_command cmd = { 0 }; + struct dpni_cmd_add_mac_addr *cmd_params; + int i; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR, cmd_flags, token); - DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr); + cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + cmd_params->mac_addr[i] = mac_addr[5 - i]; /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_remove_mac_addr() - Remove MAC address filter + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: MAC address to remove + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, const uint8_t mac_addr[6]) { struct mc_command cmd = { 0 }; + struct dpni_cmd_remove_mac_addr *cmd_params; + int i; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR, cmd_flags, token); - DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr); + cmd_params = (struct dpni_cmd_remove_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + cmd_params->mac_addr[i] = mac_addr[5 - i]; /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_clear_mac_filters() - Clear all unicast and/or multicast MAC filters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @unicast: Set to '1' to clear unicast addresses + * @multicast: Set to '1' to clear multicast addresses + * + * The primary MAC address is not cleared by this operation. + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_clear_mac_filters(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -691,24 +1071,40 @@ int dpni_clear_mac_filters(struct fsl_mc_io *mc_io, int multicast) { struct mc_command cmd = { 0 }; + struct dpni_cmd_clear_mac_filters *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_MAC_FILTERS, cmd_flags, token); - DPNI_CMD_CLEAR_MAC_FILTERS(cmd, unicast, multicast); + cmd_params = (struct dpni_cmd_clear_mac_filters *)cmd.params; + dpni_set_field(cmd_params->flags, UNICAST_FILTERS, unicast); + dpni_set_field(cmd_params->flags, MULTICAST_FILTERS, multicast); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_port_mac_addr() - Retrieve MAC address associated to the physical + * port the DPNI is attached to + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: MAC address of the physical port, if any, otherwise 0 + * + * The primary MAC address is not cleared by this operation. + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t mac_addr[6]) { struct mc_command cmd = { 0 }; - int err; + struct dpni_rsp_get_port_mac_addr *rsp_params; + int i, err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PORT_MAC_ADDR, @@ -721,62 +1117,105 @@ int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPNI_RSP_GET_PORT_MAC_ADDR(cmd, mac_addr); + rsp_params = (struct dpni_rsp_get_port_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + mac_addr[5 - i] = rsp_params->mac_addr[i]; return 0; } +/** + * dpni_enable_vlan_filter() - Enable/disable VLAN filtering mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @en: Set to '1' to enable; '0' to disable + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, - int en) + uint16_t token, + int en) { + struct dpni_cmd_enable_vlan_filter *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE_VLAN_FILTER, cmd_flags, token); - DPNI_CMD_ENABLE_VLAN_FILTER(cmd, en); + cmd_params = (struct dpni_cmd_enable_vlan_filter *)cmd.params; + dpni_set_field(cmd_params->en, ENABLE, en); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_add_vlan_id() - Add VLAN ID filter + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @vlan_id: VLAN ID to add + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_add_vlan_id(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint16_t vlan_id) { + struct dpni_cmd_vlan_id *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_VLAN_ID, cmd_flags, token); - DPNI_CMD_ADD_VLAN_ID(cmd, vlan_id); + cmd_params = (struct dpni_cmd_vlan_id *)cmd.params; + cmd_params->vlan_id = cpu_to_le16(vlan_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_remove_vlan_id() - Remove VLAN ID filter + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @vlan_id: VLAN ID to remove + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint16_t vlan_id) { + struct dpni_cmd_vlan_id *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_VLAN_ID, cmd_flags, token); - DPNI_CMD_REMOVE_VLAN_ID(cmd, vlan_id); + cmd_params = (struct dpni_cmd_vlan_id *)cmd.params; + cmd_params->vlan_id = cpu_to_le16(vlan_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpni_clear_vlan_filters() - Clear all VLAN filters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -792,6 +1231,19 @@ int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @tc_id: Traffic class selection (0-7) + * @cfg: Traffic class distribution configuration + * + * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpkg_prepare_key_cfg() + * first to prepare the key_cfg_iova parameter + * + * Return: '0' on Success; error code otherwise. + */ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -799,87 +1251,185 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io, const struct dpni_rx_tc_dist_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_rx_tc_dist *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_DIST, cmd_flags, token); - DPNI_CMD_SET_RX_TC_DIST(cmd, tc_id, cfg); + cmd_params = (struct dpni_cmd_set_rx_tc_dist *)cmd.params; + cmd_params->dist_size = cpu_to_le16(cfg->dist_size); + cmd_params->tc_id = tc_id; + cmd_params->default_flow_id = cpu_to_le16(cfg->fs_cfg.default_flow_id); + cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova); + dpni_set_field(cmd_params->flags, + DIST_MODE, + cfg->dist_mode); + dpni_set_field(cmd_params->flags, + MISS_ACTION, + cfg->fs_cfg.miss_action); + dpni_set_field(cmd_params->keep_hash_key, + KEEP_HASH_KEY, + cfg->fs_cfg.keep_hash_key); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_confirmation_mode mode) +/** + * dpni_set_tx_confirmation_mode() - Tx confirmation mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mode: Tx confirmation mode + * + * This function is useful only when 'DPNI_OPT_TX_CONF_DISABLED' is not + * selected at DPNI creation. + * Calling this function with 'mode' set to DPNI_CONF_DISABLE disables all + * transmit confirmation (including the private confirmation queues), regardless + * of previous settings; Note that in this case, Tx error frames are still + * enqueued to the general transmit errors queue. + * Calling this function with 'mode' set to DPNI_CONF_SINGLE switches all + * Tx confirmations to a shared Tx conf queue. 'index' field in dpni_get_queue + * command will be ignored. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_confirmation_mode mode) { + struct dpni_tx_confirmation_mode *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE, cmd_flags, token); - DPNI_CMD_SET_TX_CONFIRMATION_MODE(cmd, mode); + cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params; + cmd_params->confirmation_mode = mode; /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int dpni_set_congestion_notification( - struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - uint8_t tc_id, +/** + * dpni_set_congestion_notification() - Set traffic class congestion + * notification configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - Rx, Tx and Tx confirm types are supported + * @tc_id: Traffic class selection (0-7) + * @cfg: congestion notification configuration + * + * Return: '0' on Success; error code otherwise. + */ +int dpni_set_congestion_notification(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, + uint8_t tc_id, const struct dpni_congestion_notification_cfg *cfg) { + struct dpni_cmd_set_congestion_notification *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header( - DPNI_CMDID_SET_CONGESTION_NOTIFICATION, - cmd_flags, - token); - DPNI_CMD_SET_CONGESTION_NOTIFICATION(cmd, qtype, tc_id, cfg); + DPNI_CMDID_SET_CONGESTION_NOTIFICATION, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_set_congestion_notification *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = tc_id; + cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id); + cmd_params->notification_mode = cpu_to_le16(cfg->notification_mode); + cmd_params->dest_priority = cfg->dest_cfg.priority; + cmd_params->message_iova = cpu_to_le64(cfg->message_iova); + cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx); + cmd_params->threshold_entry = cpu_to_le32(cfg->threshold_entry); + cmd_params->threshold_exit = cpu_to_le32(cfg->threshold_exit); + dpni_set_field(cmd_params->type_units, + DEST_TYPE, + cfg->dest_cfg.dest_type); + dpni_set_field(cmd_params->type_units, + CONG_UNITS, + cfg->units); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } -int dpni_get_congestion_notification(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpni_get_congestion_notification() - Get traffic class congestion + * notification configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - Rx, Tx and Tx confirm types are supported + * @tc_id: Traffic class selection (0-7) + * @cfg: congestion notification configuration + * + * Return: '0' on Success; error code otherwise. + */ +int dpni_get_congestion_notification(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, enum dpni_queue_type qtype, - uint8_t tc_id, + uint8_t tc_id, struct dpni_congestion_notification_cfg *cfg) { + struct dpni_rsp_get_congestion_notification *rsp_params; + struct dpni_cmd_get_congestion_notification *cmd_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ cmd.header = mc_encode_cmd_header( - DPNI_CMDID_GET_CONGESTION_NOTIFICATION, - cmd_flags, - token); - DPNI_CMD_GET_CONGESTION_NOTIFICATION(cmd, qtype, tc_id); + DPNI_CMDID_GET_CONGESTION_NOTIFICATION, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_get_congestion_notification *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = tc_id; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err; - DPNI_RSP_GET_CONGESTION_NOTIFICATION(cmd, cfg); + rsp_params = (struct dpni_rsp_get_congestion_notification *)cmd.params; + cfg->units = dpni_get_field(rsp_params->type_units, CONG_UNITS); + cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry); + cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit); + cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx); + cfg->message_iova = le64_to_cpu(rsp_params->message_iova); + cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode); + cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id); + cfg->dest_cfg.priority = rsp_params->dest_priority; + cfg->dest_cfg.dest_type = dpni_get_field(rsp_params->type_units, + DEST_TYPE); return 0; } +/** + * dpni_get_api_version() - Get Data Path Network Interface API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path network interface API + * @minor_ver: Minor version of data path network interface API + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpni_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -891,87 +1441,177 @@ int dpni_get_api_version(struct fsl_mc_io *mc_io, if (err) return err; - DPNI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + rsp_params = (struct dpni_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } +/** + * dpni_set_queue() - Set queue parameters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - all queue types are supported, although + * the command is ignored for Tx + * @tc: Traffic class, in range 0 to NUM_TCS - 1 + * @index: Selects the specific queue out of the set allocated for the + * same TC. Value must be in range 0 to NUM_QUEUES - 1 + * @options: A combination of DPNI_QUEUE_OPT_ values that control what + * configuration options are set on the queue + * @queue: Queue structure + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, + uint16_t token, enum dpni_queue_type qtype, - uint8_t tc, - uint8_t index, + uint8_t tc, + uint8_t index, uint8_t options, - const struct dpni_queue *queue) + const struct dpni_queue *queue) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_queue *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE, cmd_flags, token); - DPNI_CMD_SET_QUEUE(cmd, qtype, tc, index, options, queue); - - /* send command to mc*/ + cmd_params = (struct dpni_cmd_set_queue *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = tc; + cmd_params->index = index; + cmd_params->options = options; + cmd_params->dest_id = cpu_to_le32(queue->destination.id); + cmd_params->dest_prio = queue->destination.priority; + dpni_set_field(cmd_params->flags, DEST_TYPE, queue->destination.type); + dpni_set_field(cmd_params->flags, STASH_CTRL, queue->flc.stash_control); + dpni_set_field(cmd_params->flags, HOLD_ACTIVE, + queue->destination.hold_active); + cmd_params->flc = cpu_to_le64(queue->flc.value); + cmd_params->user_context = cpu_to_le64(queue->user_context); + + /* send command to mc */ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_queue() - Get queue parameters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - all queue types are supported + * @tc: Traffic class, in range 0 to NUM_TCS - 1 + * @index: Selects the specific queue out of the set allocated for the + * same TC. Value must be in range 0 to NUM_QUEUES - 1 + * @queue: Queue configuration structure + * @qid: Queue identification + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, + uint16_t token, enum dpni_queue_type qtype, - uint8_t tc, - uint8_t index, + uint8_t tc, + uint8_t index, struct dpni_queue *queue, struct dpni_queue_id *qid) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_queue *cmd_params; + struct dpni_rsp_get_queue *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE, cmd_flags, token); - DPNI_CMD_GET_QUEUE(cmd, qtype, tc, index); + cmd_params = (struct dpni_cmd_get_queue *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = tc; + cmd_params->index = index; - /* send command to mc*/ + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPNI_RSP_GET_QUEUE(cmd, queue, qid); + rsp_params = (struct dpni_rsp_get_queue *)cmd.params; + queue->destination.id = le32_to_cpu(rsp_params->dest_id); + queue->destination.priority = rsp_params->dest_prio; + queue->destination.type = dpni_get_field(rsp_params->flags, + DEST_TYPE); + queue->flc.stash_control = dpni_get_field(rsp_params->flags, + STASH_CTRL); + queue->destination.hold_active = dpni_get_field(rsp_params->flags, + HOLD_ACTIVE); + queue->flc.value = le64_to_cpu(rsp_params->flc); + queue->user_context = le64_to_cpu(rsp_params->user_context); + qid->fqid = le32_to_cpu(rsp_params->fqid); + qid->qdbin = le16_to_cpu(rsp_params->qdbin); return 0; } +/** + * dpni_get_statistics() - Get DPNI statistics + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @page: Selects the statistics page to retrieve, see + * DPNI_GET_STATISTICS output. Pages are numbered 0 to 2. + * @param: Custom parameter for some pages used to select + * a certain statistic source, for example the TC. + * @stat: Structure containing the statistics + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_statistics(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t page, + uint8_t param, union dpni_statistics *stat) { struct mc_command cmd = { 0 }; - int err; + struct dpni_cmd_get_statistics *cmd_params; + struct dpni_rsp_get_statistics *rsp_params; + int i, err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS, cmd_flags, token); - DPNI_CMD_GET_STATISTICS(cmd, page); + cmd_params = (struct dpni_cmd_get_statistics *)cmd.params; + cmd_params->page_number = page; + cmd_params->param = param; - /* send command to mc*/ + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPNI_RSP_GET_STATISTICS(cmd, stat); + rsp_params = (struct dpni_rsp_get_statistics *)cmd.params; + for (i = 0; i < DPNI_STATISTICS_CNT; i++) + stat->raw.counter[i] = le64_to_cpu(rsp_params->counter[i]); return 0; } +/** + * dpni_reset_statistics() - Clears DPNI statistics + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_reset_statistics(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -987,52 +1627,117 @@ int dpni_reset_statistics(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpni_set_taildrop() - Set taildrop per queue or TC + * + * Setting a per-TC taildrop (cg_point = DPNI_CP_GROUP) will reset any current + * congestion notification or early drop (WRED) configuration previously applied + * to the same TC. + * + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cg_point: Congestion point, DPNI_CP_QUEUE is only supported in + * combination with DPNI_QUEUE_RX. + * @q_type: Queue type, can be DPNI_QUEUE_RX or DPNI_QUEUE_TX. + * @tc: Traffic class to apply this taildrop to + * @q_index: Index of the queue if the DPNI supports multiple queues for + * traffic distribution. + * Ignored if CONGESTION_POINT is not DPNI_CP_QUEUE. + * @taildrop: Taildrop structure + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_set_taildrop(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, enum dpni_congestion_point cg_point, - enum dpni_queue_type q_type, + enum dpni_queue_type qtype, uint8_t tc, - uint8_t q_index, + uint8_t index, struct dpni_taildrop *taildrop) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_taildrop *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TAILDROP, cmd_flags, token); - DPNI_CMD_SET_TAILDROP(cmd, cg_point, q_type, tc, q_index, taildrop); - - /* send command to mc*/ + cmd_params = (struct dpni_cmd_set_taildrop *)cmd.params; + cmd_params->congestion_point = cg_point; + cmd_params->qtype = qtype; + cmd_params->tc = tc; + cmd_params->index = index; + cmd_params->units = taildrop->units; + cmd_params->threshold = cpu_to_le32(taildrop->threshold); + dpni_set_field(cmd_params->enable_oal_lo, ENABLE, taildrop->enable); + dpni_set_field(cmd_params->enable_oal_lo, OAL_LO, taildrop->oal); + dpni_set_field(cmd_params->oal_hi, + OAL_HI, + taildrop->oal >> DPNI_OAL_LO_SIZE); + + /* send command to mc */ return mc_send_command(mc_io, &cmd); } +/** + * dpni_get_taildrop() - Get taildrop information + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cg_point: Congestion point + * @q_type: Queue type on which the taildrop is configured. + * Only Rx queues are supported for now + * @tc: Traffic class to apply this taildrop to + * @q_index: Index of the queue if the DPNI supports multiple queues for + * traffic distribution. Ignored if CONGESTION_POINT is not 0. + * @taildrop: Taildrop structure + * + * Return: '0' on Success; Error code otherwise. + */ int dpni_get_taildrop(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t token, - enum dpni_congestion_point cg_point, - enum dpni_queue_type q_type, - uint8_t tc, - uint8_t q_index, - struct dpni_taildrop *taildrop) + uint16_t token, + enum dpni_congestion_point cg_point, + enum dpni_queue_type qtype, + uint8_t tc, + uint8_t index, + struct dpni_taildrop *taildrop) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_taildrop *cmd_params; + struct dpni_rsp_get_taildrop *rsp_params; + uint8_t oal_lo, oal_hi; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TAILDROP, cmd_flags, token); - DPNI_CMD_GET_TAILDROP(cmd, cg_point, q_type, tc, q_index); + cmd_params = (struct dpni_cmd_get_taildrop *)cmd.params; + cmd_params->congestion_point = cg_point; + cmd_params->qtype = qtype; + cmd_params->tc = tc; + cmd_params->index = index; - /* send command to mc*/ + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; /* retrieve response parameters */ - DPNI_RSP_GET_TAILDROP(cmd, taildrop); + rsp_params = (struct dpni_rsp_get_taildrop *)cmd.params; + taildrop->enable = dpni_get_field(rsp_params->enable_oal_lo, ENABLE); + taildrop->units = rsp_params->units; + taildrop->threshold = le32_to_cpu(rsp_params->threshold); + oal_lo = dpni_get_field(rsp_params->enable_oal_lo, OAL_LO); + oal_hi = dpni_get_field(rsp_params->oal_hi, OAL_HI); + taildrop->oal = oal_hi << DPNI_OAL_LO_SIZE | oal_lo; + + /* Fill the first 4 bits, 'oal' is a 2's complement value of 12 bits */ + if (taildrop->oal >= 0x0800) + taildrop->oal |= 0xF000; return 0; } diff --git a/drivers/net/dpaa2/mc/fsl_dpkg.h b/drivers/net/dpaa2/mc/fsl_dpkg.h index 2391e40..7f46baf 100644 --- a/drivers/net/dpaa2/mc/fsl_dpkg.h +++ b/drivers/net/dpaa2/mc/fsl_dpkg.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2015 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -93,6 +93,15 @@ struct dpkg_mask { uint8_t offset; }; +/* Macros for accessing command fields smaller than 1byte */ +#define DPKG_MASK(field) \ + GENMASK(DPKG_##field##_SHIFT + DPKG_##field##_SIZE - 1, \ + DPKG_##field##_SHIFT) +#define dpkg_set_field(var, field, val) \ + ((var) |= (((val) << DPKG_##field##_SHIFT) & DPKG_MASK(field))) +#define dpkg_get_field(var, field) \ + (((var) & DPKG_MASK(field)) >> DPKG_##field##_SHIFT) + /** * struct dpkg_extract - A structure for defining a single extraction * @type: Determines how the union below is interpreted: @@ -136,12 +145,12 @@ struct dpkg_extract { */ struct { - enum net_prot prot; + enum net_prot prot; enum dpkg_extract_from_hdr_type type; - uint32_t field; - uint8_t size; - uint8_t offset; - uint8_t hdr_index; + uint32_t field; + uint8_t size; + uint8_t offset; + uint8_t hdr_index; } from_hdr; /** * struct from_data @@ -166,8 +175,8 @@ struct dpkg_extract { } from_parse; } extract; - uint8_t num_of_byte_masks; - struct dpkg_mask masks[DPKG_NUM_OF_MASKS]; + uint8_t num_of_byte_masks; + struct dpkg_mask masks[DPKG_NUM_OF_MASKS]; }; /** @@ -181,4 +190,48 @@ struct dpkg_profile_cfg { struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS]; }; +/* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at + * key_cfg_iova) + */ +struct dpni_mask_cfg { + uint8_t mask; + uint8_t offset; +}; + +#define DPKG_EFH_TYPE_SHIFT 0 +#define DPKG_EFH_TYPE_SIZE 4 +#define DPKG_EXTRACT_TYPE_SHIFT 0 +#define DPKG_EXTRACT_TYPE_SIZE 4 + +struct dpni_dist_extract { + /* word 0 */ + uint8_t prot; + /* EFH type stored in the 4 least significant bits */ + uint8_t efh_type; + uint8_t size; + uint8_t offset; + uint32_t field; + /* word 1 */ + uint8_t hdr_index; + uint8_t constant; + uint8_t num_of_repeats; + uint8_t num_of_byte_masks; + /* Extraction type is stored in the 4 LSBs */ + uint8_t extract_type; + uint8_t pad[3]; + /* word 2 */ + struct dpni_mask_cfg masks[4]; +}; + +struct dpni_ext_set_rx_tc_dist { + /* extension word 0 */ + uint8_t num_extracts; + uint8_t pad[7]; + /* words 1..25 */ + struct dpni_dist_extract extracts[10]; +}; + +int dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, + uint8_t *key_cfg_buf); + #endif /* __FSL_DPKG_H_ */ diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h index 64db70d..092d3b3 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni.h +++ b/drivers/net/dpaa2/mc/fsl_dpni.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -110,47 +110,19 @@ struct fsl_mc_io; */ #define DPNI_OPT_NO_FS 0x000020 -/** - * dpni_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpni_id: DPNI unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpni_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpni_id, - uint16_t *token); +int dpni_open(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + int dpni_id, + uint16_t *token); -/** - * dpni_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpni_cfg - Structure representing DPNI configuration - * @mac_addr: Primary MAC address - * @adv: Advanced parameters; default is all zeros; + * @mac_addr: Primary MAC address + * @adv: Advanced parameters; default is all zeros; * use this structure to change default settings */ struct dpni_cfg { @@ -217,141 +189,62 @@ struct dpni_cfg { uint8_t qos_entries; }; -/** - * dpni_create() - Create the DPNI object - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: returned object id - * - * Create the DPNI object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpni_cfg *cfg, - uint32_t *obj_id); +int dpni_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpni_cfg *cfg, + uint32_t *obj_id); -/** - * dpni_destroy() - Destroy the DPNI object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @object_id: The object id; it must be a valid id within the container that - * created this object; - * - * The function accepts the authentication token of the parent container that - * created the object (not the one that currently owns the object). The object - * is searched within parent using the provided 'object_id'. - * All tokens to the object must be closed before calling destroy. - * - * Return: '0' on Success; error code otherwise. - */ -int dpni_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); +int dpni_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id); /** * struct dpni_pools_cfg - Structure representing buffer pools configuration - * @num_dpbp: Number of DPBPs - * @pools: Array of buffer pools parameters; The number of valid entries - * must match 'num_dpbp' value + * @num_dpbp: Number of DPBPs + * @pools: Array of buffer pools parameters; The number of valid entries + * must match 'num_dpbp' value */ struct dpni_pools_cfg { - uint8_t num_dpbp; + uint8_t num_dpbp; /** * struct pools - Buffer pools parameters * @dpbp_id: DPBP object ID + * @priority: priority mask that indicates TC's used with this buffer. + * I set to 0x00 MC will assume value 0xff. * @buffer_size: Buffer size * @backup_pool: Backup pool */ struct { int dpbp_id; + uint8_t priority_mask; uint16_t buffer_size; int backup_pool; } pools[DPNI_MAX_DPBP]; }; -/** - * dpni_set_pools() - Set buffer pools configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Buffer pools configuration - * - * mandatory for DPNI operation - * warning:Allowed only when DPNI is disabled - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_pools(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_pools_cfg *cfg); +int dpni_set_pools(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const struct dpni_pools_cfg *cfg); -/** - * dpni_enable() - Enable the DPNI, allow sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpni_disable() - Disable the DPNI, stop sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpni_is_enabled() - Check if the DPNI is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); +int dpni_is_enabled(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); -/** - * dpni_reset() - Reset the DPNI, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpni_attr - Structure representing DPNI attributes @@ -363,7 +256,8 @@ int dpni_reset(struct fsl_mc_io *mc_io, * DPNI_OPT_HAS_KEY_MASKING * DPNI_OPT_NO_FS * @num_queues: Number of Tx and Rx queues used for traffic distribution. - * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI. + * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI. + * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI. * @mac_filter_entries: Number of entries in the MAC address filtering * table. * @vlan_filter_entries: Number of entries in the VLAN address filtering @@ -390,7 +284,8 @@ int dpni_reset(struct fsl_mc_io *mc_io, struct dpni_attr { uint32_t options; uint8_t num_queues; - uint8_t num_tcs; + uint8_t num_rx_tcs; + uint8_t num_tx_tcs; uint8_t mac_filter_entries; uint8_t vlan_filter_entries; uint8_t qos_entries; @@ -400,19 +295,10 @@ struct dpni_attr { uint16_t wriop_version; }; -/** - * dpni_get_attributes() - Retrieve DPNI attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @attr: Object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_attr *attr); +int dpni_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpni_attr *attr); /** * DPNI errors @@ -457,33 +343,22 @@ enum dpni_error_action { /** * struct dpni_error_cfg - Structure representing DPNI errors treatment - * @errors: Errors mask; use 'DPNI_ERROR__ - * @error_action: The desired action for the errors mask - * @set_frame_annotation: Set to '1' to mark the errors in frame annotation - * status (FAS); relevant only for the non-discard action + * @errors: Errors mask; use 'DPNI_ERROR__ + * @error_action: The desired action for the errors mask + * @set_frame_annotation: Set to '1' to mark the errors in frame + * annotation status (FAS); relevant only + * for the non-discard action */ struct dpni_error_cfg { - uint32_t errors; - enum dpni_error_action error_action; - int set_frame_annotation; + uint32_t errors; + enum dpni_error_action error_action; + int set_frame_annotation; }; -/** - * dpni_set_errors_behavior() - Set errors behavior - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Errors configuration - * - * this function may be called numerous times with different - * error masks - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_error_cfg *cfg); +int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpni_error_cfg *cfg); /** * DPNI buffer layout modification options @@ -520,25 +395,26 @@ int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, /** * struct dpni_buffer_layout - Structure representing DPNI buffer layout - * @options: Flags representing the suggested modifications to the buffer - * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_' flags - * @pass_timestamp: Pass timestamp value - * @pass_parser_result: Pass parser results - * @pass_frame_status: Pass frame status - * @private_data_size: Size kept for private data (in bytes) - * @data_align: Data alignment - * @data_head_room: Data head room - * @data_tail_room: Data tail room + * @options: Flags representing the suggested modifications to the + * buffer layout; + * Use any combination of 'DPNI_BUF_LAYOUT_OPT_' flags + * @pass_timestamp: Pass timestamp value + * @pass_parser_result: Pass parser results + * @pass_frame_status: Pass frame status + * @private_data_size: Size kept for private data (in bytes) + * @data_align: Data alignment + * @data_head_room: Data head room + * @data_tail_room: Data tail room */ struct dpni_buffer_layout { - uint32_t options; - int pass_timestamp; - int pass_parser_result; - int pass_frame_status; - uint16_t private_data_size; - uint16_t data_align; - uint16_t data_head_room; - uint16_t data_tail_room; + uint32_t options; + int pass_timestamp; + int pass_parser_result; + int pass_frame_status; + uint16_t private_data_size; + uint16_t data_align; + uint16_t data_head_room; + uint16_t data_tail_room; }; /** @@ -547,45 +423,24 @@ struct dpni_buffer_layout { * @DPNI_QUEUE_TX: Tx queue * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue * @DPNI_QUEUE_RX_ERR: Rx error queue - */enum dpni_queue_type { + */ +enum dpni_queue_type { DPNI_QUEUE_RX, DPNI_QUEUE_TX, DPNI_QUEUE_TX_CONFIRM, DPNI_QUEUE_RX_ERR, }; -/** - * dpni_get_buffer_layout() - Retrieve buffer layout attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue to get the layout from - * @layout: Returns buffer layout attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - struct dpni_buffer_layout *layout); +int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, + struct dpni_buffer_layout *layout); -/** - * dpni_set_buffer_layout() - Set buffer layout configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue to set layout on - * @layout: Buffer layout configuration - * - * Return: '0' on Success; Error code otherwise. - * - * @warning Allowed only when DPNI is disabled - */ -int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, +int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, const struct dpni_buffer_layout *layout); /** @@ -594,72 +449,39 @@ int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation + * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or + * for CPU */ enum dpni_offload { DPNI_OFF_RX_L3_CSUM, DPNI_OFF_RX_L4_CSUM, DPNI_OFF_TX_L3_CSUM, DPNI_OFF_TX_L4_CSUM, + DPNI_FLCTYPE_HASH, }; -/** - * dpni_set_offload() - Set DPNI offload configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @type: Type of DPNI offload - * @config: Offload configuration. - * For checksum offloads, non-zero value enables - * the offload. - * - * Return: '0' on Success; Error code otherwise. - * - * @warning Allowed only when DPNI is disabled - */ int dpni_set_offload(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, enum dpni_offload type, uint32_t config); -/** - * dpni_get_offload() - Get DPNI offload configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @type: Type of DPNI offload - * @config: Offload configuration. - * For checksum offloads, a value of 1 indicates that the - * offload is enabled. - * - * Return: '0' on Success; Error code otherwise. - * - * @warning Allowed only when DPNI is disabled - */ int dpni_get_offload(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, enum dpni_offload type, uint32_t *config); -/** - * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used - * for enqueue operations - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue to get QDID for. For applications lookig to - * transmit traffic this should be set to DPNI_QUEUE_TX - * @qdid: Returned virtual QDID value that should be used as an argument - * in all enqueue operations - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_qdid(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - uint16_t *qdid); +int dpni_get_qdid(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, + uint16_t *qdid); + +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t *data_offset); #define DPNI_STATISTICS_CNT 7 @@ -715,6 +537,23 @@ union dpni_statistics { uint64_t egress_confirmed_frames; } page_2; /** + * struct page_3 - Page_3 statistics structure with values for the + * selected TC + * @ceetm_dequeue_bytes: Cumulative count of the number of bytes + * dequeued + * @ceetm_dequeue_frames: Cumulative count of the number of frames + * dequeued + * @ceetm_reject_bytes: Cumulative count of the number of bytes in all + * frames whose enqueue was rejected + * @ceetm_reject_frames: Cumulative count of all frame enqueues rejected + */ + struct { + uint64_t ceetm_dequeue_bytes; + uint64_t ceetm_dequeue_frames; + uint64_t ceetm_reject_bytes; + uint64_t ceetm_reject_frames; + } page_3; + /** * struct raw - raw statistics structure, used to index counters */ struct { @@ -738,6 +577,10 @@ union dpni_statistics { * Enable a-symmetric pause frames */ #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL +/** + * Enable priority flow control pause frames + */ +#define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL /** * struct - Structure representing DPNI link configuration @@ -749,278 +592,117 @@ struct dpni_link_cfg { uint64_t options; }; -/** - * dpni_set_link_cfg() - set the link configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Link configuration - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_link_cfg(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_link_cfg *cfg); +int dpni_set_link_cfg(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const struct dpni_link_cfg *cfg); /** * struct dpni_link_state - Structure representing DPNI link state - * @rate: Rate - * @options: Mask of available options; use 'DPNI_LINK_OPT_' values - * @up: Link state; '0' for down, '1' for up + * @rate: Rate + * @options: Mask of available options; use 'DPNI_LINK_OPT_' values + * @up: Link state; '0' for down, '1' for up */ struct dpni_link_state { - uint32_t rate; - uint64_t options; - int up; + uint32_t rate; + uint64_t options; + int up; }; -/** - * dpni_get_link_state() - Return the link state (either up or down) - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @state: Returned link state; - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_link_state(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_link_state *state); - -/** - * dpni_set_max_frame_length() - Set the maximum received frame length. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @max_frame_length: Maximum received frame length (in - * bytes); frame is discarded if its - * length exceeds this value - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_max_frame_length(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t max_frame_length); - -/** - * dpni_get_max_frame_length() - Get the maximum received frame length. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @max_frame_length: Maximum received frame length (in - * bytes); frame is discarded if its - * length exceeds this value - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_max_frame_length(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t *max_frame_length); - -/** - * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Set to '1' to enable; '0' to disable - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int en); - -/** - * dpni_get_multicast_promisc() - Get multicast promiscuous mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Returns '1' if enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); - -/** - * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Set to '1' to enable; '0' to disable - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int en); - -/** - * dpni_get_unicast_promisc() - Get unicast promiscuous mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Returns '1' if enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); - -/** - * dpni_set_primary_mac_addr() - Set the primary MAC address - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to set as primary address - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); - -/** - * dpni_get_primary_mac_addr() - Get the primary MAC address - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: Returned MAC address - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t mac_addr[6]); - -/** - * dpni_add_mac_addr() - Add MAC address filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to add - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_add_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); - -/** - * dpni_remove_mac_addr() - Remove MAC address filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to remove - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); - -/** - * dpni_clear_mac_filters() - Clear all unicast and/or multicast MAC filters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @unicast: Set to '1' to clear unicast addresses - * @multicast: Set to '1' to clear multicast addresses - * - * The primary MAC address is not cleared by this operation. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_clear_mac_filters(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int unicast, - int multicast); - -/** - * dpni_get_port_mac_addr() - Retrieve MAC address associated to the physical - * port the DPNI is attached to - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address of the physical port, if any, otherwise 0 - * - * The primary MAC address is not modified by this operation. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t mac_addr[6]); - -/** - * dpni_enable_vlan_filter() - Enable/disable VLAN filtering mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @en: Set to '1' to enable; '0' to disable - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int en); +int dpni_get_link_state(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpni_link_state *state); + +int dpni_set_max_frame_length(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t max_frame_length); + +int dpni_get_max_frame_length(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t *max_frame_length); + +int dpni_set_mtu(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t mtu); + +int dpni_get_mtu(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t *mtu); + +int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int en); + +int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); + +int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int en); + +int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); + +int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const uint8_t mac_addr[6]); + +int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t mac_addr[6]); + +int dpni_add_mac_addr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const uint8_t mac_addr[6]); -/** - * dpni_add_vlan_id() - Add VLAN ID filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @vlan_id: VLAN ID to add - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_add_vlan_id(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t vlan_id); +int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + const uint8_t mac_addr[6]); + +int dpni_clear_mac_filters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int unicast, + int multicast); + +int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t mac_addr[6]); + +int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int en); + +int dpni_add_vlan_id(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t vlan_id); -/** - * dpni_remove_vlan_id() - Remove VLAN ID filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @vlan_id: VLAN ID to remove - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t vlan_id); +int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint16_t vlan_id); -/** - * dpni_clear_vlan_filters() - Clear all VLAN filters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * enum dpni_dist_mode - DPNI distribution mode @@ -1050,27 +732,16 @@ enum dpni_fs_miss_action { /** * struct dpni_fs_tbl_cfg - Flow Steering table configuration - * @miss_action: Miss action selection - * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID' + * @miss_action: Miss action selection + * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID' */ struct dpni_fs_tbl_cfg { - enum dpni_fs_miss_action miss_action; - uint16_t default_flow_id; + enum dpni_fs_miss_action miss_action; + uint16_t default_flow_id; + char keep_hash_key; }; /** - * dpni_prepare_key_cfg() - function prepare extract parameters - * @cfg: defining a full Key Generation profile (rule) - * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA - * - * This function has to be called before the following functions: - * - dpni_set_rx_tc_dist() - * - dpni_set_qos_table() - */ -int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, - uint8_t *key_cfg_buf); - -/** * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration * @dist_size: Set the distribution size; * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96, @@ -1078,36 +749,24 @@ int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, * @dist_mode: Distribution mode * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with * the extractions to be used for the distribution key by calling - * dpni_prepare_key_cfg() relevant only when + * dpkg_prepare_key_cfg() relevant only when * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0' * @fs_cfg: Flow Steering table configuration; only relevant if * 'dist_mode = DPNI_DIST_MODE_FS' */ struct dpni_rx_tc_dist_cfg { - uint16_t dist_size; - enum dpni_dist_mode dist_mode; - uint64_t key_cfg_iova; - struct dpni_fs_tbl_cfg fs_cfg; + uint16_t dist_size; + enum dpni_dist_mode dist_mode; + uint64_t key_cfg_iova; + struct dpni_fs_tbl_cfg fs_cfg; }; -/** - * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @tc_id: Traffic class selection (0-7) - * @cfg: Traffic class distribution configuration - * - * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpni_prepare_key_cfg() - * first to prepare the key_cfg_iova parameter - * - * Return: '0' on Success; error code otherwise. - */ -int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t tc_id, - const struct dpni_rx_tc_dist_cfg *cfg); +int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t tc_id, + const struct dpni_rx_tc_dist_cfg *cfg); + /** * enum dpni_congestion_unit - DPNI congestion units * @DPNI_CONGESTION_UNIT_BYTES: bytes units @@ -1147,9 +806,9 @@ enum dpni_dest { * channel; not relevant for 'DPNI_DEST_NONE' option */ struct dpni_dest_cfg { - enum dpni_dest dest_type; - int dest_id; - uint8_t priority; + enum dpni_dest dest_type; + int dest_id; + uint8_t priority; }; /* DPNI congestion options */ @@ -1186,6 +845,11 @@ struct dpni_dest_cfg { * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled) */ #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020 +/** + * This congestion will trigger flow control or priority flow control. This + * will have effect only if flow control is enabled with dpni_set_link_cfg() + */ +#define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040 /** * struct dpni_congestion_notification_cfg - congestion notification @@ -1203,54 +867,35 @@ struct dpni_dest_cfg { */ struct dpni_congestion_notification_cfg { - enum dpni_congestion_unit units; - uint32_t threshold_entry; - uint32_t threshold_exit; - uint64_t message_ctx; - uint64_t message_iova; - struct dpni_dest_cfg dest_cfg; - uint16_t notification_mode; + enum dpni_congestion_unit units; + uint32_t threshold_entry; + uint32_t threshold_exit; + uint64_t message_ctx; + uint64_t message_iova; + struct dpni_dest_cfg dest_cfg; + uint16_t notification_mode; }; -/** - * dpni_set_congestion_notification() - Set traffic class congestion - * notification configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue - Rx, Tx and Tx confirm types are supported - * @tc_id: Traffic class selection (0-7) - * @cfg: congestion notification configuration - * - * Return: '0' on Success; error code otherwise. - */ -int dpni_set_congestion_notification( - struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - uint8_t tc_id, +int dpni_set_congestion_notification(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, + uint8_t tc_id, const struct dpni_congestion_notification_cfg *cfg); -/** - * dpni_get_congestion_notification() - Get traffic class congestion - * notification configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue - Rx, Tx and Tx confirm types are supported - * @tc_id: Traffic class selection (0-7) - * @cfg: congestion notification configuration - * - * Return: '0' on Success; error code otherwise. - */ -int dpni_get_congestion_notification(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type qtype, - uint8_t tc_id, +int dpni_get_congestion_notification(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_queue_type qtype, + uint8_t tc_id, struct dpni_congestion_notification_cfg *cfg); +/* DPNI FLC stash options */ + +/** + * stashes the whole annotation area (up to 192 bytes) + */ +#define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001 /** * struct dpni_queue - Queue structure @@ -1291,9 +936,25 @@ struct dpni_queue { uint64_t user_context; /** * struct flc - FD FLow Context structure - * @value: FLC value to set - * @stash_control: Boolean, indicates whether the 6 lowest - * significant bits are used for stash control. + * @value: Default FLC value for traffic dequeued from + * this queue. Please check description of FD + * structure for more information. + * Note that FLC values set using dpni_add_fs_entry, + * if any, take precedence over values per queue. + * @stash_control: Boolean, indicates whether the 6 lowest + * - significant bits are used for stash control. + * significant bits are used for stash control. If set, the 6 + * least significant bits in value are interpreted as follows: + * - bits 0-1: indicates the number of 64 byte units of context + * that are stashed. FLC value is interpreted as a memory address + * in this case, excluding the 6 LS bits. + * - bits 2-3: indicates the number of 64 byte units of frame + * annotation to be stashed. Annotation is placed at FD[ADDR]. + * - bits 4-5: indicates the number of 64 byte units of frame + * data to be stashed. Frame data is placed at FD[ADDR] + + * FD[OFFSET]. + * For more details check the Frame Descriptor section in the + * hardware documentation. */ struct { uint64_t value; @@ -1331,41 +992,16 @@ enum dpni_confirmation_mode { DPNI_CONF_DISABLE, }; -/** - * dpni_set_tx_confirmation_mode() - Tx confirmation mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mode: Tx confirmation mode - * - * This function is useful only when 'DPNI_OPT_TX_CONF_DISABLED' is not - * selected at DPNI creation. - * Calling this function with 'mode' set to DPNI_CONF_DISABLE disables all - * transmit confirmation (including the private confirmation queues), regardless - * of previous settings; Note that in this case, Tx error frames are still - * enqueued to the general transmit errors queue. - * Calling this function with 'mode' set to DPNI_CONF_SINGLE switches all - * Tx confirmations to a shared Tx conf queue. The ID of the queue when - * calling dpni_set/get_queue is -1. - * Tx confirmation mode can only be changed while the DPNI is disabled. - * Executing this command while the DPNI is enabled will return an error. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_confirmation_mode mode); +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_confirmation_mode mode); + +int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + enum dpni_confirmation_mode *mode); -/** - * dpni_get_api_version() - Get Data Path Network Interface API version - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: Major version of data path network interface API - * @minor_ver: Minor version of data path network interface API - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t *major_ver, @@ -1396,23 +1032,6 @@ int dpni_get_api_version(struct fsl_mc_io *mc_io, */ #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008 -/** - * dpni_set_queue() - Set queue parameters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue - all queue types are supported, although - * the command is ignored for Tx - * @tc: Traffic class, in range 0 to NUM_TCS - 1 - * @index: Selects the specific queue out of the set - * allocated for the same TC.Value must be in - * range 0 to NUM_QUEUES - 1 - * @options: A combination of DPNI_QUEUE_OPT_ values that control - * what configuration options are set on the queue - * @queue: Queue configuration structure - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_set_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -1422,31 +1041,6 @@ int dpni_set_queue(struct fsl_mc_io *mc_io, uint8_t options, const struct dpni_queue *queue); -/** - * dpni_get_queue() - Get queue parameters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qtype: Type of queue - all queue types are supported - * @tc: Traffic class, in range 0 to NUM_TCS - 1 - * @index: Selects the specific queue out of the set allocated - * for the same TC. Value must be in range 0 to - * NUM_QUEUES - 1 - * @queue: Queue configuration structure - * @qid: Queue identification - * - * This function returns current queue configuration which can be changed by - * calling dpni_set_queue, and queue identification information. - * Returned qid.fqid and/or qid.qdbin values can be used to: - * - enqueue traffic for Tx queues, - * - perform volatile dequeue for Rx and, if applicable, Tx confirmation - * clean-up, - * - retrieve queue state. - * - * All these operations are supported through the DPIO run-time API. - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_get_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -1456,32 +1050,13 @@ int dpni_get_queue(struct fsl_mc_io *mc_io, struct dpni_queue *queue, struct dpni_queue_id *qid); -/** - * dpni_get_statistics() - Get DPNI statistics - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @page: Selects the statistics page to retrieve, see - * DPNI_GET_STATISTICS output. - * Pages are numbered 0 to 2. - * @stat: Structure containing the statistics - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_get_statistics(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t page, + uint8_t param, union dpni_statistics *stat); -/** - * dpni_reset_statistics() - Clears DPNI statistics - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_reset_statistics(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token); @@ -1505,40 +1080,25 @@ enum dpni_congestion_point { * struct dpni_taildrop - Structure representing the taildrop * @enable: Indicates whether the taildrop is active or not. * @units: Indicates the unit of THRESHOLD. Queue taildrop only - * supports byte units, this field is ignored and - * assumed = 0 if CONGESTION_POINT is 0. + * supports byte units, this field is ignored and + * assumed = 0 if CONGESTION_POINT is 0. * @threshold: Threshold value, in units identified by UNITS field. Value 0 - * cannot be used as a valid taildrop threshold, - * THRESHOLD must be > 0 if the taildrop is - * enabled. + * cannot be used as a valid taildrop threshold, + * THRESHOLD must be > 0 if the taildrop is + * enabled. + * @oal : Overhead Accounting Length, a 12-bit, 2's complement value + * with range (-2048 to +2047) representing a fixed per-frame + * overhead to be added to the actual length of a frame when + * performing WRED and tail drop calculations and threshold + * comparisons. */ struct dpni_taildrop { char enable; enum dpni_congestion_unit units; uint32_t threshold; + int16_t oal; }; -/** - * dpni_set_taildrop() - Set taildrop per queue or TC - * - * Setting a per-TC taildrop (cg_point = DPNI_CP_GROUP) will reset any current - * congestion notification or early drop (WRED) configuration previously applied - * to the same TC. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cg_point: Congestion point. DPNI_CP_QUEUE is only supported in - * combination with DPNI_QUEUE_RX. - * @q_type: Queue type, can be DPNI_QUEUE_RX or DPNI_QUEUE_TX. - * @tc: Traffic class to apply this taildrop to - * @q_index: Index of the queue if the DPNI supports multiple queues for - * traffic distribution. - * Ignored if CONGESTION_POINT is not DPNI_CP_QUEUE. - * @taildrop: Taildrop structure - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_set_taildrop(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -1548,21 +1108,6 @@ int dpni_set_taildrop(struct fsl_mc_io *mc_io, uint8_t q_index, struct dpni_taildrop *taildrop); -/** - * dpni_get_taildrop() - Get taildrop information - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cg_point: Congestion point - * @q_type: - * @tc: Traffic class to apply this taildrop to - * @q_index: Index of the queue if the DPNI supports multiple queues for - * traffic distribution. Ignored if CONGESTION_POINT - * is not 0. - * @taildrop: Taildrop structure - * - * Return: '0' on Success; Error code otherwise. - */ int dpni_get_taildrop(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h index 2ac397c..81226aa 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,435 +42,547 @@ /* DPNI Version */ #define DPNI_VER_MAJOR 7 -#define DPNI_VER_MINOR 0 +#define DPNI_VER_MINOR 3 + +#define DPNI_CMD_BASE_VERSION 1 +#define DPNI_CMD_VERSION_2 2 +#define DPNI_CMD_ID_OFFSET 4 + +#define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION) +#define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2) /* Command IDs */ -#define DPNI_CMDID_OPEN ((0x801 << 4) | (0x1)) -#define DPNI_CMDID_CLOSE ((0x800 << 4) | (0x1)) -#define DPNI_CMDID_CREATE ((0x901 << 4) | (0x1)) -#define DPNI_CMDID_DESTROY ((0x981 << 4) | (0x1)) -#define DPNI_CMDID_GET_API_VERSION ((0xa01 << 4) | (0x1)) - -#define DPNI_CMDID_ENABLE ((0x002 << 4) | (0x1)) -#define DPNI_CMDID_DISABLE ((0x003 << 4) | (0x1)) -#define DPNI_CMDID_GET_ATTR ((0x004 << 4) | (0x1)) -#define DPNI_CMDID_RESET ((0x005 << 4) | (0x1)) -#define DPNI_CMDID_IS_ENABLED ((0x006 << 4) | (0x1)) - -#define DPNI_CMDID_SET_POOLS ((0x200 << 4) | (0x1)) -#define DPNI_CMDID_SET_ERRORS_BEHAVIOR ((0x20B << 4) | (0x1)) - -#define DPNI_CMDID_GET_QDID ((0x210 << 4) | (0x1)) -#define DPNI_CMDID_GET_LINK_STATE ((0x215 << 4) | (0x1)) -#define DPNI_CMDID_SET_MAX_FRAME_LENGTH ((0x216 << 4) | (0x1)) -#define DPNI_CMDID_GET_MAX_FRAME_LENGTH ((0x217 << 4) | (0x1)) -#define DPNI_CMDID_SET_LINK_CFG ((0x21a << 4) | (0x1)) - -#define DPNI_CMDID_SET_MCAST_PROMISC ((0x220 << 4) | (0x1)) -#define DPNI_CMDID_GET_MCAST_PROMISC ((0x221 << 4) | (0x1)) -#define DPNI_CMDID_SET_UNICAST_PROMISC ((0x222 << 4) | (0x1)) -#define DPNI_CMDID_GET_UNICAST_PROMISC ((0x223 << 4) | (0x1)) -#define DPNI_CMDID_SET_PRIM_MAC ((0x224 << 4) | (0x1)) -#define DPNI_CMDID_GET_PRIM_MAC ((0x225 << 4) | (0x1)) -#define DPNI_CMDID_ADD_MAC_ADDR ((0x226 << 4) | (0x1)) -#define DPNI_CMDID_REMOVE_MAC_ADDR ((0x227 << 4) | (0x1)) -#define DPNI_CMDID_CLR_MAC_FILTERS ((0x228 << 4) | (0x1)) - -#define DPNI_CMDID_ENABLE_VLAN_FILTER ((0x230 << 4) | (0x1)) -#define DPNI_CMDID_ADD_VLAN_ID ((0x231 << 4) | (0x1)) -#define DPNI_CMDID_REMOVE_VLAN_ID ((0x232 << 4) | (0x1)) -#define DPNI_CMDID_CLR_VLAN_FILTERS ((0x233 << 4) | (0x1)) - -#define DPNI_CMDID_SET_RX_TC_DIST ((0x235 << 4) | (0x1)) - -#define DPNI_CMDID_GET_STATISTICS ((0x25D << 4) | (0x1)) -#define DPNI_CMDID_RESET_STATISTICS ((0x25E << 4) | (0x1)) -#define DPNI_CMDID_GET_QUEUE ((0x25F << 4) | (0x1)) -#define DPNI_CMDID_SET_QUEUE ((0x260 << 4) | (0x1)) -#define DPNI_CMDID_GET_TAILDROP ((0x261 << 4) | (0x1)) -#define DPNI_CMDID_SET_TAILDROP ((0x262 << 4) | (0x1)) - -#define DPNI_CMDID_GET_PORT_MAC_ADDR ((0x263 << 4) | (0x1)) - -#define DPNI_CMDID_GET_BUFFER_LAYOUT ((0x264 << 4) | (0x1)) -#define DPNI_CMDID_SET_BUFFER_LAYOUT ((0x265 << 4) | (0x1)) - -#define DPNI_CMDID_SET_CONGESTION_NOTIFICATION ((0x267 << 4) | (0x1)) -#define DPNI_CMDID_GET_CONGESTION_NOTIFICATION ((0x268 << 4) | (0x1)) -#define DPNI_CMDID_GET_OFFLOAD ((0x26B << 4) | (0x1)) -#define DPNI_CMDID_SET_OFFLOAD ((0x26C << 4) | (0x1)) -#define DPNI_CMDID_SET_TX_CONFIRMATION_MODE ((0x266 << 4) | (0x1)) -#define DPNI_CMDID_GET_TX_CONFIRMATION_MODE ((0x26D << 4) | (0x1)) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_OPEN(cmd, dpni_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, (cfg)->options); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, (cfg)->num_queues); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, (cfg)->num_tcs); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, (cfg)->mac_filter_entries); \ - MC_CMD_OP(cmd, 1, 0, 8, uint8_t, (cfg)->vlan_filter_entries); \ - MC_CMD_OP(cmd, 1, 16, 8, uint8_t, (cfg)->qos_entries); \ - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, (cfg)->fs_entries); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_POOLS(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \ - MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \ - MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \ - MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \ - MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \ - MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \ - MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \ - MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \ - MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \ - MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \ - MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\ - MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \ - MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\ - MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \ - MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\ - MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \ - MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\ - MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \ - MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\ - MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \ - MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\ - MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \ - MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\ - MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \ - MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* DPNI_CMD_GET_ATTR is not used, no input parameters */ - -#define DPNI_RSP_GET_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, (attr)->options); \ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, (attr)->num_queues); \ - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, (attr)->num_tcs); \ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, (attr)->mac_filter_entries); \ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, (attr)->vlan_filter_entries); \ - MC_RSP_OP(cmd, 1, 16, 8, uint8_t, (attr)->qos_entries); \ - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, (attr)->fs_entries); \ - MC_RSP_OP(cmd, 2, 0, 8, uint8_t, (attr)->qos_key_size); \ - MC_RSP_OP(cmd, 2, 8, 8, uint8_t, (attr)->fs_key_size); \ - MC_RSP_OP(cmd, 2, 16, 16, uint16_t, (attr)->wriop_version); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \ - MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \ - MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \ -} while (0) - -#define DPNI_CMD_GET_BUFFER_LAYOUT(cmd, qtype) \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype) - -#define DPNI_RSP_GET_BUFFER_LAYOUT(cmd, layout) \ -do { \ - MC_RSP_OP(cmd, 0, 48, 1, char, (layout)->pass_timestamp); \ - MC_RSP_OP(cmd, 0, 49, 1, char, (layout)->pass_parser_result); \ - MC_RSP_OP(cmd, 0, 50, 1, char, (layout)->pass_frame_status); \ - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, (layout)->private_data_size); \ - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, (layout)->data_align); \ - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, (layout)->data_head_room); \ - MC_RSP_OP(cmd, 1, 48, 16, uint16_t, (layout)->data_tail_room); \ -} while (0) - -#define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, qtype, layout) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype); \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, (layout)->options); \ - MC_CMD_OP(cmd, 0, 48, 1, char, (layout)->pass_timestamp); \ - MC_CMD_OP(cmd, 0, 49, 1, char, (layout)->pass_parser_result); \ - MC_CMD_OP(cmd, 0, 50, 1, char, (layout)->pass_frame_status); \ - MC_CMD_OP(cmd, 1, 0, 16, uint16_t, (layout)->private_data_size); \ - MC_CMD_OP(cmd, 1, 16, 16, uint16_t, (layout)->data_align); \ - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, (layout)->data_head_room); \ - MC_CMD_OP(cmd, 1, 48, 16, uint16_t, (layout)->data_tail_room); \ -} while (0) - -#define DPNI_CMD_SET_OFFLOAD(cmd, type, config) \ -do { \ - MC_CMD_OP(cmd, 0, 24, 8, enum dpni_offload, type); \ - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, config); \ -} while (0) - -#define DPNI_CMD_GET_OFFLOAD(cmd, type) \ - MC_CMD_OP(cmd, 0, 24, 8, enum dpni_offload, type) - -#define DPNI_RSP_GET_OFFLOAD(cmd, config) \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, config) - -#define DPNI_CMD_GET_QDID(cmd, qtype) \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_QDID(cmd, qdid) \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid) - - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_GET_STATISTICS(cmd, page) \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, page) - -#define DPNI_RSP_GET_STATISTICS(cmd, stat) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->raw.counter[0]); \ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->raw.counter[1]); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->raw.counter[2]); \ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->raw.counter[3]); \ - MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->raw.counter[4]); \ - MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->raw.counter[5]); \ - MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->raw.counter[6]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\ - MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_LINK_STATE(cmd, state) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_MAX_FRAME_LENGTH(cmd, max_frame_length) \ - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, max_frame_length) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_MAX_FRAME_LENGTH(cmd, max_frame_length) \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, max_frame_length) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en) \ - MC_CMD_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_MULTICAST_PROMISC(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_UNICAST_PROMISC(cmd, en) \ - MC_CMD_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_UNICAST_PROMISC(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -#define DPNI_RSP_GET_PORT_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_CLEAR_MAC_FILTERS(cmd, unicast, multicast) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 1, int, unicast); \ - MC_CMD_OP(cmd, 0, 1, 1, int, multicast); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_ENABLE_VLAN_FILTER(cmd, en) \ - MC_CMD_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_ADD_VLAN_ID(cmd, vlan_id) \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, vlan_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_REMOVE_VLAN_ID(cmd, vlan_id) \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, vlan_id) - - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_RX_TC_DIST(cmd, tc_id, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->dist_size); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \ - MC_CMD_OP(cmd, 0, 24, 4, enum dpni_dist_mode, cfg->dist_mode); \ - MC_CMD_OP(cmd, 0, 28, 4, enum dpni_fs_miss_action, \ - cfg->fs_cfg.miss_action); \ - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, cfg->fs_cfg.default_flow_id); \ - MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_cfg_iova); \ -} while (0) - -#define DPNI_CMD_GET_QUEUE(cmd, qtype, tc, index) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \ -} while (0) - -#define DPNI_RSP_GET_QUEUE(cmd, queue, queue_id) \ -do { \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \ - MC_RSP_OP(cmd, 1, 48, 8, uint8_t, (queue)->destination.priority); \ - MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \ - MC_RSP_OP(cmd, 1, 62, 1, char, (queue)->flc.stash_control); \ - MC_RSP_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc.value); \ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \ - MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (queue_id)->fqid); \ - MC_RSP_OP(cmd, 4, 32, 16, uint16_t, (queue_id)->qdbin); \ -} while (0) - -#define DPNI_CMD_SET_QUEUE(cmd, qtype, tc, index, options, queue) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, options); \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \ - MC_CMD_OP(cmd, 1, 48, 8, uint8_t, (queue)->destination.priority); \ - MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \ - MC_CMD_OP(cmd, 1, 62, 1, char, (queue)->flc.stash_control); \ - MC_CMD_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \ - MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc.value); \ - MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) - -#define DPNI_CMD_GET_TAILDROP(cmd, cp, q_type, tc, q_index) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_congestion_point, cp); \ - MC_CMD_OP(cmd, 0, 8, 8, enum dpni_queue_type, q_type); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, q_index); \ -} while (0) - -#define DPNI_RSP_GET_TAILDROP(cmd, taildrop) \ -do { \ - MC_RSP_OP(cmd, 1, 0, 1, char, (taildrop)->enable); \ - MC_RSP_OP(cmd, 1, 16, 8, enum dpni_congestion_unit, \ - (taildrop)->units); \ - MC_RSP_OP(cmd, 1, 32, 32, uint32_t, (taildrop)->threshold); \ -} while (0) - -#define DPNI_CMD_SET_TAILDROP(cmd, cp, q_type, tc, q_index, taildrop) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_congestion_point, cp); \ - MC_CMD_OP(cmd, 0, 8, 8, enum dpni_queue_type, q_type); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, q_index); \ - MC_CMD_OP(cmd, 1, 0, 1, char, (taildrop)->enable); \ - MC_CMD_OP(cmd, 1, 16, 8, enum dpni_congestion_unit, \ - (taildrop)->units); \ - MC_CMD_OP(cmd, 1, 32, 32, uint32_t, (taildrop)->threshold); \ -} while (0) - -#define DPNI_CMD_SET_TX_CONFIRMATION_MODE(cmd, mode) \ - MC_CMD_OP(cmd, 0, 32, 8, enum dpni_confirmation_mode, mode) - -#define DPNI_RSP_GET_TX_CONFIRMATION_MODE(cmd, mode) \ - MC_RSP_OP(cmd, 0, 32, 8, enum dpni_confirmation_mode, mode) - -#define DPNI_CMD_SET_CONGESTION_NOTIFICATION(cmd, qtype, tc, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (cfg)->dest_cfg.dest_id); \ - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, (cfg)->notification_mode); \ - MC_CMD_OP(cmd, 1, 48, 8, uint8_t, (cfg)->dest_cfg.priority); \ - MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (cfg)->dest_cfg.dest_type); \ - MC_CMD_OP(cmd, 1, 60, 2, enum dpni_congestion_unit, (cfg)->units); \ - MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (cfg)->message_iova); \ - MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (cfg)->message_ctx); \ - MC_CMD_OP(cmd, 4, 0, 32, uint32_t, (cfg)->threshold_entry); \ - MC_CMD_OP(cmd, 4, 32, 32, uint32_t, (cfg)->threshold_exit); \ -} while (0) - -#define DPNI_CMD_GET_CONGESTION_NOTIFICATION(cmd, qtype, tc) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, qtype); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ -} while (0) - -#define DPNI_RSP_GET_CONGESTION_NOTIFICATION(cmd, cfg) \ -do { \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (cfg)->dest_cfg.dest_id); \ - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, (cfg)->notification_mode); \ - MC_RSP_OP(cmd, 1, 48, 8, uint8_t, (cfg)->dest_cfg.priority); \ - MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (cfg)->dest_cfg.dest_type); \ - MC_RSP_OP(cmd, 1, 60, 2, enum dpni_congestion_unit, (cfg)->units); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (cfg)->message_iova); \ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (cfg)->message_ctx); \ - MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (cfg)->threshold_entry); \ - MC_RSP_OP(cmd, 4, 32, 32, uint32_t, (cfg)->threshold_exit); \ -} while (0) +#define DPNI_CMDID_OPEN DPNI_CMD(0x801) +#define DPNI_CMDID_CLOSE DPNI_CMD(0x800) +#define DPNI_CMDID_CREATE DPNI_CMD(0x901) +#define DPNI_CMDID_DESTROY DPNI_CMD(0x981) +#define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01) + +#define DPNI_CMDID_ENABLE DPNI_CMD(0x002) +#define DPNI_CMDID_DISABLE DPNI_CMD(0x003) +#define DPNI_CMDID_GET_ATTR DPNI_CMD_V2(0x004) +#define DPNI_CMDID_RESET DPNI_CMD(0x005) +#define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006) + +#define DPNI_CMDID_SET_POOLS DPNI_CMD_V2(0x200) +#define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B) + +#define DPNI_CMDID_GET_QDID DPNI_CMD(0x210) +#define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211) +#define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212) +#define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215) +#define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216) +#define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217) +#define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A) +#define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B) + +#define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220) +#define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221) +#define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222) +#define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223) +#define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224) +#define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225) +#define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226) +#define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227) +#define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228) + +#define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230) +#define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD(0x231) +#define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232) +#define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233) + +#define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V2(0x235) + +#define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V2(0x25D) +#define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E) +#define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F) +#define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260) +#define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261) +#define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262) + +#define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263) + +#define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264) +#define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265) + +#define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267) +#define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268) +#define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269) +#define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A) +#define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B) +#define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C) +#define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266) +#define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D) + +/* Macros for accessing command fields smaller than 1byte */ +#define DPNI_MASK(field) \ + GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \ + DPNI_##field##_SHIFT) +#define dpni_set_field(var, field, val) \ + ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field))) +#define dpni_get_field(var, field) \ + (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpni_cmd_open { + uint32_t dpni_id; +}; + +struct dpni_cmd_create { + uint32_t options; + uint8_t num_queues; + uint8_t num_tcs; + uint8_t mac_filter_entries; + uint8_t pad1; + uint8_t vlan_filter_entries; + uint8_t pad2; + uint8_t qos_entries; + uint8_t pad3; + uint16_t fs_entries; +}; + +struct dpni_cmd_destroy { + uint32_t dpsw_id; +}; + +#define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order)) + +struct dpni_cmd_pool { + uint16_t dpbp_id; + uint8_t priority_mask; + uint8_t pad; +}; + +struct dpni_cmd_set_pools { + uint8_t num_dpbp; + uint8_t backup_pool_mask; + uint16_t pad; + struct dpni_cmd_pool pool[8]; + uint16_t buffer_size[8]; +}; + +/* The enable indication is always the least significant bit */ +#define DPNI_ENABLE_SHIFT 0 +#define DPNI_ENABLE_SIZE 1 + +struct dpni_rsp_is_enabled { + uint8_t enabled; +}; + +struct dpni_rsp_get_attr { + /* response word 0 */ + uint32_t options; + uint8_t num_queues; + uint8_t num_rx_tcs; + uint8_t mac_filter_entries; + uint8_t num_tx_tcs; + /* response word 1 */ + uint8_t vlan_filter_entries; + uint8_t pad1; + uint8_t qos_entries; + uint8_t pad2; + uint16_t fs_entries; + uint16_t pad3; + /* response word 2 */ + uint8_t qos_key_size; + uint8_t fs_key_size; + uint16_t wriop_version; +}; + +#define DPNI_ERROR_ACTION_SHIFT 0 +#define DPNI_ERROR_ACTION_SIZE 4 +#define DPNI_FRAME_ANN_SHIFT 4 +#define DPNI_FRAME_ANN_SIZE 1 + +struct dpni_cmd_set_errors_behavior { + uint32_t errors; + /* from least significant bit: error_action:4, set_frame_annotation:1 */ + uint8_t flags; +}; + +/* There are 3 separate commands for configuring Rx, Tx and Tx confirmation + * buffer layouts, but they all share the same parameters. + * If one of the functions changes, below structure needs to be split. + */ +#define DPNI_PASS_TS_SHIFT 0 +#define DPNI_PASS_TS_SIZE 1 +#define DPNI_PASS_PR_SHIFT 1 +#define DPNI_PASS_PR_SIZE 1 +#define DPNI_PASS_FS_SHIFT 2 +#define DPNI_PASS_FS_SIZE 1 + +struct dpni_cmd_get_buffer_layout { + uint8_t qtype; +}; + +struct dpni_rsp_get_buffer_layout { + /* response word 0 */ + uint8_t pad0[6]; + /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */ + uint8_t flags; + uint8_t pad1; + /* response word 1 */ + uint16_t private_data_size; + uint16_t data_align; + uint16_t head_room; + uint16_t tail_room; +}; + +struct dpni_cmd_set_buffer_layout { + /* cmd word 0 */ + uint8_t qtype; + uint8_t pad0[3]; + uint16_t options; + /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */ + uint8_t flags; + uint8_t pad1; + /* cmd word 1 */ + uint16_t private_data_size; + uint16_t data_align; + uint16_t head_room; + uint16_t tail_room; +}; + +struct dpni_cmd_set_offload { + uint8_t pad[3]; + uint8_t dpni_offload; + uint32_t config; +}; + +struct dpni_cmd_get_offload { + uint8_t pad[3]; + uint8_t dpni_offload; +}; + +struct dpni_rsp_get_offload { + uint32_t pad; + uint32_t config; +}; + +struct dpni_cmd_get_qdid { + uint8_t qtype; +}; + +struct dpni_rsp_get_qdid { + uint16_t qdid; +}; + +struct dpni_rsp_get_sp_info { + uint16_t spids[2]; +}; + +struct dpni_rsp_get_tx_data_offset { + uint16_t data_offset; +}; + +struct dpni_cmd_get_statistics { + uint8_t page_number; + uint8_t param; +}; + +struct dpni_rsp_get_statistics { + uint64_t counter[7]; +}; + +struct dpni_cmd_set_link_cfg { + uint64_t pad0; + uint32_t rate; + uint32_t pad1; + uint64_t options; +}; + +#define DPNI_LINK_STATE_SHIFT 0 +#define DPNI_LINK_STATE_SIZE 1 + +struct dpni_rsp_get_link_state { + uint32_t pad0; + /* from LSB: up:1 */ + uint8_t flags; + uint8_t pad1[3]; + uint32_t rate; + uint32_t pad2; + uint64_t options; +}; + +struct dpni_cmd_set_max_frame_length { + uint16_t max_frame_length; +}; + +struct dpni_rsp_get_max_frame_length { + uint16_t max_frame_length; +}; + +struct dpni_cmd_set_multicast_promisc { + uint8_t enable; +}; + +struct dpni_rsp_get_multicast_promisc { + uint8_t enabled; +}; + +struct dpni_cmd_set_unicast_promisc { + uint8_t enable; +}; + +struct dpni_rsp_get_unicast_promisc { + uint8_t enabled; +}; + +struct dpni_cmd_set_primary_mac_addr { + uint16_t pad; + uint8_t mac_addr[6]; +}; + +struct dpni_rsp_get_primary_mac_addr { + uint16_t pad; + uint8_t mac_addr[6]; +}; + +struct dpni_rsp_get_port_mac_addr { + uint16_t pad; + uint8_t mac_addr[6]; +}; + +struct dpni_cmd_add_mac_addr { + uint16_t pad; + uint8_t mac_addr[6]; +}; + +struct dpni_cmd_remove_mac_addr { + uint16_t pad; + uint8_t mac_addr[6]; +}; + +#define DPNI_UNICAST_FILTERS_SHIFT 0 +#define DPNI_UNICAST_FILTERS_SIZE 1 +#define DPNI_MULTICAST_FILTERS_SHIFT 1 +#define DPNI_MULTICAST_FILTERS_SIZE 1 + +struct dpni_cmd_clear_mac_filters { + /* from LSB: unicast:1, multicast:1 */ + uint8_t flags; +}; + +struct dpni_cmd_enable_vlan_filter { + /* only the LSB */ + uint8_t en; +}; + +struct dpni_cmd_vlan_id { + uint32_t pad; + uint16_t vlan_id; +}; + +#define DPNI_SEPARATE_GRP_SHIFT 0 +#define DPNI_SEPARATE_GRP_SIZE 1 +#define DPNI_MODE_1_SHIFT 0 +#define DPNI_MODE_1_SIZE 4 +#define DPNI_MODE_2_SHIFT 4 +#define DPNI_MODE_2_SIZE 4 + +struct dpni_cmd_set_tx_priorities { + uint16_t flags; + uint8_t prio_group_A; + uint8_t prio_group_B; + uint32_t pad0; + uint8_t modes[4]; + uint32_t pad1; + uint64_t pad2; + uint16_t delta_bandwidth[8]; +}; + +#define DPNI_DIST_MODE_SHIFT 0 +#define DPNI_DIST_MODE_SIZE 4 +#define DPNI_MISS_ACTION_SHIFT 4 +#define DPNI_MISS_ACTION_SIZE 4 +#define DPNI_KEEP_HASH_KEY_SHIFT 7 +#define DPNI_KEEP_HASH_KEY_SIZE 1 + +struct dpni_cmd_set_rx_tc_dist { + uint16_t dist_size; + uint8_t tc_id; + /* from LSB: dist_mode:4, miss_action:4 */ + uint8_t flags; + uint8_t pad0; + /* only the LSB */ + uint8_t keep_hash_key; + uint16_t default_flow_id; + uint64_t pad1[5]; + uint64_t key_cfg_iova; +}; + +struct dpni_cmd_get_queue { + uint8_t qtype; + uint8_t tc; + uint8_t index; +}; + +#define DPNI_DEST_TYPE_SHIFT 0 +#define DPNI_DEST_TYPE_SIZE 4 +#define DPNI_STASH_CTRL_SHIFT 6 +#define DPNI_STASH_CTRL_SIZE 1 +#define DPNI_HOLD_ACTIVE_SHIFT 7 +#define DPNI_HOLD_ACTIVE_SIZE 1 + +struct dpni_rsp_get_queue { + /* response word 0 */ + uint64_t pad0; + /* response word 1 */ + uint32_t dest_id; + uint16_t pad1; + uint8_t dest_prio; + /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */ + uint8_t flags; + /* response word 2 */ + uint64_t flc; + /* response word 3 */ + uint64_t user_context; + /* response word 4 */ + uint32_t fqid; + uint16_t qdbin; +}; + +struct dpni_cmd_set_queue { + /* cmd word 0 */ + uint8_t qtype; + uint8_t tc; + uint8_t index; + uint8_t options; + uint32_t pad0; + /* cmd word 1 */ + uint32_t dest_id; + uint16_t pad1; + uint8_t dest_prio; + uint8_t flags; + /* cmd word 2 */ + uint64_t flc; + /* cmd word 3 */ + uint64_t user_context; +}; + +#define DPNI_DROP_ENABLE_SHIFT 0 +#define DPNI_DROP_ENABLE_SIZE 1 +#define DPNI_DROP_UNITS_SHIFT 2 +#define DPNI_DROP_UNITS_SIZE 2 + +struct dpni_early_drop { + /* from LSB: enable:1 units:2 */ + uint8_t flags; + uint8_t pad0[3]; + uint32_t pad1; + uint8_t green_drop_probability; + uint8_t pad2[7]; + uint64_t green_max_threshold; + uint64_t green_min_threshold; + uint64_t pad3; + uint8_t yellow_drop_probability; + uint8_t pad4[7]; + uint64_t yellow_max_threshold; + uint64_t yellow_min_threshold; + uint64_t pad5; + uint8_t red_drop_probability; + uint8_t pad6[7]; + uint64_t red_max_threshold; + uint64_t red_min_threshold; +}; + +struct dpni_cmd_early_drop { + uint8_t qtype; + uint8_t tc; + uint8_t pad[6]; + uint64_t early_drop_iova; +}; + +struct dpni_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; + +struct dpni_cmd_get_taildrop { + uint8_t congestion_point; + uint8_t qtype; + uint8_t tc; + uint8_t index; +}; + +struct dpni_rsp_get_taildrop { + /* cmd word 0 */ + uint64_t pad0; + /* cmd word 1 */ + /* from LSB: enable:1 oal_lo:7 */ + uint8_t enable_oal_lo; + /* from LSB: oal_hi:5 */ + uint8_t oal_hi; + uint8_t units; + uint8_t pad2; + uint32_t threshold; +}; + +#define DPNI_OAL_LO_SHIFT 1 +#define DPNI_OAL_LO_SIZE 7 +#define DPNI_OAL_HI_SHIFT 0 +#define DPNI_OAL_HI_SIZE 5 + +struct dpni_cmd_set_taildrop { + /* cmd word 0 */ + uint8_t congestion_point; + uint8_t qtype; + uint8_t tc; + uint8_t index; + uint32_t pad0; + /* cmd word 1 */ + /* from LSB: enable:1 oal_lo:7 */ + uint8_t enable_oal_lo; + /* from LSB: oal_hi:5 */ + uint8_t oal_hi; + uint8_t units; + uint8_t pad2; + uint32_t threshold; +}; + +struct dpni_tx_confirmation_mode { + uint32_t pad; + uint8_t confirmation_mode; +}; + +#define DPNI_DEST_TYPE_SHIFT 0 +#define DPNI_DEST_TYPE_SIZE 4 +#define DPNI_CONG_UNITS_SHIFT 4 +#define DPNI_CONG_UNITS_SIZE 2 + +struct dpni_cmd_set_congestion_notification { + uint8_t qtype; + uint8_t tc; + uint8_t pad[6]; + uint32_t dest_id; + uint16_t notification_mode; + uint8_t dest_priority; + /* from LSB: dest_type: 4 units:2 */ + uint8_t type_units; + uint64_t message_iova; + uint64_t message_ctx; + uint32_t threshold_entry; + uint32_t threshold_exit; +}; + +struct dpni_cmd_get_congestion_notification { + uint8_t qtype; + uint8_t tc; +}; + +struct dpni_rsp_get_congestion_notification { + uint64_t pad; + uint32_t dest_id; + uint16_t notification_mode; + uint8_t dest_priority; + /* from LSB: dest_type: 4 units:2 */ + uint8_t type_units; + uint64_t message_iova; + uint64_t message_ctx; + uint32_t threshold_entry; + uint32_t threshold_exit; +}; + +#pragma pack(pop) #endif /* _FSL_DPNI_CMD_H */ diff --git a/drivers/net/dpaa2/mc/fsl_net.h b/drivers/net/dpaa2/mc/fsl_net.h index ef7e4da..dbec306 100644 --- a/drivers/net/dpaa2/mc/fsl_net.h +++ b/drivers/net/dpaa2/mc/fsl_net.h @@ -213,7 +213,7 @@ #define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 5) #define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 6) #define NH_FLD_SCTP_CHUNK_DATA_UNORDERED (NH_FLD_SCTP_CHUNK_DATA_TYPE << 7) -#define NH_FLD_SCTP_CHUNK_DATA_BEGINNING (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8) +#define NH_FLD_SCTP_CHUNK_DATA_BEGGINNING (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8) #define NH_FLD_SCTP_CHUNK_DATA_END (NH_FLD_SCTP_CHUNK_DATA_TYPE << 9) #define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \ ((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1)