All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes
@ 2016-06-14  9:09 Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 1/3] cxgb4: Force cxgb4 driver as MASTER in kdump kernel Hariprasad Shenai
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hariprasad Shenai @ 2016-06-14  9:09 UTC (permalink / raw)
  To: davem; +Cc: netdev, nirranjan, Hariprasad Shenai

Hi,

This series adds support to configure SR-IOV via PCI sysfs interface,
reduces resource allocation in kdump kernel by disabling offload. Also
synchronize unicast and multicast mac address, even in the interface is in
Promiscuous mode.

This patch series has been created against net-next tree and includes
patches on cxgb4 and cxgb4vf driver.

We have included all the maintainers of respective drivers. Kindly review
the change and let us know in case of any review comments.

Thanks


Hariprasad Shenai (3):
  cxgb4: Force cxgb4 driver as MASTER in kdump kernel
  cxgb4: Enable SR-IOV configuration via PCI sysfs interface
  cxgb4/cxgb4vf: Synchronize all MAC addresses

 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c    | 82 +++++++++++++++++++---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    |  8 +--
 2 files changed, 76 insertions(+), 14 deletions(-)

-- 
2.3.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] cxgb4: Force cxgb4 driver as MASTER in kdump kernel
  2016-06-14  9:09 [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes Hariprasad Shenai
@ 2016-06-14  9:09 ` Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 2/3] cxgb4: Enable SR-IOV configuration via PCI sysfs interface Hariprasad Shenai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hariprasad Shenai @ 2016-06-14  9:09 UTC (permalink / raw)
  To: davem; +Cc: netdev, nirranjan, Hariprasad Shenai

When is_kdump_kernel() is true, Forcing cxgb4 driver as Master so we can
reinitialize the Firmware/Chip. Also reduce memory usage by disabling
offload.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 477db477b133..c045f65d4106 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -64,6 +64,7 @@
 #include <net/bonding.h>
 #include <net/addrconf.h>
 #include <asm/uaccess.h>
+#include <linux/crash_dump.h>
 
 #include "cxgb4.h"
 #include "t4_regs.h"
@@ -3735,7 +3736,8 @@ static int adap_init0(struct adapter *adap)
 		return ret;
 
 	/* Contact FW, advertising Master capability */
-	ret = t4_fw_hello(adap, adap->mbox, adap->mbox, MASTER_MAY, &state);
+	ret = t4_fw_hello(adap, adap->mbox, adap->mbox,
+			  is_kdump_kernel() ? MASTER_MUST : MASTER_MAY, &state);
 	if (ret < 0) {
 		dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
 			ret);
@@ -4366,6 +4368,11 @@ static void cfg_queues(struct adapter *adap)
 	if (q10g > netif_get_num_default_rss_queues())
 		q10g = netif_get_num_default_rss_queues();
 
+	/* Reduce memory usage in kdump environment, disable all offload.
+	 */
+	if (is_kdump_kernel())
+		adap->params.offload = 0;
+
 	for_each_port(adap, i) {
 		struct port_info *pi = adap2pinfo(adap, i);
 
-- 
2.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] cxgb4: Enable SR-IOV configuration via PCI sysfs interface
  2016-06-14  9:09 [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 1/3] cxgb4: Force cxgb4 driver as MASTER in kdump kernel Hariprasad Shenai
@ 2016-06-14  9:09 ` Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 3/3] cxgb4/cxgb4vf: Synchronize all MAC addresses Hariprasad Shenai
  2016-06-15 21:46 ` [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Hariprasad Shenai @ 2016-06-14  9:09 UTC (permalink / raw)
  To: davem; +Cc: netdev, nirranjan, Hariprasad Shenai

Implement callback in the driver for the new PCI bus driver
interface that allows the user to enable/disable SR-IOV
virtual functions in a device via the sysfs interface.

Deprecate module parameter used to configure SRIOV

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 66 ++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c045f65d4106..6ce4344ea6fb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -207,7 +207,7 @@ static int rx_dma_offset = 2;
 static unsigned int num_vf[NUM_OF_PF_WITH_SRIOV];
 
 module_param_array(num_vf, uint, NULL, 0644);
-MODULE_PARM_DESC(num_vf, "number of VFs for each of PFs 0-3");
+MODULE_PARM_DESC(num_vf, "number of VFs for each of PFs 0-3, deprecated parameter - please use the pci sysfs interface.");
 #endif
 
 /* TX Queue select used to determine what algorithm to use for selecting TX
@@ -4836,6 +4836,60 @@ static int get_chip_type(struct pci_dev *pdev, u32 pl_rev)
 	return -EINVAL;
 }
 
+#ifdef CONFIG_PCI_IOV
+static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)
+{
+	int err = 0;
+	int current_vfs = pci_num_vf(pdev);
+	u32 pcie_fw;
+	void __iomem *regs;
+
+	regs = pci_ioremap_bar(pdev, 0);
+	if (!regs) {
+		dev_err(&pdev->dev, "cannot map device registers\n");
+		return -ENOMEM;
+	}
+
+	pcie_fw = readl(regs + PCIE_FW_A);
+	iounmap(regs);
+	/* Check if cxgb4 is the MASTER and fw is initialized */
+	if (!(pcie_fw & PCIE_FW_INIT_F) ||
+	    !(pcie_fw & PCIE_FW_MASTER_VLD_F) ||
+	    PCIE_FW_MASTER_G(pcie_fw) != 4) {
+		dev_warn(&pdev->dev,
+			 "cxgb4 driver needs to be MASTER to support SRIOV\n");
+		return -EOPNOTSUPP;
+	}
+
+	/* If any of the VF's is already assigned to Guest OS, then
+	 * SRIOV for the same cannot be modified
+	 */
+	if (current_vfs && pci_vfs_assigned(pdev)) {
+		dev_err(&pdev->dev,
+			"Cannot modify SR-IOV while VFs are assigned\n");
+		num_vfs = current_vfs;
+		return num_vfs;
+	}
+
+	/* Disable SRIOV when zero is passed.
+	 * One needs to disable SRIOV before modifying it, else
+	 * stack throws the below warning:
+	 * " 'n' VFs already enabled. Disable before enabling 'm' VFs."
+	 */
+	if (!num_vfs) {
+		pci_disable_sriov(pdev);
+		return num_vfs;
+	}
+
+	if (num_vfs != current_vfs) {
+		err = pci_enable_sriov(pdev, num_vfs);
+		if (err)
+			return err;
+	}
+	return num_vfs;
+}
+#endif
+
 static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int func, i, err, s_qpp, qpp, num_seg;
@@ -5169,11 +5223,16 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 sriov:
 #ifdef CONFIG_PCI_IOV
-	if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
+	if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0) {
+		dev_warn(&pdev->dev,
+			 "Enabling SR-IOV VFs using the num_vf module "
+			 "parameter is deprecated - please use the pci sysfs "
+			 "interface instead.\n");
 		if (pci_enable_sriov(pdev, num_vf[func]) == 0)
 			dev_info(&pdev->dev,
 				 "instantiated %u virtual functions\n",
 				 num_vf[func]);
+	}
 #endif
 	return 0;
 
@@ -5266,6 +5325,9 @@ static struct pci_driver cxgb4_driver = {
 	.probe    = init_one,
 	.remove   = remove_one,
 	.shutdown = remove_one,
+#ifdef CONFIG_PCI_IOV
+	.sriov_configure = cxgb4_iov_configure,
+#endif
 	.err_handler = &cxgb4_eeh,
 };
 
-- 
2.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] cxgb4/cxgb4vf: Synchronize all MAC addresses
  2016-06-14  9:09 [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 1/3] cxgb4: Force cxgb4 driver as MASTER in kdump kernel Hariprasad Shenai
  2016-06-14  9:09 ` [PATCH net-next 2/3] cxgb4: Enable SR-IOV configuration via PCI sysfs interface Hariprasad Shenai
