aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mlx4
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2013-11-03 03:03:23 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-04 16:19:07 -0500
commit5a0d0a6161aecbbc76e4c1d2b82e4c7cef88bb29 (patch)
treeab181f2d85ad79385f739c3c1c682b1db835b9aa /include/linux/mlx4
parenta30f1bc5c0254cee94bc22304e57fe030fcf68f5 (diff)
mlx4: Structures and init/teardown for VF resource quotas
This is step #1 for implementing SRIOV resource quotas for VFs. Quotas are implemented per resource type for VFs and the PF, to prevent any entity from simply grabbing all the resources for itself and leaving the other entities unable to obtain such resources. Resources which are allocated using quotas: QPs, CQs, SRQs, MPTs, MTTs, MAC, VLAN, and Counters. The quota system works as follows: Each entity (VF or PF) is given a max number of a given resource (its quota), and a guaranteed minimum number for each resource (starvation prevention). For QPs, CQs, SRQs, MPTs and MTTs: 50% of the available quantity for the resource is divided equally among the PF and all the active VFs (i.e., the number of VFs in the mlx4_core module parameter "num_vfs"). This 50% represents the "guaranteed minimum" pool. The other 50% is the "free pool", allocated on a first-come-first-serve basis. For each VF/PF, resources are first allocated from its "guaranteed-minimum" pool. When that pool is exhausted, the driver attempts to allocate from the resource "free-pool". The quota (i.e., max) for the VFs and the PF is: The free-pool amount (50% of the real max) + the guaranteed minimum For MACs: Guarantee 2 MACs per VF/PF per port. As a result, since we have only 128 MACs per port, reduce the allowable number of VFs from 64 to 63. Any remaining MACs are put into a free pool. For VLANs: For the PF, the per-port quota is 128 and guarantee is 64 (to allow the PF to register at least a VLAN per VF in VST mode). For the VFs, the per-port quota is 64 and the guarantee is 0. We assume that VGT VFs are trusted not to abuse the VLAN resource. For Counters: For all functions (PF and VFs), the quota is 128 and the guarantee is 0. In this patch, we define the needed structures, which are added to the resource-tracker struct. In addition, we do initialization for the resource quota, and adjust the query_device response to use quotas rather than resource maxima. As part of the implementation, we introduce a new field in mlx4_dev: quotas. This field holds the resource quotas used to report maxima to the upper layers (ib_core, via query_device). The HCA maxima of these values are passed to the VFs (via QUERY_HCA) so that they may continue to use these in handling QPs, CQs, SRQs and MPTs. Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/mlx4')
-rw-r--r--include/linux/mlx4/device.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index e2e92885bdc1..f6f59271f857 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -641,12 +641,23 @@ struct mlx4_counter {
641 __be64 tx_bytes; 641 __be64 tx_bytes;
642}; 642};
643 643
644struct mlx4_quotas {
645 int qp;
646 int cq;
647 int srq;
648 int mpt;
649 int mtt;
650 int counter;
651 int xrcd;
652};
653
644struct mlx4_dev { 654struct mlx4_dev {
645 struct pci_dev *pdev; 655 struct pci_dev *pdev;
646 unsigned long flags; 656 unsigned long flags;
647 unsigned long num_slaves; 657 unsigned long num_slaves;
648 struct mlx4_caps caps; 658 struct mlx4_caps caps;
649 struct mlx4_phys_caps phys_caps; 659 struct mlx4_phys_caps phys_caps;
660 struct mlx4_quotas quotas;
650 struct radix_tree_root qp_table_tree; 661 struct radix_tree_root qp_table_tree;
651 u8 rev_id; 662 u8 rev_id;
652 char board_id[MLX4_BOARD_ID_LEN]; 663 char board_id[MLX4_BOARD_ID_LEN];
@@ -772,6 +783,12 @@ static inline int mlx4_is_master(struct mlx4_dev *dev)
772 return dev->flags & MLX4_FLAG_MASTER; 783 return dev->flags & MLX4_FLAG_MASTER;
773} 784}
774 785
786static inline int mlx4_num_reserved_sqps(struct mlx4_dev *dev)
787{
788 return dev->phys_caps.base_sqpn + 8 +
789 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev);
790}
791
775static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn) 792static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn)
776{ 793{
777 return (qpn < dev->phys_caps.base_sqpn + 8 + 794 return (qpn < dev->phys_caps.base_sqpn + 8 +