All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Assmann <sassmann@kpanic.de>
To: mcgrof@kernel.org
Cc: backports@vger.kernel.org, hauke@hauke-m.de, sassmann@kpanic.de
Subject: [PATCH RFC 04/10] backports: igb fixes for linux-3.7
Date: Thu, 12 Dec 2013 10:27:56 +0100	[thread overview]
Message-ID: <1386840482-585-5-git-send-email-sassmann@kpanic.de> (raw)
In-Reply-To: <1386840482-585-1-git-send-email-sassmann@kpanic.de>

- add pci_sriov_set_totalvfs()
- add patches/collateral-evolutions/network/82-ethernet/igb_pci_sriov_configure.patch

Thought of backporting struct pci_driver like this:
struct backport_pci_driver {
[...]
};
but that introduces the following.
  CC [M]  /dev/shm/next/drivers/net/ethernet/intel/igb/igb_main.o
/dev/shm/next/drivers/net/ethernet/intel/igb/igb_main.c: In function ‘igb_init_module’:
/dev/shm/next/drivers/net/ethernet/intel/igb/igb_main.c:698: warning: passing argument 1 of ‘__pci_register_driver’ from incompatible pointer type
include/linux/pci.h:1002: note: expected ‘struct pci_driver *’ but argument is of type ‘struct backport_pci_driver *’
/dev/shm/next/drivers/net/ethernet/intel/igb/igb_main.c: In function ‘igb_exit_module’:
/dev/shm/next/drivers/net/ethernet/intel/igb/igb_main.c:715: warning: passing argument 1 of ‘pci_unregister_driver’ from incompatible pointer type
include/linux/pci.h:1011: note: expected ‘struct pci_driver *’ but argument is of type ‘struct backport_pci_driver *’
Adding these as well would drag along several pci dependencies and I'm not sure
this is really safe. Opinions?

For now I've just commented out the code.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 backport/backport-include/linux/pci.h              |  5 +++-
 backport/compat/compat-3.8.c                       | 32 ++++++++++++++++++++++
 .../82-ethernet/igb_pci_sriov_configure.patch      | 14 ++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 patches/collateral-evolutions/network/82-ethernet/igb_pci_sriov_configure.patch

diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h
index b56761f..c3360f1 100644
--- a/backport/backport-include/linux/pci.h
+++ b/backport/backport-include/linux/pci.h
@@ -178,6 +178,10 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
 	.subvendor = (subvend), .subdevice = (subdev)
 #endif /* PCI_DEVICE_SUB */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
+int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
 /* Taken from drivers/pci/pci.h */
 struct pci_sriov {
@@ -202,5 +206,4 @@ struct pci_sriov {
 
 extern int pci_vfs_assigned(struct pci_dev *dev);
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
-
 #endif /* _BACKPORT_LINUX_PCI_H */
diff --git a/backport/compat/compat-3.8.c b/backport/compat/compat-3.8.c
index c6824bf..1404f29 100644
--- a/backport/compat/compat-3.8.c
+++ b/backport/compat/compat-3.8.c
@@ -18,6 +18,8 @@
 #include <linux/netdevice.h>
 #include <linux/random.h>
 #include <linux/of.h>
+#include <linux/pci.h>
+#include <linux/pci_regs.h>
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8))
 void netdev_set_default_ethtool_ops(struct net_device *dev,
@@ -514,3 +516,33 @@ int of_property_read_u8_array(const struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_property_read_u8_array);
 #endif /* CONFIG_OF */
+
+/**
+ * pci_sriov_set_totalvfs -- reduce the TotalVFs available
+ * @dev: the PCI PF device
+ * @numvfs: number that should be used for TotalVFs supported
+ *
+ * Should be called from PF driver's probe routine with
+ * device's mutex held.
+ *
+ * Returns 0 if PF is an SRIOV-capable device and
+ * value of numvfs valid. If not a PF return -ENOSYS;
+ * if numvfs is invalid return -EINVAL;
+ * if VFs already enabled, return -EBUSY.
+ */
+int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
+{
+	if (!dev->is_physfn)
+		return -ENOSYS;
+	if (numvfs > dev->sriov->total_VFs)
+		return -EINVAL;
+
+	/* Shouldn't change if VFs already enabled */
+	if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE)
+		return -EBUSY;
+	else
+		dev->sriov->driver_max_VFs = numvfs;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs);
diff --git a/patches/collateral-evolutions/network/82-ethernet/igb_pci_sriov_configure.patch b/patches/collateral-evolutions/network/82-ethernet/igb_pci_sriov_configure.patch
new file mode 100644
index 0000000..bd9b3dd
--- /dev/null
+++ b/patches/collateral-evolutions/network/82-ethernet/igb_pci_sriov_configure.patch
@@ -0,0 +1,14 @@
+diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
+index f2a5abf..433463d 100644
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -249,7 +249,9 @@ static struct pci_driver igb_driver = {
+ 	.driver.pm = &igb_pm_ops,
+ #endif
+ 	.shutdown = igb_shutdown,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+ 	.sriov_configure = igb_pci_sriov_configure,
++#endif
+ 	.err_handler = &igb_err_handler
+ };
+ 
-- 
1.8.3.1


  parent reply	other threads:[~2013-12-12  9:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12  9:27 [PATCH RFC 00/10] backports: add igb driver Stefan Assmann
2013-12-12  9:27 ` [PATCH RFC 01/10] backports: add igb ethernet network driver Stefan Assmann
2013-12-13  0:27   ` Hauke Mehrtens
2013-12-13  7:39     ` Stefan Assmann
2013-12-12  9:27 ` [PATCH RFC 02/10] backports: igb fixes for linux-3.9 Stefan Assmann
2013-12-12  9:27 ` [PATCH RFC 03/10] backports: igb fixes for linux-3.8 Stefan Assmann
2013-12-12  9:27 ` Stefan Assmann [this message]
2013-12-12  9:27 ` [PATCH RFC 05/10] backports: igb fixes for linux-3.6 Stefan Assmann
2013-12-13  0:46   ` Hauke Mehrtens
2013-12-13  8:01     ` Stefan Assmann
2013-12-12  9:27 ` [PATCH RFC 06/10] backports: igb fixes for linux-3.5 Stefan Assmann
2013-12-12  9:27 ` [PATCH RFC 07/10] backports: igb fixes for linux-3.4 Stefan Assmann
2013-12-12  9:28 ` [PATCH RFC 08/10] backports: igb fixes for linux-3.3 Stefan Assmann
2013-12-12  9:28 ` [PATCH RFC 09/10] backports: igb fixes for linux-3.2 Stefan Assmann
2013-12-12  9:28 ` [PATCH RFC 10/10] backports: igb fixes for linux-3.1 Stefan Assmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386840482-585-5-git-send-email-sassmann@kpanic.de \
    --to=sassmann@kpanic.de \
    --cc=backports@vger.kernel.org \
    --cc=hauke@hauke-m.de \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.