@ 2016-06-14  9:09 ` Hariprasad Shenai
  2016-06-15 21:46 ` [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Hariprasad Shenai @ 2016-06-14  9:09 UTC (permalink / raw)
  To: davem; +Cc: netdev, nirranjan, Hariprasad Shenai

Even if interface is in Promiscuous mode/Allmulti mode synchronize
MAC addresses.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c     | 7 ++-----
 drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 8 ++------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 6ce4344ea6fb..c45de49dc963 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -461,11 +461,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
 	struct port_info *pi = netdev_priv(dev);
 	struct adapter *adapter = pi->adapter;
 
-	if (!(dev->flags & IFF_PROMISC)) {
-		__dev_uc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync);
-		if (!(dev->flags & IFF_ALLMULTI))
-			__dev_mc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync);
-	}
+	__dev_uc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync);
+	__dev_mc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync);
 
 	return t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu,
 			     (dev->flags & IFF_PROMISC) ? 1 : 0,
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 04fc6f6d1e25..8d9b2cb74aa2 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -937,12 +937,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
 {
 	struct port_info *pi = netdev_priv(dev);
 
-	if (!(dev->flags & IFF_PROMISC)) {
-		__dev_uc_sync(dev, cxgb4vf_mac_sync, cxgb4vf_mac_unsync);
-		if (!(dev->flags & IFF_ALLMULTI))
-			__dev_mc_sync(dev, cxgb4vf_mac_sync,
-				      cxgb4vf_mac_unsync);
-	}
+	__dev_uc_sync(dev, cxgb4vf_mac_sync, cxgb4vf_mac_unsync);
+	__dev_mc_sync(dev, cxgb4vf_mac_sync, cxgb4vf_mac_unsync);
 	return t4vf_set_rxmode(pi->adapter, pi->viid, -1,
 			       (dev->flags & IFF_PROMISC) != 0,
 			       (dev->flags & IFF_ALLMULTI) != 0,
-- 
2.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes
  2016-06-14  9:09 [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes Hariprasad Shenai
                   ` (2 preceding siblings ...)
  2016-06-14  9:09 ` [PATCH net-next 3/3] cxgb4/cxgb4vf: Synchronize all MAC addresses Hariprasad Shenai
@ 2016-06-15 21:46 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-06-15 21:46 UTC (permalink / raw)
  To: hariprasad; +Cc: netdev, nirranjan

From: Hariprasad Shenai <hariprasad@chelsio.com>
Date: Tue, 14 Jun 2016 14:39:29 +0530

> This series adds support to configure SR-IOV via PCI sysfs interface,
> reduces resource allocation in kdump kernel by disabling offload. Also
> synchronize unicast and multicast mac address, even in the interface is in
> Promiscuous mode.
> 
> This patch series has been created against net-next tree and includes
> patches on cxgb4 and cxgb4vf driver.
> 
> We have included all the maintainers of respective drivers. Kindly review
> the change and let us know in case of any review comments.

A great example of why not to add module parameters to drivers.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-15 21:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14  9:09 [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes Hariprasad Shenai
2016-06-14  9:09 ` [PATCH net-next 1/3] cxgb4: Force cxgb4 driver as MASTER in kdump kernel Hariprasad Shenai
2016-06-14  9:09 ` [PATCH net-next 2/3] cxgb4: Enable SR-IOV configuration via PCI sysfs interface Hariprasad Shenai
2016-06-14  9:09 ` [PATCH net-next 3/3] cxgb4/cxgb4vf: Synchronize all MAC addresses Hariprasad Shenai
2016-06-15 21:46 ` [PATCH net-next 0/3] Add SRIOV configuration via sysfs and few fixes David Miller

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.