Skip to contentSkip to conversation

mlx4_core: Modify driver initialization flow to accommodate SRIOV for Ethernet

PATCH In review Yevgeny Petrilin 6 participants 11 messages Dec 2, 2011 – Dec 6, 2011 6 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 19/21 mlx4_core: Modify driver initialization flow to accommodate SRIOV for Ethernet

From: Jack Morgenstein <[email protected]>

1. Added module parameters sr_iov and probe_vf for controlling enablement of SRIOV mode.
2. Increased default max num-qps, num-mpts and log_num_macs to accomodate SRIOV mode
3. Added port_type_array as a module parameter to allow driver startup with ports configured as desired.
In SRIOV mode, only ETH is supported, and this array is ignored; otherwise, for the case where the FW supports both port types (ETH and IB), the port_type_array parameter is used.
By default, the port_type_array is set to configure both ports as IB.
4. When running in sriov mode, the master needs to initialize the ICM eq table to hold the eq's for itself and also for all the slaves.
5. mlx4_set_port_mask() now invoked from mlx4_init_hca, instead of in mlx4_dev_cap.
6. Introduced sriov VF (slave) device startup/teardown logic (mainly procedures mlx4_init_slave, mlx4_slave_exit, mlx4_slave_cap, mlx4_slave_exit and flow modifications in __mlx4_init_one, mlx4_init_hca, and mlx4_setup_hca). VFs obtain their startup information from the PF (master) device via the comm channel.
7. In SRIOV mode (both PF and VF), MSI_X must be enabled, or the driver aborts loading the device.
8. Do not allow setting port type via sysfs when running in SRIOV mode.
9. mlx4_get_ownership: Currently, only one PF is supported by the driver. If the HCA is burned with FW which enables more than one PF, only one of the PFs is allowed to run. The first one up grabs a FW ownership semaphone -- all other PFs will find that semaphore taken, and the driver will not allow them to run.

---
 drivers/net/ethernet/mellanox/mlx4/cmd.c  |  170 ++++++-
 drivers/net/ethernet/mellanox/mlx4/fw.c   |   68 +++-
 drivers/net/ethernet/mellanox/mlx4/fw.h   |    2 +
 drivers/net/ethernet/mellanox/mlx4/main.c |  836 +++++++++++++++++++++++------
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |    6 +
 include/linux/mlx4/cmd.h                  |    2 +
 include/linux/mlx4/device.h               |    1 +
 7 files changed, 929 insertions(+), 156 deletions(-)
drivers/net/ethernet/mellanox/mlx4/cmd.c +169 -1
index 43ea980..ee2a24f 100644
@@ -257,7 +257,7 @@ out:
 	return err;
 }
 
-static int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
+int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
 		  unsigned long timeout)
 {
 	if (mlx4_priv(dev)->cmd.use_events)
@@ -1383,6 +1383,153 @@ void mlx4_master_comm_channel(struct work_struct *work)
 		mlx4_warn(dev, "Failed to arm comm channel events\n");
 }
 
