bnxt_en: Assign additional vnics to VFs.
authorMichael Chan <michael.chan@broadcom.com>
Thu, 29 Dec 2016 17:13:39 +0000 (12:13 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Dec 2016 19:37:23 +0000 (14:37 -0500)
Assign additional vnics to VFs whenever possible so that NTUPLE can be
supported on the VFs.

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

index c69602508666cbf4a0e14226bf1b0d612ae907ae..0c9f6c1db546100cc1069f43a4925053af9ff88a 100644 (file)
@@ -429,6 +429,8 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
                vf_rx_rings = (pf->max_rx_rings - bp->rx_nr_rings) / num_vfs;
        vf_ring_grps = (bp->pf.max_hw_ring_grps - bp->rx_nr_rings) / num_vfs;
        vf_tx_rings = (pf->max_tx_rings - bp->tx_nr_rings) / num_vfs;
+       vf_vnics = (pf->max_vnics - bp->nr_vnics) / num_vfs;
+       vf_vnics = min_t(u16, vf_vnics, vf_rx_rings);
 
        req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_MTU |
                                  FUNC_CFG_REQ_ENABLES_MRU |
@@ -451,7 +453,6 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
        req.num_rx_rings = cpu_to_le16(vf_rx_rings);
        req.num_hw_ring_grps = cpu_to_le16(vf_ring_grps);
        req.num_l2_ctxs = cpu_to_le16(4);
-       vf_vnics = 1;
 
        req.num_vnics = cpu_to_le16(vf_vnics);
        /* FIXME spec currently uses 1 bit for stats ctx */
@@ -506,6 +507,8 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
                            min_rx_rings)
                                rx_ok = 1;
                }
+               if (bp->pf.max_vnics - bp->nr_vnics < min_rx_rings)
+                       rx_ok = 0;
 
                if (bp->pf.max_tx_rings - bp->tx_nr_rings >= min_tx_rings)
                        tx_ok = 1;