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 56337A0560; Tue, 18 Oct 2022 21:48:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A1D34281C; Tue, 18 Oct 2022 21:48:55 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2043.outbound.protection.outlook.com [40.107.244.43]) by mails.dpdk.org (Postfix) with ESMTP id 86338427F1 for ; Tue, 18 Oct 2022 21:48:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2X6veHbvw4a0SHUnRFVndohtNTWEecA7U1qJ+DftX9iHiSQCE0GZqu6k+htck86pEGS/mOwWS7cMV2JUyP8aBbtzptnaXV2S+AmgGBfsSX5bCPojCsd/op6pxadXk/f+KeBV7ajEHW1GKlAG1I9kyKVTV09drcG7smV1P9317aS6IXOIxvARhYCVC7RXNfvR3QfA+AzYBjsFd5FqsZLxVmbZvEGPDOJxCtu2ilfWTn0DuL+7TjQqhYPoJRx13/kNu0vKA5a7Yx8qRnmMPjwm9Tx7pW2lKevkAreWaJw7WqydmSs2uYDm3iB5xba5pG5K4nolzjyrn3u3J5mtOtILQ== 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=9jyksuWp4IEy4q2EG2JU1Y1zvIgPRyXwtD2Aad5YVb4=; b=lqKbPgEG3IdQ1HirfJWCeLQZavRj8y2vQvqB2ixPPo/xWkFFWsoRMW5EdMc87Dl+3qkhmWffCwIdoCMjvuMKLCGTxn7/Yfh2WvekCIXcnC8f7Z9X1rpu482eaXCsoVSB76MgJNoG7ByJXQ4x2c3XXmNEzqCLMuverFJ2EOj4la1LPbhmTfE6S4LixasM2ClwXUzNa8RGRrdhndqoL2aQ9FjJCTgWWGexYMsjPen4t1clWgPe86vtHkum3BrJxAMj2Uha1Dz4udo9q0Wylr2zDZQNoYbExAGbkzv3SsaJ6EM9LJO7YJXNejfohcc+PxrTtODEpj7spcmxuuZfd0SZuQ== 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=9jyksuWp4IEy4q2EG2JU1Y1zvIgPRyXwtD2Aad5YVb4=; b=rZrJLzzUd/9a0ZjnuaYpN4jDNzGN77CqybRG0tn0eGsNHdtpp2rdESHLnwoZ1NN9bxjLJFTQ84fVZjWRyxzQkWN1AHogXlzetHGAfwyPhx/tZcYCpn1ItlbxjBWh9FYZHn9z7x23bE/B1M3Kh+wssV80wa6G+CV6Yb/6KVSrUYI= Received: from DS7PR07CA0022.namprd07.prod.outlook.com (2603:10b6:5:3af::24) by DM4PR12MB7575.namprd12.prod.outlook.com (2603:10b6:8:10d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 19:48:51 +0000 Received: from DM6NAM11FT105.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::ba) by DS7PR07CA0022.outlook.office365.com (2603:10b6:5:3af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Tue, 18 Oct 2022 19:48:51 +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 DM6NAM11FT105.mail.protection.outlook.com (10.13.173.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Tue, 18 Oct 2022 19:48:51 +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.31; Tue, 18 Oct 2022 14:48:48 -0500 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH v2 36/36] net/ionic: add watchdogs to protect each queue type Date: Tue, 18 Oct 2022 12:41:31 -0700 Message-ID: <20221018194131.23006-37-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221011005032.47584-1-andrew.boyer@amd.com> References: <20221011005032.47584-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT105:EE_|DM4PR12MB7575:EE_ X-MS-Office365-Filtering-Correlation-Id: 49ad3e48-f88b-4233-3b68-08dab141c7f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LSRPZ8zPT9RvcQ0n9SC5Vdx8zqg43Le1Q+tdG+aacbHmVDG5npChqxJwFj3Tzsw/OwIptf52UylYyi4dh0Ah6jjtsqQ+P/9zjfop0Rk4fDfe9SCqiefH01Y2lTFLWd7/i52XZplTW4NmabgBxtKHGErBzK61l/bnEto5sHR15lZIbTvDSgJ90yGObns6HhreUmcO80khV49q5DPstbKZVSv20OzbqbYiQc9BRd1ds+z7iZsE/HhregNYeKsXCHvbP5wEW81+K4C7cePVMRW8czTy7O8Ux9P1pY3FjrJYCqZaxQQAdXlmxTDNEx+nUU4VylI22MPrz7DYSSjdOdbNnREeUeirgsFi2k4YxkrzsnLoSnNm/wLPs/o/fU7OHqfOhYDeV4uYJL+vXLfv6pj4j4qTgSxYdLiTlUn7m9WeqXvw9Ny+5rrZcbCMQT8KRQfKJ0f9ZWTu2KxNWWNMtMGLK5fVabPOFrTjW1jxDLjUuNjx2nOCclxoWcKZ7+3F4EEj/7B71/jyjbXGdkhT2otNNB7cB5gwXlOctDR8YlHaiLTPTrbBJF5XZucxHNGbJMAIFzfRaI0BVS4fXdu8upA+KgZQE94J39mbRvicLAXvAYBtVd76xJz7iYNtvnW1QAlIRpdKB9qKacoV883hWZAGRTogI6Xd/geoj5DSowcRCJACzNDYPM2xlj2/3WR3W/+K6CxrRWw9ilD6qmjdHn2Tw/cjD45NPDxUef51LJO8+Vkvrww8r9bSiNnoVMDWbsKT03cMshYS+JLEYBLaxzfsSF9A4Zj+Q+4Vz4MbBLG6ZIgIPsuY8PXezFMmCOOcWfne 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)(396003)(39860400002)(346002)(136003)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(82740400003)(82310400005)(478600001)(356005)(81166007)(186003)(4326008)(2616005)(40460700003)(36756003)(44832011)(6916009)(316002)(70586007)(70206006)(426003)(336012)(47076005)(83380400001)(6666004)(1076003)(5660300002)(8676002)(40480700001)(16526019)(2906002)(26005)(8936002)(86362001)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 19:48:51.1449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49ad3e48-f88b-4233-3b68-08dab141c7f5 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: DM6NAM11FT105.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7575 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 5e238e8ab7..b1e74fbd89 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 00c8add95c..36b3bcc5a9 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 26e08d06c9..c957d55bf9 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 d216980450..b9e73b4871 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 4e4a18e5d7..2752ba2acd 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 a191fd3ec9..0421fb32b2 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