From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0046.outbound.protection.outlook.com [104.47.36.46]) by dpdk.org (Postfix) with ESMTP id DA3659A06 for ; Fri, 26 May 2017 08:51:44 +0200 (CEST) Received: from BN6PR03CA0030.namprd03.prod.outlook.com (10.175.124.16) by BLUPR03MB166.namprd03.prod.outlook.com (10.255.212.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 26 May 2017 06:51:43 +0000 Received: from BL2FFO11FD044.protection.gbl (2a01:111:f400:7c09::155) by BN6PR03CA0030.outlook.office365.com (2603:10b6:404:10c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Fri, 26 May 2017 06:51:43 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD044.mail.protection.outlook.com (10.173.161.140) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Fri, 26 May 2017 06:51:43 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v4Q6pQMX014894; Thu, 25 May 2017 23:51:41 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 26 May 2017 12:21:13 +0530 Message-ID: <1495781485-2236-9-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495781485-2236-1-git-send-email-hemant.agrawal@nxp.com> References: <1495445969-29199-1-git-send-email-hemant.agrawal@nxp.com> <1495781485-2236-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131402551032695345; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39410400002)(39850400002)(39380400002)(39450400003)(39400400002)(39860400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(2906002)(104016004)(105606002)(498600001)(6666003)(15650500001)(36756003)(2950100002)(356003)(86362001)(38730400002)(8676002)(4326008)(6916009)(110136004)(2351001)(69596002)(81166006)(81156014)(8936002)(48376002)(50466002)(85426001)(50226002)(8656002)(54906002)(47776003)(77096006)(305945005)(53936002)(189998001)(5660300001)(5003940100001)(76176999)(50986999)(106466001)(33646002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB166; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD044; 1:aQgQ4EZbip7hMvMtCQPt6to6oWj0YSkAlYwnVk9LfFa6S4DJKTZXy9GYVAGH+6ycCLN+aBl6Rq9GXTJcclcg/5pYv8OajB09LpwjhRITmEf9MoL8qtsK7ETlQcpx6I7MFcKWKlxdWO148n878ZEjsnJjoNb7MEtNZI2amnp3jr+Yb+yaOpXRNOhaJ4tfL+Zy9OOat5Ng7rQRsujPYawfWXfvZKtOSIN5Jwiif22e4g4oHvIHB4OCpaI6Zs1dTiVroXv3PBPlLYiyiEy4DwLNgKQayJWwJfnB8WK87wudh1+2NfuBIuj8lZesVwqXxvPhV6g8l23hz88tSJxMJ/ct0Jy0KDTwIGOLHi7FwcC3Ye6zwrUfL7SUQTtyLsngtwg9E8tiFIfSPKSF2zxXtvrqMJPfLWkizBGDawEfBMeAXK6C+bMnfILtuaTj9T7ZXURHmzZSKzpSf3GgdSM7eyz1tsq+5x4dgeWvb1UNF3+TcjH5kjLbVeoXSqua0Ke1lETmLRIYl+Iu2+8mZm0Ul6S+c/90TN48+fqHVfMOXQwzf5LE2376yNMJ8Cn8JUS+/sLiSRFB4RmYE5YvvEXksyn+u3WLtTPwuilZ8urnfxRQcMoFhd+F9cJnJOaVKFBWbpAf2CbFHh9AaWqmY38oUuLtElGPx9z+pUBSTw3CFeEjLp1V9AU3xSn2VrvzjbFf8ytyDdFCRFgdIvyGIJJ4tY5wPQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLUPR03MB166: X-MS-Office365-Filtering-Correlation-Id: 1f364ded-d806-4636-876d-08d4a403ab54 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 3:KyRsiDx1N6X99+1Ncw0QGJPdAXcRj6vJj/35wOhgvZtnaPjlPaJvcXWjDCjAgnJsF7pTvd6HnstmvOuSY4O+0Ta6z/rfv77Dmo7+0XeypOQRlO6HoEF4ho7d1hj4LThUCBW8XRA5bzV1TRvDtLC9qbECntGD+/P7loc+2dBSFQYFQ+ygbFQM6fpBL+Sqd1j20iE1a/L+uxBtpT817qmvMkdqYjs5eeR8r81tIwXFyq67nzdGu7m4YJlH7cGRNSY/DChFBtzwSl0pzy1/0ClSaG1GETlx0MuM89wP9OaK7aZ575+Z/0N+d9/Qo5SK8tm3ZBedkgJUaTycOXMQlmWtFWyw3ZYGQ+JWVMG728N9IWsxF8/Zq674cGgCi2Ejmu84mBRspMZhELgWd3VAYFChouT5P90g7krw/6Htt1k3o77jgxyOapxFapuk0MT+Vz2b; 25:g/DKf/Sh33ddec0KZZye37zf9GfnzLMb1pTN7SCX8eUZLSIH/feNNOmVhPuyRXXiu7bprMBs3p27pMowXP1AMyQ7qcazfr6l9oLxc88Lxsgn8KOofSSB72wyKn4tyRrlOoLsfD4Y87Q/b3AprR8iGmCBNnVgetD0IJwlea4GZ1XpAYlrE0wbsMO2++hhP22+mfxmhJSK5om4VU2jZTgdOnnZ42nltWKaAysCm9zoKqm8+5Qz0IKJEp5sk7dr/Te7pYiblFX0veEkJ9I3s0hJX772dfT+nm45lsm8k8pXnMFfBFiu8f1XqHDcHcTMdHp4ZwNq0nDYgtgB+SiQ7mnSM9nsyK/BYfcd+xTTLqMkLU2Q9hdKwXNzMgOCc4F7dZigDktdjSXfhmCh/r1/kcica2EjVE0Upa5fy/HGNHReiEEpgJorViEfqlfdNxWYJ85VCMkZ8iygyaFVDgEIDMczEEhZsP7bAlOkowkHoL3AZew= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 31:GUdV2jupPnMCzjzvQo5nXij9hYWKepJzvWS5kcp9jB1rqEaGLSHzD+4dDRDdnQte1uxt4i90XI5NqdXCLgSDGF8TZDmCRE2n5zMpLLxfO8WhX3XYzWa5V2aYp7Q1QtR6GMehFYRlwrIUyx9wUKTUaMjhLoY14YinP1xYbQdN3QxtskmU34kRCRZ7XOzSMTJ6qFi5iWEsm4+Y9+s+Vuug3jbeONne6EaiM/bSUT5wvaBQQcC/V2I2NTj0BHZ1KsJAMEiIgGu9lCyUxkHCzLlhQA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13018025)(13016025)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123559100)(20161123556025)(20161123561025)(20161123563025); SRVR:BLUPR03MB166; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 4:SANE2UJ7mTFOLd0InfkuGXNFMlYcu0EUtO/VBXRlmS1wwHnQtjlAqiUn3bh1UNulr20DRgC+2QzVu4OipsSgBh9JQZE19UUok8Uun4wGQpoJ8gFjYPUIJMTCkuJ7Y7Z8yyY49ePgRWCushA9I/onVxN5HO5XtPAcSDX/gAW7pdrJaabxW3rvfHutMbVlhmPmURNjKk0lKsrhu4w2sixphKvxsCvwrzPK752sb0J5WOtk7lT61D1r0JaNR+gRdNaVoQa9vkVMvGB8M+wJaXU6rE6us+fF2WHnj2N9pzzEAtyZWkHlsJWuSivteuEtYdMmT8HsIOZVpp+5JfcjTPsLHzoa74vhGwt/oIpcr+s20i1wERjo4sVknzZCf+Em1zUWGgYsxTowFQdjAiyboOO4jwhgAKzZ+D+5SPJXxe0wnho0YGW9kd9tWNiZ3Mh0ZJgGFSdPjQdCAWGegRkqV8944E9teuV/0vdogIhqWg/K1jgosH0VOUtqnUx4c1Lo9S1ZEPLd+lonhSbTEsBf7N24Cfw1BvHTKyMNku2DiSVbuQaFm/K/8+B9U7OaS98T6q8zjoVgO/UFvnYfnbqlp//HMlc9qQQF9IhEC1QbqmATFYfM7b72RYrvXuSkjRx1zfjzun8kTBE7rxLyRHd+ZcROPCriaI/7e/FSWpKB05730BaMW60e7Uy/B5zA0158sevtBcpcnnxl3+Io2BVahfx1umYNV68XDeng8SpTqe9C37ci7hKRrg4gWQzrS/RLgRtq8kOytrEgkxcdLmW4D3e5bFbKOzGrxbbzBIIYpbwJdB2F0XDUhPpMCz3Vdku9Gg3c/iTgNaI0jxH3sYkHSMFWJ5bjrJGduWWxWkQETsjN4P4bQ16250mGw2OullBtsGqaApW9WkCHBbRzImGBg5mnYgQr0sKVp4wu1uzfd1sXxO3r3bGq4PI7VcRVDBgusOjR X-Forefront-PRVS: 031996B7EF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB166; 23:hGLW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6hDi8UthhXkysblRJfJ1YZqECMQF4rs6iSwulMYQ==; 5:dwNjNSQ4TfvE7Zi5HHKxzHsiYiOHVooqwWD6xViVihr/cAJyWRh1nZezNN4a9uRjX+94cVTLnSejZPSrxpHsRutfBcMtw8VELmTPdEeCT7vTpuVm9kHtDUTaczHKD/vVB6YQOt4wj5ky6mH+wXCbNq1WGRjEmDTwbl92CLux+Hfqom6MLQYipDIERGxQxS0Y; 24:rv0nC4SkPbxKk/MMLIGK1/n0YImN3n406IevQNUAF1DNZLuv/+xdEDtpTS1aWeca3DxoczLF8E9wwwFjuQlb3RWPy/yKPP63dDoP3Nsih+4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 7:GeEFfKsP6LOMXpbHgpKE1wig+5FxyKi7UpjddUzuOc/TJtt4LzqT0RpYzdhND8WaFW2rFIhQqu5dQIHC/CdvoOEeJcFsM3MIXjjAjrsGVTVjw5qs2LZsRVu7j5ftMeGuRVy5VwOZ5p1DPbeTfdSmrAY5uP+OsOGNSBU5kGcOZj0Hf6N6vJ2A2c3L1vcYWEHCHmgtXtvuaQOXGKzGD1Jw7IQmZdiaNKVQqiJ70SqXN3Gz6HGlh8dn/MdxTjQf2CmtR2bZrUVO7o4HJo+pWPclktfNAVclAhS3Y+Co4MToMmwXdhRibd9MvCdpkoBczRd/+GzBdIjPPpdGYym4LMVwyA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2017 06:51:43.0355 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB166 Subject: [dpdk-dev] [PATCH v4 08/20] net/dpaa2: add support for congestion notification 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: , X-List-Received-Date: Fri, 26 May 2017 06:51:46 -0000 In case of HW egress FQ is congested, skip further transmission of frames. Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 5 +- drivers/net/dpaa2/dpaa2_ethdev.c | 62 ++++++++++++++- drivers/net/dpaa2/dpaa2_ethdev.h | 14 ++++ drivers/net/dpaa2/dpaa2_rxtx.c | 4 + drivers/net/dpaa2/mc/dpni.c | 48 ++++++++++++ drivers/net/dpaa2/mc/fsl_dpni.h | 130 +++++++++++++++++++++++++++++++- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 36 +++++++++ 7 files changed, 291 insertions(+), 8 deletions(-) diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index e04edc6..b83ddd9 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -123,7 +123,10 @@ struct dpaa2_queue { uint64_t rx_pkts; uint64_t tx_pkts; uint64_t err_pkts; - struct queue_storage_info_t *q_storage; + union { + struct queue_storage_info_t *q_storage; + struct qbman_result *cscn; + }; }; struct swp_active_dqs { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 797e71d..80f1cd7 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -177,8 +177,13 @@ for (i = 0; i < priv->nb_tx_queues; i++) { mc_q->dev = dev; - mc_q->flow_id = DPNI_NEW_FLOW_ID; + mc_q->flow_id = 0xffff; priv->tx_vq[i] = mc_q++; + dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; + dpaa2_q->cscn = rte_malloc(NULL, + sizeof(struct qbman_result), 16); + if (!dpaa2_q->cscn) + goto fail_tx; } vq_id = 0; @@ -191,6 +196,14 @@ } return 0; +fail_tx: + i -= 1; + while (i >= 0) { + dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i]; + rte_free(dpaa2_q->cscn); + priv->tx_vq[i--] = NULL; + } + i = priv->nb_rx_queues; fail: i -= 1; mc_q = priv->rx_vq[0]; @@ -320,7 +333,7 @@ PMD_INIT_FUNC_TRACE(); /* Return if queue already configured */ - if (dpaa2_q->flow_id != DPNI_NEW_FLOW_ID) + if (dpaa2_q->flow_id != 0xffff) return 0; memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue)); @@ -358,6 +371,36 @@ } dpaa2_q->tc_index = tc_id; + if (priv->flags & DPAA2_TX_CGR_SUPPORT) { + struct dpni_congestion_notification_cfg cong_notif_cfg; + + cong_notif_cfg.units = DPNI_CONGESTION_UNIT_BYTES; + /* Notify about congestion when the queue size is 32 KB */ + cong_notif_cfg.threshold_entry = CONG_ENTER_TX_THRESHOLD; + /* Notify that the queue is not congested when the data in + * the queue is below this thershold. + */ + cong_notif_cfg.threshold_exit = CONG_EXIT_TX_THRESHOLD; + cong_notif_cfg.message_ctx = 0; + cong_notif_cfg.message_iova = (uint64_t)dpaa2_q->cscn; + cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE; + cong_notif_cfg.notification_mode = + DPNI_CONG_OPT_WRITE_MEM_ON_ENTER | + DPNI_CONG_OPT_WRITE_MEM_ON_EXIT | + DPNI_CONG_OPT_COHERENT_WRITE; + + ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW, + priv->token, + DPNI_QUEUE_TX, + tc_id, + &cong_notif_cfg); + if (ret) { + PMD_INIT_LOG(ERR, + "Error in setting tx congestion notification: = %d", + -ret); + return -ret; + } + } dev->data->tx_queues[tx_queue_id] = dpaa2_q; return 0; } @@ -513,12 +556,22 @@ static void dpaa2_dev_close(struct rte_eth_dev *dev) { + struct rte_eth_dev_data *data = dev->data; struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; - int ret; + int i, ret; + struct dpaa2_queue *dpaa2_q; PMD_INIT_FUNC_TRACE(); + for (i = 0; i < data->nb_tx_queues; i++) { + dpaa2_q = (struct dpaa2_queue *)data->tx_queues[i]; + if (!dpaa2_q->cscn) { + rte_free(dpaa2_q->cscn); + dpaa2_q->cscn = NULL; + } + } + /* Clean the device first */ ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token); if (ret) { @@ -832,6 +885,9 @@ void dpaa2_dev_stats_reset(struct rte_eth_dev *dev) priv->max_vlan_filters = attr.vlan_filter_entries; priv->flags = 0; + priv->flags |= DPAA2_TX_CGR_SUPPORT; + PMD_INIT_LOG(INFO, "Enable the tx congestion control support"); + /* Allocate memory for hardware structure for queues */ ret = dpaa2_alloc_rx_tx_queues(eth_dev); if (ret) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index 7fa7e7d..e7728ba 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -47,9 +47,23 @@ /*default tc to be used for ,congestion, distribution etc configuration. */ #define DPAA2_DEF_TC 0 +/* Threshold for a queue to *Enter* Congestion state. + * It is set to 32KB + */ +#define CONG_ENTER_TX_THRESHOLD (32 * 1024) + +/* Threshold for a queue to *Exit* Congestion state. + */ +#define CONG_EXIT_TX_THRESHOLD (24 * 1024) + /* Size of the input SMMU mapped memory required by MC */ #define DIST_PARAM_IOVA_SIZE 256 +/* Enable TX Congestion control support + * default is disable + */ +#define DPAA2_TX_CGR_SUPPORT 0x01 + struct dpaa2_dev_priv { void *hw; int32_t hw_id; diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c index 9b7539a..0670ae3 100644 --- a/drivers/net/dpaa2/dpaa2_rxtx.c +++ b/drivers/net/dpaa2/dpaa2_rxtx.c @@ -406,6 +406,10 @@ static inline int __attribute__((hot)) /*Clear the unused FD fields before sending*/ while (nb_pkts) { + /*Check if the queue is congested*/ + if (qbman_result_SCN_state_in_mem(dpaa2_q->cscn)) + goto skip_tx; + frames_to_send = (nb_pkts >> 3) ? MAX_TX_RING_SLOTS : nb_pkts; for (loop = 0; loop < frames_to_send; loop++) { diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c index 3330614..3d1f81b 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -626,6 +626,54 @@ int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, 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, + const struct dpni_congestion_notification_cfg *cfg) +{ + 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); + + /* 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, + enum dpni_queue_type qtype, + uint8_t tc_id, + struct dpni_congestion_notification_cfg *cfg) +{ + 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); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + DPNI_RSP_GET_CONGESTION_NOTIFICATION(cmd, cfg); + + return 0; +} + int dpni_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t *major_ver, diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h index ef14f85..2b6515a 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni.h +++ b/drivers/net/dpaa2/mc/fsl_dpni.h @@ -72,10 +72,7 @@ * All flows within traffic class considered; see dpni_set_queue() */ #define DPNI_ALL_TC_FLOWS (uint16_t)(-1) -/** - * Generate new flow ID; see dpni_set_queue() - */ -#define DPNI_NEW_FLOW_ID (uint16_t)(-1) + /** * Tx traffic is always released to a buffer pool on transmit, there are no * resources allocated to have the frames confirmed back to the source after @@ -961,6 +958,16 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io, 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 + * @DPNI_CONGESTION_UNIT_FRAMES: frames units + */ +enum dpni_congestion_unit { + DPNI_CONGESTION_UNIT_BYTES = 0, + DPNI_CONGESTION_UNIT_FRAMES +}; + /** * enum dpni_dest - DPNI destination types @@ -981,6 +988,119 @@ enum dpni_dest { DPNI_DEST_DPCON = 2 }; +/** + * struct dpni_dest_cfg - Structure representing DPNI destination parameters + * @dest_type: Destination type + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type + * @priority: Priority selection within the DPIO or DPCON channel; valid values + * are 0-1 or 0-7, depending on the number of priorities in that + * channel; not relevant for 'DPNI_DEST_NONE' option + */ +struct dpni_dest_cfg { + enum dpni_dest dest_type; + int dest_id; + uint8_t priority; +}; + +/* DPNI congestion options */ + +/** + * CSCN message is written to message_iova once entering a + * congestion state (see 'threshold_entry') + */ +#define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001 +/** + * CSCN message is written to message_iova once exiting a + * congestion state (see 'threshold_exit') + */ +#define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002 +/** + * CSCN write will attempt to allocate into a cache (coherent write); + * valid only if 'DPNI_CONG_OPT_WRITE_MEM_' is selected + */ +#define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004 +/** + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to + * DPIO/DPCON's WQ channel once entering a congestion state + * (see 'threshold_entry') + */ +#define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008 +/** + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to + * DPIO/DPCON's WQ channel once exiting a congestion state + * (see 'threshold_exit') + */ +#define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010 +/** + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the + * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled) + */ +#define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020 + +/** + * struct dpni_congestion_notification_cfg - congestion notification + * configuration + * @units: units type + * @threshold_entry: above this threshold we enter a congestion state. + * set it to '0' to disable it + * @threshold_exit: below this threshold we exit the congestion state. + * @message_ctx: The context that will be part of the CSCN message + * @message_iova: I/O virtual address (must be in DMA-able memory), + * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_' is + * contained in 'options' + * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel + * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_' values + */ + +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; +}; + +/** + * 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); + +/** + * 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, + struct dpni_congestion_notification_cfg *cfg); + /** * struct dpni_queue - Queue structure @@ -1077,6 +1197,8 @@ enum dpni_confirmation_mode { * 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. */ diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h index bb92ea8..383649e 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h @@ -82,6 +82,8 @@ #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)) @@ -331,4 +333,38 @@ #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) + #endif /* _FSL_DPNI_CMD_H */ -- 1.9.1