+static int sync_toggles(struct mlx4_dev *dev)
+{
+	struct mlx4_priv *priv = mlx4_priv(dev);
+	int wr_toggle;
+	int rd_toggle;
+	unsigned long end;
+
+	wr_toggle = swab32(readl(&priv->mfunc.comm->slave_write)) >> 31;
+	end = jiffies + msecs_to_jiffies(5000);
+
+	while (time_before(jiffies, end)) {
+		rd_toggle = swab32(readl(&priv->mfunc.comm->slave_read)) >> 31;
+		if (rd_toggle == wr_toggle) {
+			priv->cmd.comm_toggle = rd_toggle;
+			return 0;
+		}
+
+		cond_resched();
+	}
+
+	/*
+	 * we could reach here if for example the previous VM using this
+	 * function misbehaved and left the channel with unsynced state. We
+	 * should fix this here and give this VM a chance to use a properly
+	 * synced channel
+	 */
+	mlx4_warn(dev, "recovering from previously mis-behaved VM\n");
+	__raw_writel((__force u32) 0, &priv->mfunc.comm->slave_read);
+	__raw_writel((__force u32) 0, &priv->mfunc.comm->slave_write);
+	priv->cmd.comm_toggle = 0;
+
+	return 0;
+}
+
+int mlx4_multi_func_init(struct mlx4_dev *dev)
+{
+	struct mlx4_priv *priv = mlx4_priv(dev);
+	struct mlx4_slave_state *s_state;
+	int i, err, port;
+
+	priv->mfunc.vhcr = dma_alloc_coherent(&(dev->pdev->dev), PAGE_SIZE,
+					    &priv->mfunc.vhcr_dma,
+					    GFP_KERNEL);
+	if (!priv->mfunc.vhcr) {
+		mlx4_err(dev, "Couldn't allocate vhcr.\n");
+		return -ENOMEM;
+	}
+
+	if (mlx4_is_master(dev))
+		priv->mfunc.comm =
+		ioremap(pci_resource_start(dev->pdev, priv->fw.comm_bar) +
+			priv->fw.comm_base, MLX4_COMM_PAGESIZE);
+	else
+		priv->mfunc.comm =
+		ioremap(pci_resource_start(dev->pdev, 2) +
+			MLX4_SLAVE_COMM_BASE, MLX4_COMM_PAGESIZE);
+	if (!priv->mfunc.comm) {
+		mlx4_err(dev, "Couldn't map communication vector.\n");
+		goto err_vhcr;
+	}
+
+	if (mlx4_is_master(dev)) {
+		priv->mfunc.master.slave_state =
+			kzalloc(dev->num_slaves *
+				sizeof(struct mlx4_slave_state), GFP_KERNEL);
+		if (!priv->mfunc.master.slave_state)
+			goto err_comm;
+
+		for (i = 0; i < dev->num_slaves; ++i) {
+			s_state = &priv->mfunc.master.slave_state[i];
+			s_state->last_cmd = MLX4_COMM_CMD_RESET;
+			__raw_writel((__force u32) 0,
+				     &priv->mfunc.comm[i].slave_write);
+			__raw_writel((__force u32) 0,
+				     &priv->mfunc.comm[i].slave_read);
+			mmiowb();
+			for (port = 1; port <= MLX4_MAX_PORTS; port++) {
+				s_state->vlan_filter[port] =
+					kzalloc(sizeof(struct mlx4_vlan_fltr),
+						GFP_KERNEL);
+				if (!s_state->vlan_filter[port]) {
+					if (--port)
+						kfree(s_state->vlan_filter[port]);
+					goto err_slaves;
+				}
+				INIT_LIST_HEAD(&s_state->mcast_filters[port]);
+			}
+			spin_lock_init(&s_state->lock);
+		}
+
+		memset(&priv->mfunc.master.cmd_eqe, 0, sizeof(struct mlx4_eqe));
+		priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD;
+		INIT_WORK(&priv->mfunc.master.comm_work,
+			  mlx4_master_comm_channel);
+		INIT_WORK(&priv->mfunc.master.slave_event_work,
+			  mlx4_gen_slave_eqe);
+		INIT_WORK(&priv->mfunc.master.slave_flr_event_work,
+			  mlx4_master_handle_slave_flr);
+		spin_lock_init(&priv->mfunc.master.slave_state_lock);
+		priv->mfunc.master.comm_wq =
+			create_singlethread_workqueue("mlx4_comm");
+		if (!priv->mfunc.master.comm_wq)
+			goto err_slaves;
+
+		if (mlx4_init_resource_tracker(dev))
+			goto err_thread;
+
+		sema_init(&priv->cmd.slave_sem, 1);
+		err = mlx4_ARM_COMM_CHANNEL(dev);
+		if (err) {
+			mlx4_err(dev, " Failed to arm comm channel eq: %x\n",
+				 err);
+			goto err_resource;
+		}
+
+	} else {
+		err = sync_toggles(dev);
+		if (err) {
+			mlx4_err(dev, "Couldn't sync toggles\n");
+			goto err_comm;
+		}
+
+		sema_init(&priv->cmd.slave_sem, 1);
+	}
+	return 0;
+
+err_resource:
+	mlx4_free_resource_tracker(dev);
+err_thread:
+	flush_workqueue(priv->mfunc.master.comm_wq);
+	destroy_workqueue(priv->mfunc.master.comm_wq);
+err_slaves:
+	while (--i) {
+		for (port = 1; port <= MLX4_MAX_PORTS; port++)
+			kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]);
+	}
+	kfree(priv->mfunc.master.slave_state);
+err_comm:
+	iounmap(priv->mfunc.comm);
+err_vhcr:
+	dma_free_coherent(&(dev->pdev->dev), PAGE_SIZE,
+					     priv->mfunc.vhcr,
+					     priv->mfunc.vhcr_dma);
+	priv->mfunc.vhcr = NULL;
+	return -ENOMEM;
+}
+
 int mlx4_cmd_init(struct mlx4_dev *dev)
 {
 	struct mlx4_priv *priv = mlx4_priv(dev);
@@ -1418,6 +1565,27 @@ err_hcr:
 	return -ENOMEM;
 }
 
