diff mbox series

[v2,net-next,2/3] qede: add per queue coalesce support for qede driver

Message ID 1612906019-31724-3-git-send-email-bupadhaya@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series qede: add netpoll and per-queue coalesce support | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: GR-everest-linux-l2@marvell.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 141 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Bhaskar Upadhaya Feb. 9, 2021, 9:26 p.m. UTC
per queue coalescing allows better and more finegrained control
over interrupt rates.

Signed-off-by: Bhaskar Upadhaya <bupadhaya@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
---
 .../net/ethernet/qlogic/qede/qede_ethtool.c   | 123 ++++++++++++++++++
 1 file changed, 123 insertions(+)

Comments

Dan Carpenter Feb. 10, 2021, 8:57 a.m. UTC | #1
Hi Bhaskar,

url:    https://github.com/0day-ci/linux/commits/Bhaskar-Upadhaya/qede-add-netpoll-and-per-queue-coalesce-support/20210210-080747 
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git  6626a0266566c5aea16178c5e6cd7fc4db3f2f56
config: i386-randconfig-m021-20210209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/net/ethernet/qlogic/qede/qede_ethtool.c:2188 qede_get_per_coalesce() warn: assigning (-22) to unsigned variable 'rc'

Old smatch warnings:
drivers/net/ethernet/qlogic/qede/qede_ethtool.c:2193 qede_get_per_coalesce() warn: assigning (-22) to unsigned variable 'rc'

vim +/rc +2188 drivers/net/ethernet/qlogic/qede/qede_ethtool.c

