Commit 60100978 authored by David S. Miller's avatar David S. Miller

Merge branch 'cxgb4-sriov-sysfs'

Hariprasad Shenai says:

====================
Add SRIOV configuration via sysfs and few fixes

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.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 88da48f4 d01f7abc
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include <net/bonding.h> #include <net/bonding.h>
#include <net/addrconf.h> #include <net/addrconf.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/crash_dump.h>
#include "cxgb4.h" #include "cxgb4.h"
#include "t4_regs.h" #include "t4_regs.h"
...@@ -206,7 +207,7 @@ static int rx_dma_offset = 2; ...@@ -206,7 +207,7 @@ static int rx_dma_offset = 2;
static unsigned int num_vf[NUM_OF_PF_WITH_SRIOV]; static unsigned int num_vf[NUM_OF_PF_WITH_SRIOV];
module_param_array(num_vf, uint, NULL, 0644); 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 #endif
/* TX Queue select used to determine what algorithm to use for selecting TX /* TX Queue select used to determine what algorithm to use for selecting TX
...@@ -460,11 +461,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok) ...@@ -460,11 +461,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
struct port_info *pi = netdev_priv(dev); struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter; struct adapter *adapter = pi->adapter;
if (!(dev->flags & IFF_PROMISC)) {
__dev_uc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync); __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_mc_sync(dev, cxgb4_mac_sync, cxgb4_mac_unsync);
}
return t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, return t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu,
(dev->flags & IFF_PROMISC) ? 1 : 0, (dev->flags & IFF_PROMISC) ? 1 : 0,
...@@ -3735,7 +3733,8 @@ static int adap_init0(struct adapter *adap) ...@@ -3735,7 +3733,8 @@ static int adap_init0(struct adapter *adap)
return ret; return ret;
/* Contact FW, advertising Master capability */ /* 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) { if (ret < 0) {
dev_err(adap->pdev_dev, "could not connect to FW, error %d\n", dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
ret); ret);
...@@ -4366,6 +4365,11 @@ static void cfg_queues(struct adapter *adap) ...@@ -4366,6 +4365,11 @@ static void cfg_queues(struct adapter *adap)
if (q10g > netif_get_num_default_rss_queues()) if (q10g > netif_get_num_default_rss_queues())
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) { for_each_port(adap, i) {
struct port_info *pi = adap2pinfo(adap, i); struct port_info *pi = adap2pinfo(adap, i);
...@@ -4829,6 +4833,60 @@ static int get_chip_type(struct pci_dev *pdev, u32 pl_rev) ...@@ -4829,6 +4833,60 @@ static int get_chip_type(struct pci_dev *pdev, u32 pl_rev)
return -EINVAL; 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) static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
int func, i, err, s_qpp, qpp, num_seg; int func, i, err, s_qpp, qpp, num_seg;
...@@ -5162,11 +5220,16 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -5162,11 +5220,16 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
sriov: sriov:
#ifdef CONFIG_PCI_IOV #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) if (pci_enable_sriov(pdev, num_vf[func]) == 0)
dev_info(&pdev->dev, dev_info(&pdev->dev,
"instantiated %u virtual functions\n", "instantiated %u virtual functions\n",
num_vf[func]); num_vf[func]);
}
#endif #endif
return 0; return 0;
...@@ -5259,6 +5322,9 @@ static struct pci_driver cxgb4_driver = { ...@@ -5259,6 +5322,9 @@ static struct pci_driver cxgb4_driver = {
.probe = init_one, .probe = init_one,
.remove = remove_one, .remove = remove_one,
.shutdown = remove_one, .shutdown = remove_one,
#ifdef CONFIG_PCI_IOV
.sriov_configure = cxgb4_iov_configure,
#endif
.err_handler = &cxgb4_eeh, .err_handler = &cxgb4_eeh,
}; };
......
...@@ -937,12 +937,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok) ...@@ -937,12 +937,8 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
{ {
struct port_info *pi = netdev_priv(dev); struct port_info *pi = netdev_priv(dev);
if (!(dev->flags & IFF_PROMISC)) {
__dev_uc_sync(dev, cxgb4vf_mac_sync, cxgb4vf_mac_unsync); __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_mc_sync(dev, cxgb4vf_mac_sync,
cxgb4vf_mac_unsync);
}
return t4vf_set_rxmode(pi->adapter, pi->viid, -1, return t4vf_set_rxmode(pi->adapter, pi->viid, -1,
(dev->flags & IFF_PROMISC) != 0, (dev->flags & IFF_PROMISC) != 0,
(dev->flags & IFF_ALLMULTI) != 0, (dev->flags & IFF_ALLMULTI) != 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment