diff mbox

[net-next,V0,19/21] mlx4_core: Modify driver initialization flow to accommodate SRIOV for Ethernet

Message ID 201112041629.41466.jackm@dev.mellanox.co.il
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

jackm Dec. 4, 2011, 2:29 p.m. UTC
On Friday 02 December 2011 19:51, Roland Dreier wrote:
> >  #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.
> 
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:


- Jack
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Or Gerlitz Dec. 4, 2011, 3:39 p.m. UTC | #1
On 12/4/2011 4:29 PM, Jack Morgenstein wrote:
> 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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
jackm Dec. 5, 2011, 7:19 a.m. UTC | #2
On Sunday 04 December 2011 17:39, Or Gerlitz wrote:
> On 12/4/2011 4:29 PM, Jack Morgenstein wrote:
> > 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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Or Gerlitz Dec. 5, 2011, 7:40 a.m. UTC | #3
On 12/5/2011 9:19 AM, Jack Morgenstein wrote:
> 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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roland Dreier Dec. 5, 2011, 7:01 p.m. UTC | #4
On Sun, Dec 4, 2011 at 6:29 AM, Jack Morgenstein
<jackm@dev.mellanox.co.il> wrote:
> 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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

======================================================

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.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>

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


Index: net-next/drivers/net/ethernet/mellanox/mlx4/main.c
===================================================================
--- net-next.orig/drivers/net/ethernet/mellanox/mlx4/main.c	2011-12-04 10:38:52.000000000 +0200
+++ net-next/drivers/net/ethernet/mellanox/mlx4/main.c	2011-12-04 16:23:33.000000000 +0200
@@ -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;
 		}
 
 		/*