75a56157c75052 Bhaskar Upadhaya 2021-02-09  2171  static int qede_get_per_coalesce(struct net_device *dev,
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2172  				 u32 queue,
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2173  				 struct ethtool_coalesce *coal)
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2174  {
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2175  	void *rx_handle = NULL, *tx_handle = NULL;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2176  	struct qede_dev *edev = netdev_priv(dev);
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2177  	u16 rx_coal, tx_coal, rc = 0;

"rc" needs to be int.

75a56157c75052 Bhaskar Upadhaya 2021-02-09  2178  	struct qede_fastpath *fp;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2179  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2180  	rx_coal = QED_DEFAULT_RX_USECS;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2181  	tx_coal = QED_DEFAULT_TX_USECS;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2182  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2183  	memset(coal, 0, sizeof(struct ethtool_coalesce));
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2184  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2185  	__qede_lock(edev);
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2186  	if (queue >= edev->num_queues) {
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2187  		DP_INFO(edev, "Invalid queue\n");
75a56157c75052 Bhaskar Upadhaya 2021-02-09 @2188  		rc = -EINVAL;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2189  		goto out;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2190  	}
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2191  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2192  	if (edev->state != QEDE_STATE_OPEN) {
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2193  		rc = -EINVAL;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2194  		goto out;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2195  	}
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2196  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2197  	fp = &edev->fp_array[queue];
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2198  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2199  	if (fp->type & QEDE_FASTPATH_RX)
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2200  		rx_handle = fp->rxq->handle;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2201  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2202  	rc = edev->ops->get_coalesce(edev->cdev, &rx_coal,
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2203  				     rx_handle);
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2204  	if (rc) {
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2205  		DP_INFO(edev, "Read Rx coalesce error\n");
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2206  		goto out;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2207  	}
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2208  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2209  	fp = &edev->fp_array[queue];
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2210  	if (fp->type & QEDE_FASTPATH_TX)
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2211  		tx_handle = fp->txq->handle;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2212  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2213  	rc = edev->ops->get_coalesce(edev->cdev, &tx_coal,
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2214  				      tx_handle);
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2215  	if (rc)
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2216  		DP_INFO(edev, "Read Tx coalesce error\n");
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2217  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2218  out:
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2219  	__qede_unlock(edev);
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2220  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2221  	coal->rx_coalesce_usecs = rx_coal;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2222  	coal->tx_coalesce_usecs = tx_coal;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2223  
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2224  	return rc;
75a56157c75052 Bhaskar Upadhaya 2021-02-09  2225  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index bedbb85a179a..522736968496 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -2105,6 +2105,125 @@  static int qede_get_dump_data(struct net_device *dev,
 	return rc;
 }
 
+static int qede_set_per_coalesce(struct net_device *dev,
+				 u32 queue,
+				 struct ethtool_coalesce *coal)
+{
+	struct qede_dev *edev = netdev_priv(dev);
+	struct qede_fastpath *fp;
+	u16 rxc, txc;
+	int rc = 0;
+
+	if (coal->rx_coalesce_usecs > QED_COALESCE_MAX ||
+	    coal->tx_coalesce_usecs > QED_COALESCE_MAX) {
+		DP_INFO(edev,
+			"Can't support requested %s coalesce value [max supported value %d]\n",
+			coal->rx_coalesce_usecs > QED_COALESCE_MAX ? "rx"
+								   : "tx",
+			QED_COALESCE_MAX);
+		return -EINVAL;
+	}
+
+	rxc = (u16)coal->rx_coalesce_usecs;
+	txc = (u16)coal->tx_coalesce_usecs;
+
+	__qede_lock(edev);
+	if (queue >= edev->num_queues) {
+		DP_INFO(edev, "Invalid queue\n");
+		rc = -EINVAL;
+		goto out;
+	}
+
+	if (edev->state != QEDE_STATE_OPEN) {
+		rc = -EINVAL;
+		goto out;
+	}
+
+	fp = &edev->fp_array[queue];
+
+	if (edev->fp_array[queue].type & QEDE_FASTPATH_RX) {
+		rc = edev->ops->common->set_coalesce(edev->cdev,
+						     rxc, 0,
+						     fp->rxq->handle);
+		if (rc) {
+			DP_INFO(edev,
+				"Set RX coalesce error, rc = %d\n", rc);
+			goto out;
+		}
+	}
+
+	if (edev->fp_array[queue].type & QEDE_FASTPATH_TX) {
+		rc = edev->ops->common->set_coalesce(edev->cdev,
+						     0, txc,
+						     fp->txq->handle);
+		if (rc) {
+			DP_INFO(edev,
+				"Set TX coalesce error, rc = %d\n", rc);
+			goto out;
+		}
+	}
+out:
+	__qede_unlock(edev);
+
+	return rc;
+}
+
+static int qede_get_per_coalesce(struct net_device *dev,
+				 u32 queue,
+				 struct ethtool_coalesce *coal)
+{
+	void *rx_handle = NULL, *tx_handle = NULL;
+	struct qede_dev *edev = netdev_priv(dev);
+	u16 rx_coal, tx_coal, rc = 0;
+	struct qede_fastpath *fp;
+
+	rx_coal = QED_DEFAULT_RX_USECS;
+	tx_coal = QED_DEFAULT_TX_USECS;
+
+	memset(coal, 0, sizeof(struct ethtool_coalesce));
+
+	__qede_lock(edev);
+	if (queue >= edev->num_queues) {
+		DP_INFO(edev, "Invalid queue\n");
+		rc = -EINVAL;
+		goto out;
+	}
+
+	if (edev->state != QEDE_STATE_OPEN) {
+		rc = -EINVAL;
+		goto out;
+	}
+
+	fp = &edev->fp_array[queue];
+
+	if (fp->type & QEDE_FASTPATH_RX)
+		rx_handle = fp->rxq->handle;
+
+	rc = edev->ops->get_coalesce(edev->cdev, &rx_coal,
+				     rx_handle);
+	if (rc) {
+		DP_INFO(edev, "Read Rx coalesce error\n");
+		goto out;
+	}
+
+	fp = &edev->fp_array[queue];
+	if (fp->type & QEDE_FASTPATH_TX)
+		tx_handle = fp->txq->handle;
+
+	rc = edev->ops->get_coalesce(edev->cdev, &tx_coal,
+				      tx_handle);
+	if (rc)
+		DP_INFO(edev, "Read Tx coalesce error\n");
+
+out:
+	__qede_unlock(edev);
+
+	coal->rx_coalesce_usecs = rx_coal;
+	coal->tx_coalesce_usecs = tx_coal;
+
+	return rc;
+}
+
 static const struct ethtool_ops qede_ethtool_ops = {
 	.supported_coalesce_params	= ETHTOOL_COALESCE_USECS,
 	.get_link_ksettings		= qede_get_link_ksettings,
@@ -2148,6 +2267,8 @@  static const struct ethtool_ops qede_ethtool_ops = {
 	.set_fecparam			= qede_set_fecparam,
 	.get_tunable			= qede_get_tunable,
 	.set_tunable			= qede_set_tunable,
+	.get_per_queue_coalesce		= qede_get_per_coalesce,
+	.set_per_queue_coalesce		= qede_set_per_coalesce,
 	.flash_device			= qede_flash_device,
 	.get_dump_flag			= qede_get_dump_flag,
 	.get_dump_data			= qede_get_dump_data,
@@ -2177,6 +2298,8 @@  static const struct ethtool_ops qede_vf_ethtool_ops = {
 	.set_rxfh			= qede_set_rxfh,
 	.get_channels			= qede_get_channels,
 	.set_channels			= qede_set_channels,
+	.get_per_queue_coalesce		= qede_get_per_coalesce,
+	.set_per_queue_coalesce		= qede_set_per_coalesce,
 	.get_tunable			= qede_get_tunable,
 	.set_tunable			= qede_set_tunable,
 };