From patchwork Mon May 15 12:37:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 24304 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B845E5A6A; Mon, 15 May 2017 14:38:27 +0200 (CEST) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0050.outbound.protection.outlook.com [104.47.42.50]) by dpdk.org (Postfix) with ESMTP id BFAE13252 for ; Mon, 15 May 2017 14:38:19 +0200 (CEST) Received: from MWHPR03CA0012.namprd03.prod.outlook.com (10.175.133.150) by BLUPR03MB167.namprd03.prod.outlook.com (10.255.212.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Mon, 15 May 2017 12:38:17 +0000 Received: from BN1AFFO11FD029.protection.gbl (2a01:111:f400:7c10::142) by MWHPR03CA0012.outlook.office365.com (2603:10b6:300:117::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11 via Frontend Transport; Mon, 15 May 2017 12:38:17 +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 BN1AFFO11FD029.mail.protection.outlook.com (10.58.52.184) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Mon, 15 May 2017 12:38:17 +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 v4FCbxNv003970; Mon, 15 May 2017 05:38:15 -0700 From: Hemant Agrawal To: CC: , Date: Mon, 15 May 2017 18:07:32 +0530 Message-ID: <1494851864-26029-10-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494851864-26029-1-git-send-email-hemant.agrawal@nxp.com> References: <1492607395-5922-1-git-send-email-hemant.agrawal@nxp.com> <1494851864-26029-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131393254971972595; (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)(39450400003)(39840400002)(39850400002)(39380400002)(39400400002)(39410400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(50466002)(48376002)(6666003)(15650500001)(305945005)(356003)(105606002)(68736007)(5660300001)(2351001)(85426001)(81166006)(8676002)(8936002)(50226002)(106466001)(36756003)(47776003)(6916009)(2950100002)(498600001)(50986999)(5003940100001)(2906002)(54906002)(86362001)(8656002)(110136004)(104016004)(77096006)(38730400002)(76176999)(53936002)(33646002)(189998001)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB167; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD029; 1:mvfLGkA3SDab9+OQZDNOYExS7C9rsnr6glCNfQSnaIgXfcLbJjzcQrdFdqY2tYadKDLncwFuy2CTjpq6vnLeuIP/fVAAZF4eYHTcLzbjLLu4rf6q2P5W0QNZjXBvfaVVON0yJ/BXKwqeZ7D1BS3mp+lNIeLuK2jujO/P01CnmU0j7ZXW5OHadPQucqbeVZcJ3kuA9u4IYjS6j49mBLi6Og46tcckIHVOzF6fRWuuHuh7RFhklK/0oqbuVaNoIl9Ii8IrAfMhsDKRQT9nFPL1zE+Riu1jkaDxxyET1JD8tlF40yoHFvrdVPweTw92GzPg/IxTrsvvckZN4pe/KcH8rGgfmH8Q9WG4q9SuyW8MoMdXoRXxYz/T3UVw4Gi8iWi0cJyO26fr0HJklt+vT/kiYZTKgeYehbDy2+XbjGXoG9C7sedOaWM7HW2nuzXUoQVJQakdr4fWnNXKcr+CQg+aKxPdwRLAE07E3355ajLRedyv1LCX4DRA1NdRNyjUCKLnyStpi1lzxZOCkao8voHyASJMlaSad9NQI5uVzlPXkrqb4Cqna7lKArKDQgb3lDQtnDyvfFSB/kJYYlxwkao/sa+y3ZVz8zIxnX0OEydZK5KDUHtN68PjkVZ3tYrMUBtVRB0l/anZZ/jLZjwIusOOVVugSGzTtWNgmFAsnxAYfUt0hTOdr5wSbymrnJ5j2fXcv3ninUt3W3etN+tYmc/I3RoQLuZXSAXdbfLZmcJnycC1TodpbcIklVRSKDmwre+zPlxLAv5/yCLcJwzlXo2BEQ== MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4486cd1e-9a46-4b37-3a92-08d49b8f42f1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BLUPR03MB167; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB167; 3:VqoOQ7tqqjsGgPh818YJ9idllRUryugkx3geKKx/vEHM2k1YIedrnknWY2SvrlVQjogZpqPGySLZE6AjJtAzZy4fI9HxQ24EAu2PYpB43UjfxQhvzZ5PMfu30XtCrWgA44QENn9jvuwU5UYTyMzbOiFMnGliaCPuHTwCRO5PeLybJZERIUhHCk/UDWuBlTyx0TV9YoNQRTC++ATSoAkkT2dtEO7ASRxapIJ4ZkGgrRuJgTYbU8VXENcqPdM76thD3DeYaF9GIjljVkzfbHzb0EiFtNe6HIpWDEDUuaSGRv4GXzKfUySZWf86ARelx3gkZTG89yjNdFL5UZRqqZkTJ9j+D+wJI9jGruET7bgS4KGfpjQN87lU1dBnoClcosUWyBsbmJoYEGyL8KqhHJ6GuCjSv5A7qfUegZ+VMr7Eo+vnU10On0cuAyVd6GV/mq37; 25:ghamkbN/VokXTFpKAJ1toX1GK3vMkOMoUstVTDn4UgpHUMJFYRwbEFzNexzcM7BTjXTbgcVT6GODNGuYqYQqkvveP1zJOItv0iOznZqHmM49Fk9iiNMzQQ9mcsZvZW09HndpWvdjNT8fZQD9SwK+vGQgrm342Vr07+yfsP7RzOefctZ9g0BuEQ1oLCGmn+cUDV+9mvzRI+5lYpGbgiPhCmScogkEqhbNj57BmUz6olOuA/sVXIdTVYJFxbKzpDKbvHS1IBJrZgJTmfUUjSOZ0WJpfyIViybUV6XocIy+nnFvUqK9JEVTPcLZXY3l75XKbbpU5zg4bgGKM7KKHkAuQbMPEOT2sDwVnjlP5Ps7KFh1Svnf8yWEcG9f2nzr0dEMIeW/TmaqXXOSdi3I7SERtJ5fK65vP+lxZ+wPobsgpfgIdevRkKXaHU747IZR0lkis5pXl94hQYWZI6V+UZCMXQ== X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB167; 31:IX/AWihCU92DXbYTTxiKGUHa9ldbwHmAPUz94VXDGKqQkwTswUCA0qxFrxT8bfcpy2D+Iw/pRoapP3gejIMm3a1yGhyIOJgFyVKH5gWKAgKt0zutBuHRuK0KVyj4c/H91uYuSin5MWrHzvFa8knM0zlavDHpMw5APb6NfYsF0qQD7kvdeAJXO6DV44mgEf3KtQvxIYQ4FnfVJW6TIJCWOJwA0JT9hbbzFA3qXo0D04rTpfY9SMm2CUc7UQF0l+5JrgUjofaKMGAHXLwP6x70LQ== 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)(13023025)(13024025)(13018025)(13015025)(5005006)(8121501046)(13017025)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123556025)(20161123559100)(20161123563025); SRVR:BLUPR03MB167; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB167; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB167; 4:Ro7n3uwapop0TBZSIcpD8p7MtSF1Xlu49i2DaaipgeS?= N3+KmepfYNIcBS4Hd+2V5hGl7yHrj2TkEHzE3sV87LMJKPsqaq9UzemAoJe5TYI/JQCvF1fm1eQig/UOs6D+r/lPSDPPYzYAxM2cEzQ1muktpyTV3EXW8XWg6NXOBqa3UYuDzi2b4lxkVVkVOaoY/gmhWFNWstrV7fpItJCVGWzNmZ3YUq/DPVnhSt53QpUqfSvjL8t4zcU4RHdti5lK7zZyArdhubj/5HE6b+GQLjKEMP10Vk8CDB/BuvI5PB4VqeGpbsY+YQb/yQB7z1pKBr9eNHwqdL9dbf/goYPK2/BkTjwu8IoP+aZuqyEA4BjuunJ+1wRBOUzMdVglnlo1OLLfyCpfyFDTbA9uHKiFt9dwYrgoNptuzkUtxNaHuq8rFVDhxRUK5+2+oPY061EyQQthj/ICF807agmI95dL704umkYiye/Lyhi11acXq3qHmTNNO+Uuo59rm/0HTHSMIJRKyqx/QFl8J3xJ5UNMPeYvXatfvYCgZBzFkM6oysPaZL9aoNS7n+wUzWDsYh9HYDZEZ9hRehq0rCBqPjLy0iX6PBvnXjTQH2WoUsxUY3F6Emi87YFuZcyDchxbPcTl7ReqzyWtg5wpwYCX0uo5NqcRUJHk5FjTzTnfgdEKDXpEJFstpRripEGHBpJpafNZkUZu/VsXHNZLdgkb2mxPMXwvZhpTlgN1F7It8YubuPG3cxIGVfj14mg8p7bEG3yf+/3G65NG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OnBYDq21Uw8cqfSjrPrA==; 5:n1RmrSVBQjYqt9haUOlTOKOVSxpxw8v4CPTsA68QzKwURU7sz0fuOYIWHwh04nJuUu6Pr26Qyousr0NDj0Ayy0vAbHFJRcKz5RxCEISpxoxEDyMnmXQ4LsAha87EOBsoiJCUjae99EEi8OcxHFuC7Mj9QzM6LXl97PRJljsuKZJCTsiqErexIVXnV+QAgOj8; 24:YTJF1X3NrGGDBIaSDfnglS8yKABj3n+UKIEc+Cu++fctvUoYibeMiDseZcXwEMr4jEJJA38uu3oC9MlfmS3D66LbO3iuFo72FOGsURebsX0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB167; 7:ZmXIcS87lT5kagvXH8XUklYfbfZvlEU8gSxMPBXH7lHbbsyZYd8R5iX1CZUud6ry6IoS3lTSo/24issCDx9s4LCYBTFUYq5kiNy7iwlnovqvRcF5gZr4KpGJ5I9B4fOT4kAeXlbyLk+gJQpArOSWuL1dVB2u0Rx0U866/BxPUYpIcg+WckfM1cPjnIO7CI2l31ejOVtA3GHPifbr103nC8QU02lu/h/3J2ilyIiHo6g8mlUZmDGht/9GPUiczGWyGiVOw4SjcBYjczEus7okRG0j5L3XO+e0oroblAGSWRahuwk+FbqdeWx4QGFXxgvBvMp2C8iS92IaV+qChnbMBQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2017 12:38:17.0100 (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: BLUPR03MB167 Subject: [dpdk-dev] [PATCH v2 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 | 47 ++++++++++++ drivers/net/dpaa2/mc/fsl_dpni.h | 129 +++++++++++++++++++++++++++++++- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 36 +++++++++ 7 files changed, 289 insertions(+), 8 deletions(-) diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index 09e9398..6549b84 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..145336d 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -626,6 +626,53 @@ 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..10dccc7 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,118 @@ 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 +1196,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 */