From patchwork Tue Dec 6 17:09:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 9462947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 72F0660231 for ; Tue, 6 Dec 2016 17:10:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D11F2843B for ; Tue, 6 Dec 2016 17:10:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51B9628480; Tue, 6 Dec 2016 17:10:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D92892847E for ; Tue, 6 Dec 2016 17:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753933AbcLFRKf (ORCPT ); Tue, 6 Dec 2016 12:10:35 -0500 Received: from mail-pg0-f46.google.com ([74.125.83.46]:33910 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753507AbcLFRKK (ORCPT ); Tue, 6 Dec 2016 12:10:10 -0500 Received: by mail-pg0-f46.google.com with SMTP id x23so151275682pgx.1 for ; Tue, 06 Dec 2016 09:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8FSNmlJSOPDQbcpGyRkj6lRdX3xW338muyMFdIxFhxk=; b=GuLKzPOSkeZBaddLyJx3efErzlf29QE8KIN/YiuyZfSEmi+FtyX7sEEyiAkjfkW3YH yEbwSB3zTPqcwFYES6J9hSwIxpHb0KSF+602V0XUghpQxon5NpDLfZ+boiGHpF4wrsLl ZP/aXqhlm02jBWJ1DBbctw/JqFQvCfdY7/6FE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8FSNmlJSOPDQbcpGyRkj6lRdX3xW338muyMFdIxFhxk=; b=LIpCBjRtzke9ssuwJW/PJ3o7fwMqZg5WYqbeopiO3O4qJUTuU8EnRom2s36c+cXcDM bvdHLTckTSLoz5Dj/42yUxHAZiuJE8JZ5LVJ6n22z9Fc00tT1Xb9NLrdHgzUuvre+1YN 0QV0l1x45IcEuvbwEYn/H6jv8BJ9tphM/8sG/rat+nK24YE+S8SJvm92ujLOCBXMuz3b 9Vkzf4JK9frhVcq6e79SVv1FgtPUUZYitQ/V3sGu53eyvbo5PijlLvuDCFJk1CrR10e3 UpgPzTm1sBzNqFGf8sBGhUU1mAUe4tPr4dIYiWWoChR2xDM0YM/aWE5/Plljoq6mqj7H zr2A== X-Gm-Message-State: AKaTC00Hmsug63N67zWfsRo8ilEO3XCrmoLRvIdzMOewrP8C4Qpt93gWgaC5fGr6VlgTPout X-Received: by 10.99.212.69 with SMTP id i5mr115368167pgj.29.1481044208954; Tue, 06 Dec 2016 09:10:08 -0800 (PST) Received: from localhost.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id v77sm36100804pfa.85.2016.12.06.09.10.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 09:10:08 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, selvin.xavier@broadcom.com, somnath.kotur@broadcom.com, dledford@redhat.com, linux-rdma@vger.kernel.org Subject: [PATCH net-next 5/7] bnxt_en: Reserve RDMA resources by default. Date: Tue, 6 Dec 2016 12:09:36 -0500 Message-Id: <1481044178-25193-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1481044178-25193-1-git-send-email-michael.chan@broadcom.com> References: <1481044178-25193-1-git-send-email-michael.chan@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the device supports RDMA, we'll setup network default rings so that there are enough minimum resources for RDMA, if possible. However, the user can still increase network rings to the max if he wants. The actual RDMA resources won't be reserved until the RDMA driver registers. Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 ++++++++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 +++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1f6be83..7218d65 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4166,6 +4166,11 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp) if (rc) goto hwrm_func_qcaps_exit; + if (resp->flags & cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_ROCE_V1_SUPPORTED)) + bp->flags |= BNXT_FLAG_ROCEV1_CAP; + if (resp->flags & cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_ROCE_V2_SUPPORTED)) + bp->flags |= BNXT_FLAG_ROCEV2_CAP; + bp->tx_push_thresh = 0; if (resp->flags & cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED)) @@ -4808,6 +4813,24 @@ static int bnxt_setup_int_mode(struct bnxt *bp) return rc; } +unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp) +{ + if (BNXT_PF(bp)) + return bp->pf.max_stat_ctxs; +#if defined(CONFIG_BNXT_SRIOV) + return bp->vf.max_stat_ctxs; +#endif +} + +unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp) +{ + if (BNXT_PF(bp)) + return bp->pf.max_cp_rings; +#if defined(CONFIG_BNXT_SRIOV) + return bp->vf.max_cp_rings; +#endif +} + static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp) { if (BNXT_PF(bp)) @@ -6832,6 +6855,39 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared) return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared); } +static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx, + bool shared) +{ + int rc; + + rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared); + if (rc) + return rc; + + if (bp->flags & BNXT_FLAG_ROCE_CAP) { + int max_cp, max_stat, max_irq; + + /* Reserve minimum resources for RoCE */ + max_cp = bnxt_get_max_func_cp_rings(bp); + max_stat = bnxt_get_max_func_stat_ctxs(bp); + max_irq = bnxt_get_max_func_irqs(bp); + if (max_cp <= BNXT_MIN_ROCE_CP_RINGS || + max_irq <= BNXT_MIN_ROCE_CP_RINGS || + max_stat <= BNXT_MIN_ROCE_STAT_CTXS) + return 0; + + max_cp -= BNXT_MIN_ROCE_CP_RINGS; + max_irq -= BNXT_MIN_ROCE_CP_RINGS; + max_stat -= BNXT_MIN_ROCE_STAT_CTXS; + max_cp = min_t(int, max_cp, max_irq); + max_cp = min_t(int, max_cp, max_stat); + rc = bnxt_trim_rings(bp, max_rx, max_tx, max_cp, shared); + if (rc) + rc = 0; + } + return rc; +} + static int bnxt_set_dflt_rings(struct bnxt *bp) { int dflt_rings, max_rx_rings, max_tx_rings, rc; @@ -6840,7 +6896,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp) if (sh) bp->flags |= BNXT_FLAG_SHARED_RINGS; dflt_rings = netif_get_num_default_rss_queues(); - rc = bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings, sh); + rc = bnxt_get_dflt_rings(bp, &max_rx_rings, &max_tx_rings, sh); if (rc) return rc; bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 43a4b17..d796836 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -387,6 +387,9 @@ struct rx_tpa_end_cmp_ext { #define DB_KEY_TX_PUSH (0x4 << 28) #define DB_LONG_TX_PUSH (0x2 << 24) +#define BNXT_MIN_ROCE_CP_RINGS 2 +#define BNXT_MIN_ROCE_STAT_CTXS 1 + #define INVALID_HW_RING_ID ((u16)-1) /* The hardware supports certain page sizes. Use the supported page sizes @@ -953,6 +956,10 @@ struct bnxt { #define BNXT_FLAG_PORT_STATS 0x400 #define BNXT_FLAG_UDP_RSS_CAP 0x800 #define BNXT_FLAG_EEE_CAP 0x1000 + #define BNXT_FLAG_ROCEV1_CAP 0x8000 + #define BNXT_FLAG_ROCEV2_CAP 0x10000 + #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \ + BNXT_FLAG_ROCEV2_CAP) #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ @@ -1234,6 +1241,8 @@ static inline void bnxt_disable_poll(struct bnxt_napi *bnapi) int hwrm_send_message(struct bnxt *, void *, u32, int); int hwrm_send_message_silent(struct bnxt *, void *, u32, int); int bnxt_hwrm_set_coal(struct bnxt *); +unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); +unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max); void bnxt_tx_disable(struct bnxt *bp); void bnxt_tx_enable(struct bnxt *bp);