+void mlx4_multi_func_cleanup(struct mlx4_dev *dev)
+{
+	struct mlx4_priv *priv = mlx4_priv(dev);
+	int i, port;
+
+	if (mlx4_is_master(dev)) {
+		flush_workqueue(priv->mfunc.master.comm_wq);
+		destroy_workqueue(priv->mfunc.master.comm_wq);
+		for (i = 0; i < dev->num_slaves; i++) {
+			for (port = 1; port <= MLX4_MAX_PORTS; port++)
+				kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]);
+		}
+		kfree(priv->mfunc.master.slave_state);
+		iounmap(priv->mfunc.comm);
+		dma_free_coherent(&(dev->pdev->dev), PAGE_SIZE,
+						     priv->mfunc.vhcr,
+						     priv->mfunc.vhcr_dma);
+		priv->mfunc.vhcr = NULL;
+	}
+}
+
 void mlx4_cmd_cleanup(struct mlx4_dev *dev)
 {
 	struct mlx4_priv *priv = mlx4_priv(dev);
drivers/net/ethernet/mellanox/mlx4/fw.c +67 -1

80 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx4/fw.h +2 -0
index d9a0032..358c5eb 100644
@@ -160,6 +160,7 @@ struct mlx4_init_hca_param {
 	u8  log_mc_table_sz;
 	u8  log_mpt_sz;
 	u8  log_uar_sz;
+	u8  uar_page_sz; /* log pg sz in 4k chunks */
 };
 
 struct mlx4_init_ib_param {
@@ -196,6 +197,7 @@ int mlx4_RUN_FW(struct mlx4_dev *dev);
 int mlx4_QUERY_FW(struct mlx4_dev *dev);
 int mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter);
 int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
+int mlx4_QUERY_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param);
 int mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic);
 int mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt);
 int mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages);
drivers/net/ethernet/mellanox/mlx4/main.c +682 -154

1,113 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx4/mlx4.h +6 -0
index 879f825..3921dbf 100644
@@ -49,6 +49,7 @@
 #include <linux/mlx4/cmd.h>
 
 #define DRV_NAME	"mlx4_core"
+#define PFX		DRV_NAME ": "
 #define DRV_VERSION	"1.0"
 #define DRV_RELDATE	"July 14, 2011"
 
@@ -957,10 +958,15 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
 
 int mlx4_cmd_init(struct mlx4_dev *dev);
 void mlx4_cmd_cleanup(struct mlx4_dev *dev);
+int mlx4_multi_func_init(struct mlx4_dev *dev);
+void mlx4_multi_func_cleanup(struct mlx4_dev *dev);
 void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
 int mlx4_cmd_use_events(struct mlx4_dev *dev);
 void mlx4_cmd_use_polling(struct mlx4_dev *dev);
 
+int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
+		  unsigned long timeout);
+
 void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
 void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
 
include/linux/mlx4/cmd.h +2 -0
index 67e6848..ecb5dbe 100644
@@ -220,4 +220,6 @@ void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbo
 
 u32 mlx4_comm_get_version(void);
 
+#define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8)
+
 #endif /* MLX4_CMD_H */
include/linux/mlx4/device.h +1 -0
index 65bb466..4aaa90f 100644
@@ -489,6 +489,7 @@ struct mlx4_dev {
 	struct radix_tree_root	qp_table_tree;
 	u8			rev_id;
 	char			board_id[MLX4_BOARD_ID_LEN];
+	int			sr_iov;
 };
 
 struct mlx4_init_port_param {
Signature · 10 lines
1.7.7





--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4ED8A636.40901-VPRAkNaXOzVS1MOuV/[email protected]

#2 lore raw
Quoted 14 lines

 #ifdef CONFIG_PCI_IOV

drivers/net/ethernet/mellanox/mlx4/main.c +9 -0
+
+static int sr_iov;
+module_param(sr_iov, int, 0444);
+MODULE_PARM_DESC(sr_iov, "enable #sr_iov functions if sr_iov > 0");
+
+static int probe_vf;
+module_param(probe_vf, int, 0444);
+MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (sr_iov > 0)");
+

 int mlx4_log_num_mgm_entry_size = 10; module_param_named(log_num_mgm_entry_size, mlx4_log_num_mgm_entry_size, int, 0444);

drivers/net/ethernet/mellanox/mlx4/main.c MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num" · line 101

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx4/main.c +2 -0
@@ -85,24 +95,30 @@ MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num"
                                         " log_num_mgm_entry_size <= 12");
 
  #else /* CONFIG_PCI_IOV */
