aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4/main.c
diff options
context:
space:
mode:
authorEli Cohen <eli@mellanox.co.il>2011-03-22 18:38:41 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-23 15:24:23 -0400
commitc1b43dca137f2154845122417fba86d4bae67182 (patch)
tree36237582bfd5baf0e9a3ccea5377b949be289440 /drivers/net/mlx4/main.c
parent1679200f91da6a054b06954c9bd3eeed29b6731f (diff)
mlx4: Add blue flame support for kernel consumers
Using blue flame can improve latency by allowing the HW to more efficiently access the WQE. This patch presents two functions that are used to allocate or release HW resources for using blue flame; the caller need to supply a struct mlx4_bf object when allocating resources. Consumers that make use of this API should post doorbells to the UAR object pointed by the initialized struct mlx4_bf; Signed-off-by: Eli Cohen <eli@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4/main.c')
-rw-r--r--drivers/net/mlx4/main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index c8e276138f8..05c5671749a 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -39,6 +39,7 @@
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/io-mapping.h>
42 43
43#include <linux/mlx4/device.h> 44#include <linux/mlx4/device.h>
44#include <linux/mlx4/doorbell.h> 45#include <linux/mlx4/doorbell.h>
@@ -721,8 +722,31 @@ static void mlx4_free_icms(struct mlx4_dev *dev)
721 mlx4_free_icm(dev, priv->fw.aux_icm, 0); 722 mlx4_free_icm(dev, priv->fw.aux_icm, 0);
722} 723}
723 724
725static int map_bf_area(struct mlx4_dev *dev)
726{
727 struct mlx4_priv *priv = mlx4_priv(dev);
728 resource_size_t bf_start;
729 resource_size_t bf_len;
730 int err = 0;
731
732 bf_start = pci_resource_start(dev->pdev, 2) + (dev->caps.num_uars << PAGE_SHIFT);
733 bf_len = pci_resource_len(dev->pdev, 2) - (dev->caps.num_uars << PAGE_SHIFT);
734 priv->bf_mapping = io_mapping_create_wc(bf_start, bf_len);
735 if (!priv->bf_mapping)
736 err = -ENOMEM;
737
738 return err;
739}
740
741static void unmap_bf_area(struct mlx4_dev *dev)
742{
743 if (mlx4_priv(dev)->bf_mapping)
744 io_mapping_free(mlx4_priv(dev)->bf_mapping);
745}
746
724static void mlx4_close_hca(struct mlx4_dev *dev) 747static void mlx4_close_hca(struct mlx4_dev *dev)
725{ 748{
749 unmap_bf_area(dev);
726 mlx4_CLOSE_HCA(dev, 0); 750 mlx4_CLOSE_HCA(dev, 0);
727 mlx4_free_icms(dev); 751 mlx4_free_icms(dev);
728 mlx4_UNMAP_FA(dev); 752 mlx4_UNMAP_FA(dev);
@@ -775,6 +799,9 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
775 goto err_stop_fw; 799 goto err_stop_fw;
776 } 800 }
777 801
802 if (map_bf_area(dev))
803 mlx4_dbg(dev, "Failed to map blue flame area\n");
804
778 init_hca.log_uar_sz = ilog2(dev->caps.num_uars); 805 init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
779 806
780 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size); 807 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
@@ -805,6 +832,7 @@ err_free_icm:
805 mlx4_free_icms(dev); 832 mlx4_free_icms(dev);
806 833
807err_stop_fw: 834err_stop_fw:
835 unmap_bf_area(dev);
808 mlx4_UNMAP_FA(dev); 836 mlx4_UNMAP_FA(dev);
809 mlx4_free_icm(dev, priv->fw.fw_icm, 0); 837 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
810 838
@@ -1196,6 +1224,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1196 1224
1197 pci_read_config_byte(pdev, PCI_REVISION_ID, &dev->rev_id); 1225 pci_read_config_byte(pdev, PCI_REVISION_ID, &dev->rev_id);
1198 1226
1227 INIT_LIST_HEAD(&priv->bf_list);
1228 mutex_init(&priv->bf_mutex);
1229
1199 /* 1230 /*
1200 * Now reset the HCA before we touch the PCI capabilities or 1231 * Now reset the HCA before we touch the PCI capabilities or
1201 * attempt a firmware command, since a boot ROM may have left 1232 * attempt a firmware command, since a boot ROM may have left