From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DDABAA04FD; Fri, 7 Oct 2022 19:48:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E78842C2A; Fri, 7 Oct 2022 19:45:19 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by mails.dpdk.org (Postfix) with ESMTP id A190A42BFB for ; Fri, 7 Oct 2022 19:45:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SAvN+cbzsjQH5E8xA2leSdFgNohXR1rbCOQt7JpoaNZDNm8t6xublK80lWNKu1i3iKr3x4K5ZI94Gxbcql3XAH2ftFS9gKs+b9RzwfaIclYJDg7Touhn6xID8EIMu3dnXJbaIdn7KLg0QBico4wkin6RWQretxR5Cd91lHynqJWDiVVd2ngEcH2CZ1S8EB2y/yhDGc9UPh+JliNA9p7LIsaz0ge/WKJsljpXGGdos/K6ZRJTBK7A5FeoNZYJ61N4avJHqXsvcInir6Tx1swQxTtpJLgCfiONwIQvZflS1SZPz7Gn90ZxhZI8zEcFswcP31YSKfb7YGC/fSJxs5mTPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XiJ6/gwJfBLlCrv9Rad56GMl0fjjaOZS05ubpFq0/NU=; b=QLQTEIZKansVgBLq4YYJUzvPRG7Zl/TyM/melFR47lQQXCVB3Kc81YR0ywh77IoU6AN0ku48Dd9T+/DEAELgo74GaATPc1IZa6TG3KlneRGRfnxFWTW9VebJIhdmdkVF9CLGIc/0Y8RT5EH/rQjH/OYO0UUjyFXh6cu4psXD9E6FZmY+KMmNou7Pwqkv7EQeU+9Txe7mLsaENto+ikd0lZT2vymhdnSTGygW5gNOzCrdVpJ6ZcldvzS1C7fn94mt5Fn0k4Gg7v2dsUB+/7YT+MISWpHB352neITC9kJ8mSRJ+Ntx1pxmHwna3HapI3d6yojzzxuxlKgtj2NZLggzBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XiJ6/gwJfBLlCrv9Rad56GMl0fjjaOZS05ubpFq0/NU=; b=aO57mQVB/T0MNNC0Xl+b2etm+brI8sb09Y8D7x5FSPx7NFtMdD3xO8VMhXXX8/DqcIN8y9hLOt4c0dfL4TVnYRMjjBAMOnr4hZYm066MokY8vkylkA3FiIpQqPlQzn7oS6sWBzXJjZWJE9zTUPxrNxRWM2sak3OXVIQRNIOqG3o= Received: from MW4PR03CA0351.namprd03.prod.outlook.com (2603:10b6:303:dc::26) by MW4PR12MB6874.namprd12.prod.outlook.com (2603:10b6:303:20b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 7 Oct 2022 17:45:12 +0000 Received: from CO1NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::f1) by MW4PR03CA0351.outlook.office365.com (2603:10b6:303:dc::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Fri, 7 Oct 2022 17:45:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT068.mail.protection.outlook.com (10.13.175.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 17:45:12 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 7 Oct 2022 12:45:08 -0500 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH 35/35] net/ionic: add watchdogs to protect each queue type Date: Fri, 7 Oct 2022 10:43:36 -0700 Message-ID: <20221007174336.54354-36-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221007174336.54354-1-andrew.boyer@amd.com> References: <20221007174336.54354-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT068:EE_|MW4PR12MB6874:EE_ X-MS-Office365-Filtering-Correlation-Id: cb2f2fad-3694-4e2a-4432-08daa88baf75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HPwB29EViBhoaOlOVCyRdtma4LS6zKDpzVm4/88E9g0GSmxvsSGC+kl87cAEMLCFIzSm7sJ9iCAc/F2R5h0ESzV00Ja8/SMExi+blPMsk5XXp5P+MS5et0NlPh/Sni4Om8e/SVqKxd13ZJCeNu2bufBkMiXzZwe3RHgtVl173RwbKYQTH/3IBeOzzjHvpbyCfdTXnc79JGgBQ8nei5rxFhmtWqlH3UG149trVLehPjCv7nMAKA/Z9jM+ehpo7XGN7ahAWO7wQug5m0WoH0r9InEHWgUa/gssBe4jMOijvwzFHAfC8FXYWzYQXE0u5bt7BiaYC3lOpmOSRfMPt9l0HW6q+S1ueZwdtbumDTdX3YB/WS5+LWStB7BQpM9JA0tJvZkHqWLdM+XRoEOlYscE5QxaWtJ91N8UJaJFpPcNtyh+9P7BDEPzuCrx4neGjz5kTkfkgxNEMOwII1VnbCmRMZeVXudjck2MN/3ZnDKcQhRgu6L909INWYAHSwjktNSPaujuvwOBkAdCT6TmJkUvJAmnhJC9hLpiGyZOgl6PY6lVgfMjltl8YVXaYU6J5sOCE9w9WOK7NU8VDzQrirqeWfk/hF5tGyqVHh/XB99lnZqQD+7YrXuiZtIadA5ERu9EPePPju1YB8A06kdf6bS9u/uto30g1GskM/F86UtBkFmNmbNsl5pnQ2Bvvf90JueHdvEnLrlDWtN3bO39tf9nDgOzfAezy9lblyADpVh2CwsKpj1dr9F/FyxmdE46gmy18ZMkDtmaMEctfrwz8h8qyi3qC+gngmy6iqQFkRA4pFTjqY+nbybF8Y21E3jVS+nm X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199015)(40470700004)(46966006)(36840700001)(8936002)(36860700001)(40480700001)(8676002)(16526019)(6666004)(2616005)(44832011)(336012)(186003)(426003)(1076003)(26005)(40460700003)(36756003)(5660300002)(2906002)(41300700001)(70586007)(83380400001)(47076005)(4326008)(356005)(81166007)(70206006)(6916009)(82310400005)(86362001)(82740400003)(316002)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 17:45:12.2246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb2f2fad-3694-4e2a-4432-08daa88baf75 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6874 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Ring the doorbell again for the following scenarios: * No receives posted but Rx queue not empty after deadline * No transmits posted but Tx work still pending after deadline * Admin queue work still pending after deadline This will help the queues recover in the extremely rare case that a doorbell is missed by the FW. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_dev.h | 4 +++ drivers/net/ionic/ionic_lif.h | 3 ++ drivers/net/ionic/ionic_main.c | 22 ++++++++++++ drivers/net/ionic/ionic_rxtx.c | 1 + drivers/net/ionic/ionic_rxtx_sg.c | 50 ++++++++++++++++++++++++++- drivers/net/ionic/ionic_rxtx_simple.c | 50 ++++++++++++++++++++++++++- 6 files changed, 128 insertions(+), 2 deletions(-) diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h index 4d07d9206e..d5d56b778d 100644 --- a/drivers/net/ionic/ionic_dev.h +++ b/drivers/net/ionic/ionic_dev.h @@ -26,6 +26,10 @@ #define IONIC_DEVCMD_CHECK_PERIOD_US 10 /* devcmd status chk period */ #define IONIC_DEVCMD_RETRY_WAIT_US 20000 +#define IONIC_Q_WDOG_MS 10 /* 10ms */ +#define IONIC_Q_WDOG_MAX_MS 5000 /* 5s */ +#define IONIC_ADMINQ_WDOG_MS 500 /* 500ms */ + #define IONIC_ALIGN 4096 struct ionic_adapter; diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h index 2aa9f774ff..1f4686f340 100644 --- a/drivers/net/ionic/ionic_lif.h +++ b/drivers/net/ionic/ionic_lif.h @@ -85,6 +85,8 @@ struct ionic_rx_qcq { struct rte_mempool *mb_pool; uint64_t rearm_data; uint64_t rearm_seg_data; + uint64_t last_wdog_cycles; + uint64_t wdog_ms; uint16_t frame_size; /* Based on configured MTU */ uint16_t hdr_seg_size; /* Length of first segment of RX chain */ uint16_t seg_size; /* Length of all subsequent segments */ @@ -103,6 +105,7 @@ struct ionic_tx_qcq { struct ionic_qcq qcq; /* cacheline2 */ + uint64_t last_wdog_cycles; uint16_t num_segs_fw; /* # segs supported by current FW */ uint16_t free_thresh; uint16_t flags; diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c index 3d8157dac3..8330d8dfc1 100644 --- a/drivers/net/ionic/ionic_main.c +++ b/drivers/net/ionic/ionic_main.c @@ -230,10 +230,16 @@ static int ionic_adminq_wait_for_completion(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, unsigned long max_wait) { + struct ionic_queue *q = &lif->adminqcq->qcq.q; unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US; + unsigned long step_deadline; unsigned long max_wait_usec = max_wait * 1000000L; unsigned long elapsed_usec = 0; int budget = 8; + uint16_t idx; + void **info; + + step_deadline = IONIC_ADMINQ_WDOG_MS * 1000 / step_usec; while (ctx->pending_work && elapsed_usec < max_wait_usec) { /* @@ -245,10 +251,26 @@ ionic_adminq_wait_for_completion(struct ionic_lif *lif, ionic_qcq_service(&lif->adminqcq->qcq, budget, ionic_adminq_service, NULL); + /* + * Ring the doorbell again if work is pending after deadline. + */ + if (ctx->pending_work && !step_deadline) { + step_deadline = IONIC_ADMINQ_WDOG_MS * + 1000 / step_usec; + + rte_spinlock_lock(&lif->adminq_lock); + idx = Q_NEXT_TO_POST(q, -1); + info = IONIC_INFO_PTR(q, idx); + if (info[0] == ctx) + ionic_q_flush(q); + rte_spinlock_unlock(&lif->adminq_lock); + } + rte_spinlock_unlock(&lif->adminq_service_lock); rte_delay_us_block(step_usec); elapsed_usec += step_usec; + step_deadline--; } return (!ctx->pending_work); diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c index 64733da535..967cc7dc9a 100644 --- a/drivers/net/ionic/ionic_rxtx.c +++ b/drivers/net/ionic/ionic_rxtx.c @@ -551,6 +551,7 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, } rxq->mb_pool = mp; + rxq->wdog_ms = IONIC_Q_WDOG_MS; /* * Note: the interface does not currently support diff --git a/drivers/net/ionic/ionic_rxtx_sg.c b/drivers/net/ionic/ionic_rxtx_sg.c index bdca3fa4b4..73e3114bea 100644 --- a/drivers/net/ionic/ionic_rxtx_sg.c +++ b/drivers/net/ionic/ionic_rxtx_sg.c @@ -167,6 +167,7 @@ ionic_xmit_pkts_sg(void *tx_queue, struct rte_mbuf **tx_pkts, struct rte_mbuf *mbuf; uint32_t bytes_tx = 0; uint16_t nb_avail, nb_tx = 0; + uint64_t then, now, hz, delta; int err; struct ionic_txq_desc *desc_base = q->base; @@ -220,8 +221,26 @@ ionic_xmit_pkts_sg(void *tx_queue, struct rte_mbuf **tx_pkts, rte_wmb(); ionic_q_flush(q); + txq->last_wdog_cycles = rte_get_timer_cycles(); + stats->packets += nb_tx; stats->bytes += bytes_tx; + } else { + /* + * Ring the doorbell again if no work could be posted and work + * is still pending after the deadline. + */ + if (q->head_idx != q->tail_idx) { + then = txq->last_wdog_cycles; + now = rte_get_timer_cycles(); + hz = rte_get_timer_hz(); + delta = (now - then) * 1000; + + if (delta >= hz * IONIC_Q_WDOG_MS) { + ionic_q_flush(q); + txq->last_wdog_cycles = now; + } + } } return nb_tx; @@ -421,6 +440,7 @@ ionic_rxq_service_sg(struct ionic_rx_qcq *rxq, uint32_t work_to_do, struct ionic_rxq_desc *q_desc_base = q->base; struct ionic_rxq_comp *cq_desc, *cq_desc_base = cq->base; uint32_t work_done = 0; + uint64_t then, now, hz, delta; cq_desc = &cq_desc_base[cq->tail_idx]; @@ -453,8 +473,36 @@ ionic_rxq_service_sg(struct ionic_rx_qcq *rxq, uint32_t work_to_do, } /* Update the queue indices and ring the doorbell */ - if (work_done) + if (work_done) { ionic_q_flush(q); + rxq->last_wdog_cycles = rte_get_timer_cycles(); + rxq->wdog_ms = IONIC_Q_WDOG_MS; + } else { + /* + * Ring the doorbell again if no recvs were posted and the + * recv queue is not empty after the deadline. + * + * Exponentially back off the deadline to avoid excessive + * doorbells when the recv queue is idle. + */ + if (q->head_idx != q->tail_idx) { + then = rxq->last_wdog_cycles; + now = rte_get_timer_cycles(); + hz = rte_get_timer_hz(); + delta = (now - then) * 1000; + + if (delta >= hz * rxq->wdog_ms) { + ionic_q_flush(q); + rxq->last_wdog_cycles = now; + + delta = 2 * rxq->wdog_ms; + if (delta > IONIC_Q_WDOG_MAX_MS) + delta = IONIC_Q_WDOG_MAX_MS; + + rxq->wdog_ms = delta; + } + } + } } uint16_t diff --git a/drivers/net/ionic/ionic_rxtx_simple.c b/drivers/net/ionic/ionic_rxtx_simple.c index fe10e2624e..74b9ee65c3 100644 --- a/drivers/net/ionic/ionic_rxtx_simple.c +++ b/drivers/net/ionic/ionic_rxtx_simple.c @@ -140,6 +140,7 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, struct rte_mbuf *mbuf; uint32_t bytes_tx = 0; uint16_t nb_avail, nb_tx = 0; + uint64_t then, now, hz, delta; int err; struct ionic_txq_desc *desc_base = q->base; @@ -193,8 +194,26 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, rte_wmb(); ionic_q_flush(q); + txq->last_wdog_cycles = rte_get_timer_cycles(); + stats->packets += nb_tx; stats->bytes += bytes_tx; + } else { + /* + * Ring the doorbell again if no work could be posted and work + * is still pending after the deadline. + */ + if (q->head_idx != q->tail_idx) { + then = txq->last_wdog_cycles; + now = rte_get_timer_cycles(); + hz = rte_get_timer_hz(); + delta = (now - then) * 1000; + + if (delta >= hz * IONIC_Q_WDOG_MS) { + ionic_q_flush(q); + txq->last_wdog_cycles = now; + } + } } return nb_tx; @@ -342,6 +361,7 @@ ionic_rxq_service(struct ionic_rx_qcq *rxq, uint32_t work_to_do, struct ionic_rxq_desc *q_desc_base = q->base; struct ionic_rxq_comp *cq_desc, *cq_desc_base = cq->base; uint32_t work_done = 0; + uint64_t then, now, hz, delta; cq_desc = &cq_desc_base[cq->tail_idx]; @@ -374,8 +394,36 @@ ionic_rxq_service(struct ionic_rx_qcq *rxq, uint32_t work_to_do, } /* Update the queue indices and ring the doorbell */ - if (work_done) + if (work_done) { ionic_q_flush(q); + rxq->last_wdog_cycles = rte_get_timer_cycles(); + rxq->wdog_ms = IONIC_Q_WDOG_MS; + } else { + /* + * Ring the doorbell again if no recvs were posted and the + * recv queue is not empty after the deadline. + * + * Exponentially back off the deadline to avoid excessive + * doorbells when the recv queue is idle. + */ + if (q->head_idx != q->tail_idx) { + then = rxq->last_wdog_cycles; + now = rte_get_timer_cycles(); + hz = rte_get_timer_hz(); + delta = (now - then) * 1000; + + if (delta >= hz * rxq->wdog_ms) { + ionic_q_flush(q); + rxq->last_wdog_cycles = now; + + delta = 2 * rxq->wdog_ms; + if (delta > IONIC_Q_WDOG_MAX_MS) + delta = IONIC_Q_WDOG_MAX_MS; + + rxq->wdog_ms = delta; + } + } + } } uint16_t -- 2.17.1