+static int sr_iov;
+#define probe_vf 0
  int mlx4_log_num_mgm_entry_size = 9;
  #endif /* CONFIG_PCI_IOV */

I don't think it's a good idea to put module parameters inside an #ifdef. Then depending on the
kernel config someone compiles with, their modprobe.conf may or may not break.

drivers/net/ethernet/mellanox/mlx4/main.c int log_mtts_per_seg = ilog2(MLX4_MTT_ENTRY_PER_SEG); · line 143

Quoted 4 lines
drivers/net/ethernet/mellanox/mlx4/main.c +4 -0
+static int port_type_array[2] = {1, 1};
+static int arr_argc = 2;
+module_param_array(port_type_array, int, &arr_argc, 0444);
+MODULE_PARM_DESC(port_type_array, "Array of port types: IB by default");

Is this really the best way to pass this in? What if I have two adapters, and I want to use
the first one for IB and the second for ethernet? (Which doesn't sound like a particularly
obscure config)

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAL1RGDV8LzSOei=aQW7VXUP=G+9qdO+Y4eKZu8mBuHJuUp8UuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 10 lines · Roland Dreier
Quoted 5 lines

 #else /* CONFIG_PCI_IOV */

(quoted diff) +2 -0
+static int sr_iov;
+#define probe_vf 0

 int mlx4_log_num_mgm_entry_size = 9;
 #endif /* CONFIG_PCI_IOV */

I don't think it's a good idea to put module parameters inside an #ifdef.  Then depending on the
kernel config someone compiles with, their modprobe.conf may or may not break.

I agree. I will change this so that the module parameters are always there.

If the kernel is not configured to support IOV, pci_enable_sriov will fail. Currently, we abort the device startup. I can change this to simply continue without sriov enabled:
======================================================

mlx4_core: fix sriov module parameters

Always have the sr_iov module parameters (even if the kernel is not compiled with sriov support). Change device startup logic so that if pci_enable_sriov() fails, the PF-driver continues to bring up the device, but in non-sriov mode.

---
Roland,
I will roll this change into the original patch set, so that V1 will contain this code.

