提交 839f1243 编写于 作者: R Roland Dreier

mlx4_core: Stash PCI ID driver_data in mlx4_priv structure

That way we can check flags later on, when we've finished with the
pci_device_id structure.  Also convert the "is VF" flag to an enum:
"Never do in the preprocessor what can be done in C."
Signed-off-by: NRoland Dreier <roland@purestorage.com>
上级 f3d4c89e
...@@ -95,8 +95,6 @@ MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num" ...@@ -95,8 +95,6 @@ MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num"
" Not in use with device managed" " Not in use with device managed"
" flow steering"); " flow steering");
#define MLX4_VF (1 << 0)
#define HCA_GLOBAL_CAP_MASK 0 #define HCA_GLOBAL_CAP_MASK 0
#define PF_CONTEXT_BEHAVIOUR_MASK 0 #define PF_CONTEXT_BEHAVIOUR_MASK 0
...@@ -1916,7 +1914,7 @@ static void mlx4_free_ownership(struct mlx4_dev *dev) ...@@ -1916,7 +1914,7 @@ static void mlx4_free_ownership(struct mlx4_dev *dev)
iounmap(owner); iounmap(owner);
} }
static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
{ {
struct mlx4_priv *priv; struct mlx4_priv *priv;
struct mlx4_dev *dev; struct mlx4_dev *dev;
...@@ -1939,12 +1937,11 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1939,12 +1937,11 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
/* /*
* Check for BARs. * Check for BARs.
*/ */
if (((id == NULL) || !(id->driver_data & MLX4_VF)) && if (!(pci_dev_data & MLX4_PCI_DEV_IS_VF) &&
!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { !(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "Missing DCS, aborting." dev_err(&pdev->dev, "Missing DCS, aborting."
"(id == 0X%p, id->driver_data: 0x%lx," "(driver_data: 0x%x, pci_resource_flags(pdev, 0):0x%lx)\n",
" pci_resource_flags(pdev, 0):0x%lx)\n", id, pci_dev_data, pci_resource_flags(pdev, 0));
id ? id->driver_data : 0, pci_resource_flags(pdev, 0));
err = -ENODEV; err = -ENODEV;
goto err_disable_pdev; goto err_disable_pdev;
} }
...@@ -2009,7 +2006,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2009,7 +2006,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
dev->rev_id = pdev->revision; dev->rev_id = pdev->revision;
/* Detect if this device is a virtual function */ /* Detect if this device is a virtual function */
if (id && id->driver_data & MLX4_VF) { if (pci_dev_data & MLX4_PCI_DEV_IS_VF) {
/* When acting as pf, we normally skip vfs unless explicitly /* When acting as pf, we normally skip vfs unless explicitly
* requested to probe them. */ * requested to probe them. */
if (num_vfs && extended_func_num(pdev) > probe_vf) { if (num_vfs && extended_func_num(pdev) > probe_vf) {
...@@ -2156,6 +2153,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2156,6 +2153,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
mlx4_sense_init(dev); mlx4_sense_init(dev);
mlx4_start_sense(dev); mlx4_start_sense(dev);
priv->pci_dev_data = pci_dev_data;
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
return 0; return 0;
...@@ -2225,7 +2223,7 @@ static int __devinit mlx4_init_one(struct pci_dev *pdev, ...@@ -2225,7 +2223,7 @@ static int __devinit mlx4_init_one(struct pci_dev *pdev,
{ {
printk_once(KERN_INFO "%s", mlx4_version); printk_once(KERN_INFO "%s", mlx4_version);
return __mlx4_init_one(pdev, id); return __mlx4_init_one(pdev, id->driver_data);
} }
static void mlx4_remove_one(struct pci_dev *pdev) static void mlx4_remove_one(struct pci_dev *pdev)
...@@ -2305,8 +2303,13 @@ static void mlx4_remove_one(struct pci_dev *pdev) ...@@ -2305,8 +2303,13 @@ static void mlx4_remove_one(struct pci_dev *pdev)
int mlx4_restart_one(struct pci_dev *pdev) int mlx4_restart_one(struct pci_dev *pdev)
{ {
struct mlx4_dev *dev = pci_get_drvdata(pdev);
struct mlx4_priv *priv = mlx4_priv(dev);
int pci_dev_data;
pci_dev_data = priv->pci_dev_data;
mlx4_remove_one(pdev); mlx4_remove_one(pdev);
return __mlx4_init_one(pdev, NULL); return __mlx4_init_one(pdev, pci_dev_data);
} }
static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = { static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
...@@ -2335,11 +2338,11 @@ static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = { ...@@ -2335,11 +2338,11 @@ static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
/* MT26478 ConnectX2 40GigE PCIe gen2 */ /* MT26478 ConnectX2 40GigE PCIe gen2 */
{ PCI_VDEVICE(MELLANOX, 0x676e), 0 }, { PCI_VDEVICE(MELLANOX, 0x676e), 0 },
/* MT25400 Family [ConnectX-2 Virtual Function] */ /* MT25400 Family [ConnectX-2 Virtual Function] */
{ PCI_VDEVICE(MELLANOX, 0x1002), MLX4_VF }, { PCI_VDEVICE(MELLANOX, 0x1002), MLX4_PCI_DEV_IS_VF },
/* MT27500 Family [ConnectX-3] */ /* MT27500 Family [ConnectX-3] */
{ PCI_VDEVICE(MELLANOX, 0x1003), 0 }, { PCI_VDEVICE(MELLANOX, 0x1003), 0 },
/* MT27500 Family [ConnectX-3 Virtual Function] */ /* MT27500 Family [ConnectX-3 Virtual Function] */
{ PCI_VDEVICE(MELLANOX, 0x1004), MLX4_VF }, { PCI_VDEVICE(MELLANOX, 0x1004), MLX4_PCI_DEV_IS_VF },
{ PCI_VDEVICE(MELLANOX, 0x1005), 0 }, /* MT27510 Family */ { PCI_VDEVICE(MELLANOX, 0x1005), 0 }, /* MT27510 Family */
{ PCI_VDEVICE(MELLANOX, 0x1006), 0 }, /* MT27511 Family */ { PCI_VDEVICE(MELLANOX, 0x1006), 0 }, /* MT27511 Family */
{ PCI_VDEVICE(MELLANOX, 0x1007), 0 }, /* MT27520 Family */ { PCI_VDEVICE(MELLANOX, 0x1007), 0 }, /* MT27520 Family */
...@@ -2368,7 +2371,7 @@ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev, ...@@ -2368,7 +2371,7 @@ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev) static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev)
{ {
int ret = __mlx4_init_one(pdev, NULL); int ret = __mlx4_init_one(pdev, 0);
return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
} }
......
...@@ -768,6 +768,10 @@ struct _rule_hw { ...@@ -768,6 +768,10 @@ struct _rule_hw {
}; };
}; };
enum {
MLX4_PCI_DEV_IS_VF = 1 << 0,
};
struct mlx4_priv { struct mlx4_priv {
struct mlx4_dev dev; struct mlx4_dev dev;
...@@ -775,6 +779,8 @@ struct mlx4_priv { ...@@ -775,6 +779,8 @@ struct mlx4_priv {
struct list_head ctx_list; struct list_head ctx_list;
spinlock_t ctx_lock; spinlock_t ctx_lock;
int pci_dev_data;
struct list_head pgdir_list; struct list_head pgdir_list;
struct mutex pgdir_mutex; struct mutex pgdir_mutex;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册