From owner-svn-src-head@freebsd.org Thu Nov 9 12:03:07 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 DE4A7E4E53D; Thu, 9 Nov 2017 12:03:07 +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 A91AD63600; Thu, 9 Nov 2017 12:03:07 +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 vA9C36sA054047; Thu, 9 Nov 2017 12:03:06 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vA9C36H5054045; Thu, 9 Nov 2017 12:03:06 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201711091203.vA9C36H5054045@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 12:03:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325583 - 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: 325583 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 12:03:08 -0000 Author: mw Date: Thu Nov 9 12:03:06 2017 New Revision: 325583 URL: https://svnweb.freebsd.org/changeset/base/325583 Log: Allow partial MSI-x allocation in ENA driver The situation, where part of the MSI-x was not configured properly, was not properly handled. Now, the driver reduces number of queues to reflect number of existing and properly configured MSI-x vectors. Submitted by: Michal Krawczyk Reviewed by: byenduri_gmail.com Obtained from: Semihalf Sponsored by: Amazon, Inc. Differential Revision: https://reviews.freebsd.org/D12863 Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Thu Nov 9 12:01:46 2017 (r325582) +++ head/sys/dev/ena/ena.c Thu Nov 9 12:03:06 2017 (r325583) @@ -1796,7 +1796,8 @@ static int ena_enable_msix(struct ena_adapter *adapter) { device_t dev = adapter->pdev; - int i, msix_vecs, rc = 0; + int msix_vecs, msix_req; + int i, rc = 0; /* Reserved the max msix vectors we might need */ msix_vecs = ENA_MAX_MSIX_VEC(adapter->num_queues); @@ -1813,6 +1814,7 @@ ena_enable_msix(struct ena_adapter *adapter) adapter->msix_entries[i].vector = i + 1; } + msix_req = msix_vecs; rc = pci_alloc_msix(dev, &msix_vecs); if (unlikely(rc != 0)) { device_printf(dev, @@ -1820,6 +1822,12 @@ ena_enable_msix(struct ena_adapter *adapter) rc = ENOSPC; goto err_msix_free; + } + + if (msix_vecs != msix_req) { + device_printf(dev, "Enable only %d MSI-x (out of %d), reduce " + "the number of queues\n", msix_vecs, msix_req); + adapter->num_queues = msix_vecs - ENA_ADMIN_MSIX_VEC; } adapter->msix_vecs = msix_vecs; Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Thu Nov 9 12:01:46 2017 (r325582) +++ head/sys/dev/ena/ena.h Thu Nov 9 12:03:06 2017 (r325583) @@ -58,7 +58,8 @@ #define ENA_DMA_BIT_MASK(x) ((1ULL << (x)) - 1ULL) /* 1 for AENQ + ADMIN */ -#define ENA_MAX_MSIX_VEC(io_queues) (1 + (io_queues)) +#define ENA_ADMIN_MSIX_VEC 1 +#define ENA_MAX_MSIX_VEC(io_queues) (ENA_ADMIN_MSIX_VEC + (io_queues)) #define ENA_REG_BAR 0 #define ENA_MEM_BAR 2