drivers/net/ethernet/mellanox/mlx4/main.c +12 -14
Index: net-next/drivers/net/ethernet/mellanox/mlx4/main.c
===================================================================
@@ -76,8 +76,6 @@ MODULE_PARM_DESC(msi_x, "attempt to use 
 
 #endif /* CONFIG_PCI_MSI */
 
-#ifdef CONFIG_PCI_IOV
-
 static int sr_iov;
 module_param(sr_iov, int, 0444);
 MODULE_PARM_DESC(sr_iov, "enable #sr_iov functions if sr_iov > 0");
@@ -94,12 +92,6 @@ MODULE_PARM_DESC(log_num_mgm_entry_size,
 					 " 10 gives 248.range: 9<="
 					 " log_num_mgm_entry_size <= 12");
 
-#else /* CONFIG_PCI_IOV */
-static int sr_iov;
-#define probe_vf 0
-int mlx4_log_num_mgm_entry_size = 9;
-#endif /* CONFIG_PCI_IOV */
-
 #define MLX4_VF					(1 << 0)
 
 #define HCA_GLOBAL_CAP_MASK	0
@@ -1732,13 +1724,19 @@ static int __mlx4_init_one(struct pci_de
 
 		if (sr_iov) {
 			mlx4_warn(dev, "Enabling sriov with:%d vfs\n", sr_iov);
-			if (pci_enable_sriov(pdev, sr_iov)) {
-				mlx4_err(dev, "Failed to enable sriov, aborting.\n");
-				goto err_rel_own;
+			err = pci_enable_sriov(pdev, sr_iov);
+			if (err) {
+				mlx4_err(dev, "Failed to enable sriov,"
+					 "continuing without sriov enabled"
+					 " (err = %d).\n", err);
+				sr_iov = 0;
+				err = 0;
+			} else {
+				mlx4_warn(dev, "Running in master mode\n");
+				dev->flags |= MLX4_FLAG_SRIOV |
+					MLX4_FLAG_MASTER;
+				dev->sr_iov = sr_iov;
 			}
-			mlx4_warn(dev, "Running in master mode\n");
-			dev->flags |= MLX4_FLAG_SRIOV | MLX4_FLAG_MASTER;
-			dev->sr_iov = sr_iov;
 		}
 
 		/*

- Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 201112041629.41466.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#6 lore raw
Quoted 1 line · Jack Morgenstein

If the kernel is not configured to support IOV, pci_enable_sriov will fail.

Jack,

If CONFIG_PCI_IOV isn't set, pci_enable_sriov isn't there...

Or.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4EDB942F.1020101-VPRAkNaXOzVWk0Htik3J/[email protected]

#8 lore raw
Quoted 9 lines · Or Gerlitz
Quoted 2 lines · Jack Morgenstein

If the kernel is not configured to support IOV, pci_enable_sriov will fail.

Jack,

If CONFIG_PCI_IOV isn't set, pci_enable_sriov isn't there...

Or.

Not so. I checked. If CONFIG_PCI_IOV isn't set, pci_enable_sriov returns -ENODEV via a static inline function.
Look in kernel file include/linux/pci.h (for the most recent kernel):

#ifdef CONFIG_PCI_IOV
extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); extern void pci_disable_sriov(struct pci_dev *dev);
extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); extern int pci_num_vf(struct pci_dev *dev);
#else
static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)

{
        return -ENODEV;
}

static inline void pci_disable_sriov(struct pci_dev *dev) {
}
static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)

{
        return IRQ_NONE;
}
static inline int pci_num_vf(struct pci_dev *dev)
{
        return 0;
}

#endif

- Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 201112050919.39280.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#10 lore raw
Quoted 3 lines · Jack Morgenstein

If CONFIG_PCI_IOV isn't set, pci_enable_sriov isn't there...

Not so. I checked. If CONFIG_PCI_IOV isn't set, pci_enable_sriov returns -ENODEV via a static inline function. Look in kernel file include/linux/pci.h (for the most recent kernel)

Sure, sorry, my bad, thanks for clarifying this out.

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
In reply to a message not in the archive
Quoted 3 lines · Jack Morgenstein

If the kernel is not configured to support IOV, pci_enable_sriov will fail. Currently, we abort the device startup.  I can change this to simply continue without sriov enabled:

Agree... we definitely don't want drivers failing just because a device has an SR-IOV
cap but the kernel isn't compiled with SR-IOV support.

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
In reply to a message not in the archive
Quoted 4 lines · Yevgeny Petrilin

From: Jack Morgenstein <[email protected]>

1. Added module parameters sr_iov and probe_vf for controlling enablement of SRIOV mode.

This sort of option is useful in many drivers, and ideally would be specified in some generic way rather than a module parameters. However I can't see a good way to make it configurable after the net device is registered.

Currently the in-tree drivers have:

be2net: num_vfs
cxgb4:  num_vfs [array]
igb:    max_vfs
ixgbe:  max_vfs

Consider renaming 'sr_iov' to one of the above rather than adding to the variation.

The 'probe_vf' parameter is very odd. Why do you think it is necessary to make this a module parameter? It should be possible to bind and unbind the driver from each VF dynamically via sysfs but this parameter appears to restrict that.

[...]

Quoted 6 lines

3. Added port_type_array as a module parameter to allow driver startup with ports configured as desired.
In SRIOV mode, only ETH is supported, and this array is ignored; otherwise, for the case where the FW supports both port types (ETH and IB), the port_type_array parameter is used.
By default, the port_type_array is set to configure both ports as IB.

[...]

You seem to be saying that this can be reconfigured after startup - in which case is the module parameter really necessary? Maybe I misunderstand.

Ben.

Signature · 8 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw
Quoted 8 lines
Quoted 2 lines

1. Added module parameters sr_iov and probe_vf for controlling enablement of SRIOV mode.

This sort of option is useful in many drivers, and ideally would be specified in some generic way rather than a module parameters. However I can't see a good way to make it configurable after the net device is registered.

Quoted 8 lines

Currently the in-tree drivers have:

be2net: num_vfs
cxgb4:  num_vfs [array]
igb:    max_vfs
ixgbe:  max_vfs

Consider renaming 'sr_iov' to one of the above rather than adding to the variation.

Good point, we probably should rename it.

Quoted 6 lines

The 'probe_vf' parameter is very odd. Why do you think it is necessary to make this a module parameter? It should be possible to bind and unbind the driver from each VF dynamically via sysfs but this parameter appears to restrict that.

We have same driver acting both as VF and PF, so once the VFs are being created (pci_enable_sriov), The probe function is being called for all of them.
In many cases this is not what we want, but rather pass the vfs to guest OS.
The module parameter is meant to ease the life of the administrator.

Quoted 11 lines

[...]

Quoted 6 lines

3. Added port_type_array as a module parameter to allow driver startup with ports configured as desired.
In SRIOV mode, only ETH is supported, and this array is ignored; otherwise, for the case where the FW supports both port types (ETH and IB), the port_type_array parameter is used.
By default, the port_type_array is set to configure both ports as IB.

[...]

You seem to be saying that this can be reconfigured after startup - in which case is the module parameter really necessary? Maybe I misunderstand.

In SRIOV mode we don't allow dynamic link layer type changes, so the type is set by module parameter.

Thanks,
Yevgeny

#14 lore raw
In reply to Ben Hutchings
Quoted 5 lines · Ben Hutchings

The 'probe_vf' parameter is very odd.  Why do you think it is necessary to make this a module parameter?  It should be possible to bind and unbind the driver from each VF dynamically via sysfs but this parameter appears to restrict that.

The host which sees the PF will also see all the VFs once they come up. As each VF appears (as seen by 'lspci'), the O/S will invoke the "probe" method for that VF. Without the "probe_vf" parameter, this probe would result in all the VFs being bound to the PF host (and thus unavailable for guests).

The small section of code which makes use of the probe_vf parameter (file net/ethernet/mellanox/mlx4_main.c):

	/* Detect if this device is a virtual function */
	if (id && id->driver_data & MLX4_VF) {
		/* When acting as pf, we normally skip vfs unless explicitly
		 * requested to probe them. */
		if (sr_iov && extended_func_num(pdev) > probe_vf) {
			mlx4_warn(dev, "Skipping virtual function:%d\n",
						extended_func_num(pdev));
			err = -ENODEV;
			goto err_free_dev;
		}

If you invoke "dmesg" on the PF host, you will see a series of the "Skipping... " messages, one per VF. If probe_vf > 0, the PF-host will reserve some VFs for its own use, and not issue the "Skipping..." message for those VFs.

-Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 201112061035.54093.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#16 lore raw
Quoted 11 lines · Jack Morgenstein
Quoted 5 lines · Ben Hutchings

The 'probe_vf' parameter is very odd. Why do you think it is necessary to make this a module parameter? It should be possible to bind and unbind the driver from each VF dynamically via sysfs but this parameter appears to restrict that.

The host which sees the PF will also see all the VFs once they come up. As each VF appears (as seen by 'lspci'), the O/S will invoke the "probe" method for that VF. Without the "probe_vf" parameter, this probe would result in all the VFs being bound to the PF host (and thus unavailable for guests).

As I said, you can unbind it through sysfs.

Quoted 2 lines

The small section of code which makes use of the probe_vf parameter (file net/ethernet/mellanox/mlx4_main.c):

Yes, I get it.

Quoted 11 lines
	/* Detect if this device is a virtual function */
	if (id && id->driver_data & MLX4_VF) {
		/* When acting as pf, we normally skip vfs unless explicitly
		 * requested to probe them. */
		if (sr_iov && extended_func_num(pdev) > probe_vf) {
			mlx4_warn(dev, "Skipping virtual function:%d\n",
						extended_func_num(pdev));
			err = -ENODEV;
			goto err_free_dev;
		}
Quoted 4 lines

If you invoke "dmesg" on the PF host, you will see a series of the "Skipping... " messages, one per VF. If probe_vf > 0, the PF-host will reserve some VFs for its own use, and not issue the "Skipping..." message for those VFs.

What if you want to change that later? You can't use those VFs in the PF-host without reloading the driver.

Ben.

Signature · 8 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html