netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <sameehj@amazon.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: Arthur Kiyanovski <akiyano@amazon.com>, <dwmw@amazon.com>,
	<zorik@amazon.com>, <matua@amazon.com>, <saeedb@amazon.com>,
	<msw@amazon.com>, <aliguori@amazon.com>, <nafea@amazon.com>,
	<gtzalik@amazon.com>, <netanel@amazon.com>, <alisaidi@amazon.com>,
	<benh@amazon.com>, <sameehj@amazon.com>, <ndagan@amazon.com>
Subject: [PATCH V2 net-next 13/13] net: ena: cosmetic: extract code to ena_indirection_table_set()
Date: Tue, 28 Apr 2020 07:27:26 +0000	[thread overview]
Message-ID: <20200428072726.22247-14-sameehj@amazon.com> (raw)
In-Reply-To: <20200428072726.22247-1-sameehj@amazon.com>

From: Arthur Kiyanovski <akiyano@amazon.com>

Extract code to ena_indirection_table_set() to make
the code cleaner.

Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_ethtool.c | 48 ++++++++++++-------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index 74725d606964..830d3711d6ee 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -636,6 +636,32 @@ static u32 ena_get_rxfh_key_size(struct net_device *netdev)
 	return ENA_HASH_KEY_SIZE;
 }
 
+static int ena_indirection_table_set(struct ena_adapter *adapter,
+				     const u32 *indir)
+{
+	struct ena_com_dev *ena_dev = adapter->ena_dev;
+	int i, rc;
+
+	for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) {
+		rc = ena_com_indirect_table_fill_entry(ena_dev,
+						       i,
+						       ENA_IO_RXQ_IDX(indir[i]));
+		if (unlikely(rc)) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "Cannot fill indirect table (index is too large)\n");
+			return rc;
+		}
+	}
+
+	rc = ena_com_indirect_table_set(ena_dev);
+	if (rc) {
+		netif_err(adapter, drv, adapter->netdev,
+			  "Cannot set indirect table\n");
+		return rc == -EPERM ? -EOPNOTSUPP : rc;
+	}
+	return rc;
+}
+
 static int ena_indirection_table_get(struct ena_adapter *adapter, u32 *indir)
 {
 	struct ena_com_dev *ena_dev = adapter->ena_dev;
@@ -710,26 +736,12 @@ static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
 	struct ena_adapter *adapter = netdev_priv(netdev);
 	struct ena_com_dev *ena_dev = adapter->ena_dev;
 	enum ena_admin_hash_functions func = 0;
-	int rc, i;
+	int rc;
 
 	if (indir) {
-		for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) {
-			rc = ena_com_indirect_table_fill_entry(ena_dev,
-							       i,
-							       ENA_IO_RXQ_IDX(indir[i]));
-			if (unlikely(rc)) {
-				netif_err(adapter, drv, netdev,
-					  "Cannot fill indirect table (index is too large)\n");
-				return rc;
-			}
-		}
-
-		rc = ena_com_indirect_table_set(ena_dev);
-		if (rc) {
-			netif_err(adapter, drv, netdev,
-				  "Cannot set indirect table\n");
-			return rc == -EPERM ? -EOPNOTSUPP : rc;
-		}
+		rc = ena_indirection_table_set(adapter, indir);
+		if (rc)
+			return rc;
 	}
 
 	switch (hfunc) {
-- 
2.24.1.AMZN


      parent reply	other threads:[~2020-04-28  7:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  7:27 [PATCH V2 net-next 00/13] Enhance current features in ena driver sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 01/13] net: ena: avoid unnecessary admin command when RSS function set fails sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 02/13] net: ena: fix error returning in ena_com_get_hash_function() sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 03/13] net: ena: allow setting the hash function without changing the key sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 04/13] net: ena: change default RSS hash function to Toeplitz sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 05/13] net: ena: changes to RSS hash key allocation sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 06/13] net: ena: remove code that does nothing sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 07/13] net: ena: add unmask interrupts statistics to ethtool sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 08/13] net: ena: add support for reporting of packet drops sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 09/13] net: ena: implement ena_com_get_admin_polling_mode() sameehj
2020-04-28 19:04   ` Jakub Kicinski
2020-05-03  9:54     ` Jubran, Samih
2020-04-28  7:27 ` [PATCH V2 net-next 10/13] net: ena: use SHUTDOWN as reset reason when closing interface sameehj
2020-04-28  7:27 ` [PATCH V2 net-next 11/13] net: ena: move llq configuration from ena_probe to ena_device_init() sameehj
2020-04-28 19:46   ` Jakub Kicinski
2020-05-03  9:54     ` Jubran, Samih
2020-04-28  7:27 ` [PATCH V2 net-next 12/13] net: ena: cosmetic: remove unnecessary spaces and tabs in ena_com.h macros sameehj
2020-04-28  7:27 ` sameehj [this message]

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=20200428072726.22247-14-sameehj@amazon.com \
    --to=sameehj@amazon.com \
    --cc=akiyano@amazon.com \
    --cc=aliguori@amazon.com \
    --cc=alisaidi@amazon.com \
    --cc=benh@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dwmw@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=matua@amazon.com \
    --cc=msw@amazon.com \
    --cc=nafea@amazon.com \
    --cc=ndagan@amazon.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedb@amazon.com \
    --cc=zorik@amazon.com \
    /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).