]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bnxt_en: Reserve RDMA resources by default.
authorMichael Chan <michael.chan@broadcom.com>
Wed, 7 Dec 2016 05:26:19 +0000 (00:26 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Dec 2016 15:59:26 +0000 (10:59 -0500)
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.

v2: Fix compile warning when BNXT_CONFIG_SRIOV is not set.

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index 52b8ad4973e338a4a3cb909ddf954158f81caab2..57285bd7694403a20b63493d9049c9cebdf110d2 100644 (file)
@@ -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 defined(CONFIG_BNXT_SRIOV)
+       if (BNXT_VF(bp))
+               return bp->vf.max_stat_ctxs;
+#endif
+       return bp->pf.max_stat_ctxs;
+}
+
+unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
+{
+#if defined(CONFIG_BNXT_SRIOV)
+       if (BNXT_VF(bp))
+               return bp->vf.max_cp_rings;
+#endif
+       return bp->pf.max_cp_rings;
+}
+
 static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
 {
 #if defined(CONFIG_BNXT_SRIOV)
@@ -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);
index 43a4b170a6f1e6a4168543c87b5107a6732c4706..d796836633c85ae849e0da3eeb1d9c51e0a0cb4f 100644 (file)
@@ -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 @@ int _hwrm_send_message(struct bnxt *, void *, u32, int);
 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);