From: Greg Rose <gregory.v.rose@intel.com>
To: netdev@vger.kernel.org
Subject: [RFC PATCH V2 2/2] ixgbe: Add support for new ethtool IOV configuration commands
Date: Thu, 22 Sep 2011 14:35:28 -0700 [thread overview]
Message-ID: <20110922213527.26654.48496.stgit@gitlad.jf.intel.com> (raw)
In-Reply-To: <20110922213522.26654.59301.stgit@gitlad.jf.intel.com>
Implement driver support for the new ethtool command to configure
the number of VFs per PF independently. The framework is in place
for support of two other features that allow the user to partition
some of the I/O resources of the device to additional semi-independent
net devices and to set the number of queues per VF.
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 1
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 110 ++++++++++++++++++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +
3 files changed, 113 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 8fab322..cea2323 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -528,6 +528,7 @@ struct ixgbe_adapter {
int fdir_filter_count;
u32 timer_event_accumulator;
u32 vferr_refcount;
+ const struct ixgbe_info *saved_ii;
};
struct ixgbe_fdir_filter {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 08c9994..c695362 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -38,7 +38,7 @@
#include <linux/uaccess.h>
#include "ixgbe.h"
-
+#include "ixgbe_sriov.h"
#define IXGBE_ALL_RAR_ENTRIES 16
@@ -2577,6 +2577,112 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
return ret;
}
+static int ixgbe_reinit_sriov(struct net_device *netdev, int new_vfs)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+ struct pci_dev *pdev = adapter->pdev;
+ int err;
+ int i;
+
+ if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+ if (ixgbe_check_vf_assignment(adapter)) {
+ netdev_warn(netdev, "%s ",
+ "reconfigure of SR-IOV VFs "
+ "not supported while VFs are "
+ "assigned to guest VMs\n");
+ return -EBUSY;
+ }
+ }
+ if (netif_running(netdev)) {
+ netdev_warn(netdev, "%s",
+ "Cannot reconfigure SR-IOV "
+ "while interface is up\n"
+ "Please bring the interface "
+ "down first\n");
+ return -EBUSY;
+ }
+
+ ixgbe_clear_interrupt_scheme(adapter);
+
+ if (adapter->num_vfs)
+ ixgbe_disable_sriov(adapter);
+
+ adapter->num_vfs = (new_vfs > 63) ? 63 : new_vfs;
+
+ if (adapter->num_vfs) {
+ ixgbe_enable_sriov(adapter, adapter->saved_ii);
+ for (i = 0; i < adapter->num_vfs; i++)
+ ixgbe_vf_configuration(pdev, (i | 0x10000000));
+ }
+
+ if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+ adapter->flags &= ~(IXGBE_FLAG_RSS_ENABLED |
+ IXGBE_FLAG_DCB_ENABLED);
+ netdev->features &= ~NETIF_F_RXHASH;
+ } else {
+ adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
+ netdev->features |= NETIF_F_RXHASH;
+ }
+
+ err = ixgbe_init_interrupt_scheme(adapter);
+ /*
+ * If we can't init some sort of interrupt scheme then the device
+ * is hosed - just print a warning and bail. Nothing will work
+ * but at least we've put a message in the system log telling why.
+ */
+ if (err)
+ e_dev_err("Cannot initialize interrupts for device\n");
+ else
+ ixgbe_reset(adapter);
+
+ return err;
+}
+
+static int ixgbe_iov_set_cmd(struct net_device *dev,
+ struct ethtool_iov_set_cmd *iov_cmd)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+ struct ixgbe_hw *hw = &adapter->hw;
+ int err = 0;
+
+ if (iov_cmd->set_cmd == ETHTOOL_IOV_CMD_CONFIGURE_SRIOV &&
+ hw->mac.type == ixgbe_mac_82598EB)
+ return -EOPNOTSUPP;
+
+ switch (iov_cmd->set_cmd) {
+ case ETHTOOL_IOV_CMD_CONFIGURE_SRIOV:
+ if (iov_cmd->cmd_param != adapter->num_vfs &&
+ !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
+ err = ixgbe_reinit_sriov(dev, iov_cmd->cmd_param);
+ else
+ err = -EINVAL;
+ break;
+ case ETHTOOL_IOV_CMD_CONFIGURE_NETDEVS:
+ err = -ENOTSUPP;
+ break;
+ case ETHTOOL_IOV_CMD_CONFIGURE_VF_QUEUES:
+ err = -ENOTSUPP;
+ break;
+ default:
+ err = -EINVAL;
+ break;
+ }
+
+ return err;
+}
+
+static int ixgbe_iov_get_cmd(struct net_device *dev,
+ struct ethtool_iov_get_cmd *iov_cmd)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+
+ iov_cmd->mode = ETHTOOL_IOV_MODE_NONE;
+ if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
+ iov_cmd->mode = ETHTOOL_IOV_MODE_SRIOV;
+
+ return 0;
+}
+
static const struct ethtool_ops ixgbe_ethtool_ops = {
.get_settings = ixgbe_get_settings,
.set_settings = ixgbe_set_settings,
@@ -2605,6 +2711,8 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
.set_coalesce = ixgbe_set_coalesce,
.get_rxnfc = ixgbe_get_rxnfc,
.set_rxnfc = ixgbe_set_rxnfc,
+ .iov_set_cmd = ixgbe_iov_set_cmd,
+ .iov_get_cmd = ixgbe_iov_get_cmd,
};
void ixgbe_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 99ff8b2..546f3ba 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7591,6 +7591,9 @@ static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
if (hw->mac.type == ixgbe_mac_82598EB)
return;
+ /* need to save this away in case SR-IOV is reconfigured */
+ adapter->saved_ii = ii;
+
/* The 82599 supports up to 64 VFs per physical function
* but this implementation limits allocation to 63 so that
* basic networking resources are still available to the
next prev parent reply other threads:[~2011-09-22 21:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 21:35 [RFC PATCH V2 1/2] net/core/ethtool: New Commands to Configure IOV features Greg Rose
2011-09-22 21:35 ` Greg Rose [this message]
2011-10-08 0:37 ` Ben Hutchings
2011-10-13 17:04 ` Rose, Gregory V
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=20110922213527.26654.48496.stgit@gitlad.jf.intel.com \
--to=gregory.v.rose@intel.com \
--cc=netdev@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).