]> git.baikalelectronics.ru Git - kernel.git/commitdiff
qede: Add support for {get, set}_channels
authorSudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Mon, 30 Nov 2015 10:25:01 +0000 (12:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Dec 2015 21:02:39 +0000 (16:02 -0500)
Signed-off-by: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_ethtool.c
drivers/net/ethernet/qlogic/qede/qede_main.c

index ea00d5f3bab43a8c9ef8002c05c1c796a8bb4af9..a65a9b22aaec0e6674f5b114f4776cb623983a5d 100644 (file)
@@ -116,6 +116,7 @@ struct qede_dev {
                                 (edev)->dev_info.num_tc)
 
        struct qede_fastpath            *fp_array;
+       u16                             req_rss;
        u16                             num_rss;
        u8                              num_tc;
 #define QEDE_RSS_CNT(edev)             ((edev)->num_rss)
index 3a362476a22c66cb01a7de728875b9e67b9eb5df..ea2fda8e5b640df119b07c774ea1d5f2f1d0193a 100644 (file)
@@ -366,6 +366,57 @@ int qede_change_mtu(struct net_device *ndev, int new_mtu)
        return 0;
 }
 
+static void qede_get_channels(struct net_device *dev,
+                             struct ethtool_channels *channels)
+{
+       struct qede_dev *edev = netdev_priv(dev);
+
+       channels->max_combined = QEDE_MAX_RSS_CNT(edev);
+       channels->combined_count = QEDE_RSS_CNT(edev);
+}
+
+static int qede_set_channels(struct net_device *dev,
+                            struct ethtool_channels *channels)
+{
+       struct qede_dev *edev = netdev_priv(dev);
+
+       DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
+                  "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
+                  channels->rx_count, channels->tx_count,
+                  channels->other_count, channels->combined_count);
+
+       /* We don't support separate rx / tx, nor `other' channels. */
+       if (channels->rx_count || channels->tx_count ||
+           channels->other_count || (channels->combined_count == 0) ||
+           (channels->combined_count > QEDE_MAX_RSS_CNT(edev))) {
+               DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
+                          "command parameters not supported\n");
+               return -EINVAL;
+       }
+
+       /* Check if there was a change in the active parameters */
+       if (channels->combined_count == QEDE_RSS_CNT(edev)) {
+               DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
+                          "No change in active parameters\n");
+               return 0;
+       }
+
+       /* We need the number of queues to be divisible between the hwfns */
+       if (channels->combined_count % edev->dev_info.common.num_hwfns) {
+               DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
+                          "Number of channels must be divisable by %04x\n",
+                          edev->dev_info.common.num_hwfns);
+               return -EINVAL;
+       }
+
+       /* Set number of queues and reload if necessary */
+       edev->req_rss = channels->combined_count;
+       if (netif_running(dev))
+               qede_reload(edev, NULL, NULL);
+
+       return 0;
+}
+
 static const struct ethtool_ops qede_ethtool_ops = {
        .get_settings = qede_get_settings,
        .set_settings = qede_set_settings,
@@ -377,6 +428,8 @@ static const struct ethtool_ops qede_ethtool_ops = {
        .get_ethtool_stats = qede_get_ethtool_stats,
        .get_sset_count = qede_get_sset_count,
 
+       .get_channels = qede_get_channels,
+       .set_channels = qede_set_channels,
 };
 
 void qede_set_ethtool_ops(struct net_device *dev)
index f4657a2e730aa424ff2a372a8b3e6557b9434f52..6237f10b5119faae8c6149bae8b6eea31f607deb 100644 (file)
@@ -1502,8 +1502,11 @@ static int qede_set_num_queues(struct qede_dev *edev)
        u16 rss_num;
 
        /* Setup queues according to possible resources*/
-       rss_num = netif_get_num_default_rss_queues() *
-                 edev->dev_info.common.num_hwfns;
+       if (edev->req_rss)
+               rss_num = edev->req_rss;
+       else
+               rss_num = netif_get_num_default_rss_queues() *
+                         edev->dev_info.common.num_hwfns;
 
        rss_num = min_t(u16, QEDE_MAX_RSS_CNT(edev), rss_num);