From owner-svn-src-head@freebsd.org Thu Nov 9 11:50:54 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06DA8E7275E; Thu, 9 Nov 2017 11:50:54 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3E6B3253; Thu, 9 Nov 2017 11:50:53 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vA9Boq9A045807; Thu, 9 Nov 2017 11:50:52 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vA9BoqZR045806; Thu, 9 Nov 2017 11:50:52 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201711091150.vA9BoqZR045806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Thu, 9 Nov 2017 11:50:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325577 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 325577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Nov 2017 11:50:54 -0000 Author: mw Date: Thu Nov 9 11:50:52 2017 New Revision: 325577 URL: https://svnweb.freebsd.org/changeset/base/325577 Log: Split function checking for missing TX completion in ENA driver Pure cosmetic change for better readability of the driver. Submitted by: Michal Krawczyk Reviewed by: byenduri_gmail.com Obtained from: Semihalf Sponsored by: Amazon, Inc. Differential Revision: https://reviews.freebsd.org/D12857 Modified: head/sys/dev/ena/ena.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Thu Nov 9 11:48:22 2017 (r325576) +++ head/sys/dev/ena/ena.c Thu Nov 9 11:50:52 2017 (r325577) @@ -3349,6 +3349,56 @@ static void check_for_admin_com_state(struct ena_adapt } } +static int +check_missing_comp_in_queue(struct ena_adapter *adapter, + struct ena_ring *tx_ring) +{ + struct bintime curtime, time; + struct ena_tx_buffer *tx_buf; + uint32_t missed_tx = 0; + int i; + + getbinuptime(&curtime); + + for (i = 0; i < tx_ring->ring_size; i++) { + tx_buf = &tx_ring->tx_buffer_info[i]; + + if (!bintime_isset(&tx_buf->timestamp)) + continue; + + time = curtime; + bintime_sub(&time, &tx_buf->timestamp); + + /* Check again if packet is still waiting */ + if (unlikely(bttosbt(time) > adapter->missing_tx_timeout)) { + + if (!tx_buf->print_once) + ena_trace(ENA_WARNING, "Found a Tx that wasn't " + "completed on time, qid %d, index %d.\n", + tx_ring->qid, i); + + tx_buf->print_once = true; + missed_tx++; + + if (unlikely(missed_tx > + adapter->missing_tx_threshold)) { + device_printf(adapter->pdev, + "The number of lost tx completion " + "is above the threshold (%d > %d). " + "Reset the device\n", + missed_tx, + adapter->missing_tx_threshold); + adapter->reset_reason = + ENA_REGS_RESET_MISS_TX_CMPL; + adapter->trigger_reset = true; + return (EIO); + } + } + } + + return (0); +} + /* * Check for TX which were not completed on time. * Timeout is defined by "missing_tx_timeout". @@ -3358,9 +3408,7 @@ static void check_for_admin_com_state(struct ena_adapt static void check_for_missing_tx_completions(struct ena_adapter *adapter) { struct ena_ring *tx_ring; - struct ena_tx_buffer *tx_info; - struct bintime curtime, time; - int i, j, budget, missed_tx; + int i, budget, rc; /* Make sure the driver doesn't turn the device in other process */ rmb(); @@ -3375,48 +3423,13 @@ static void check_for_missing_tx_completions(struct en return; budget = adapter->missing_tx_max_queues; - getbinuptime(&curtime); for (i = adapter->next_monitored_tx_qid; i < adapter->num_queues; i++) { tx_ring = &adapter->tx_ring[i]; - missed_tx = 0; - - for (j = 0; j < tx_ring->ring_size; j++) { - tx_info = &tx_ring->tx_buffer_info[j]; - - if (!bintime_isset(&tx_info->timestamp)) - continue; - - time = curtime; - bintime_sub(&time, &tx_info->timestamp); - - /* Check again if packet is still waiting */ - if (bintime_isset(&tx_info->timestamp) && unlikely( - bttosbt(time) > adapter->missing_tx_timeout)) { - if (tx_info->print_once) - device_printf(adapter->pdev, - "Found a Tx that wasn't completed " - "on time, qid %d, index %d.\n", - tx_ring->qid, j); - - tx_info->print_once = false; - missed_tx++; - - if (unlikely(missed_tx > - adapter->missing_tx_threshold)) { - device_printf(adapter->pdev, - "The number of lost tx completion " - "is above the threshold (%d > %d). " - "Reset the device\n", missed_tx, - adapter->missing_tx_threshold); - adapter->reset_reason = - ENA_REGS_RESET_MISS_TX_CMPL; - adapter->trigger_reset = true; - return; - } - } - } + rc = check_missing_comp_in_queue(adapter, tx_ring); + if (unlikely(rc)) + return; budget--; if (budget == 0) {