From: <darinzon@amazon•com>
To: "Nelson, Shannon" <shannon.nelson@amd•com>,
David Miller <davem@davemloft•net>,
Jakub Kicinski <kuba@kernel•org>, <netdev@vger•kernel.org>
Cc: David Arinzon <darinzon@amazon•com>,
"Woodhouse, David" <dwmw@amazon•com>,
"Machulsky, Zorik" <zorik@amazon•com>,
"Matushevsky, Alexander" <matua@amazon•com>,
Saeed Bshara <saeedb@amazon•com>, "Wilson, Matt" <msw@amazon•com>,
"Liguori, Anthony" <aliguori@amazon•com>,
"Bshara, Nafea" <nafea@amazon•com>,
"Belgazal, Netanel" <netanel@amazon•com>,
"Saidi, Ali" <alisaidi@amazon•com>,
"Herrenschmidt, Benjamin" <benh@amazon•com>,
"Kiyanovski, Arthur" <akiyano@amazon•com>,
"Dagan, Noam" <ndagan@amazon•com>,
"Agroskin, Shay" <shayagr@amazon•com>,
"Itzko, Shahar" <itzko@amazon•com>,
"Abboud, Osama" <osamaabb@amazon•com>,
"Ostrovsky, Evgeny" <evostrov@amazon•com>,
"Tabachnik, Ofir" <ofirt@amazon•com>,
"Koler, Nati" <nkoler@amazon•com>
Subject: [PATCH v2 net-next 10/11] net: ena: handle ena_calc_io_queue_size() possible errors
Date: Tue, 30 Jan 2024 09:53:52 +0000 [thread overview]
Message-ID: <20240130095353.2881-11-darinzon@amazon.com> (raw)
In-Reply-To: <20240130095353.2881-1-darinzon@amazon.com>
From: David Arinzon <darinzon@amazon•com>
Fail queue size calculation when the device returns maximum
TX/RX queue sizes that are smaller than the allowed minimum.
Signed-off-by: Osama Abboud <osamaabb@amazon•com>
Signed-off-by: David Arinzon <darinzon@amazon•com>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 24 +++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 8d99904..965a01c 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2899,8 +2899,8 @@ static const struct net_device_ops ena_netdev_ops = {
.ndo_xdp_xmit = ena_xdp_xmit,
};
-static void ena_calc_io_queue_size(struct ena_adapter *adapter,
- struct ena_com_dev_get_features_ctx *get_feat_ctx)
+static int ena_calc_io_queue_size(struct ena_adapter *adapter,
+ struct ena_com_dev_get_features_ctx *get_feat_ctx)
{
struct ena_admin_feature_llq_desc *llq = &get_feat_ctx->llq;
struct ena_com_dev *ena_dev = adapter->ena_dev;
@@ -2959,6 +2959,18 @@ static void ena_calc_io_queue_size(struct ena_adapter *adapter,
max_tx_queue_size = rounddown_pow_of_two(max_tx_queue_size);
max_rx_queue_size = rounddown_pow_of_two(max_rx_queue_size);
+ if (max_tx_queue_size < ENA_MIN_RING_SIZE) {
+ netdev_err(adapter->netdev, "Device max TX queue size: %d < minimum: %d\n",
+ max_tx_queue_size, ENA_MIN_RING_SIZE);
+ return -EINVAL;
+ }
+
+ if (max_rx_queue_size < ENA_MIN_RING_SIZE) {
+ netdev_err(adapter->netdev, "Device max RX queue size: %d < minimum: %d\n",
+ max_rx_queue_size, ENA_MIN_RING_SIZE);
+ return -EINVAL;
+ }
+
/* When forcing large headers, we multiply the entry size by 2, and therefore divide
* the queue size by 2, leaving the amount of memory used by the queues unchanged.
*/
@@ -2989,6 +3001,8 @@ static void ena_calc_io_queue_size(struct ena_adapter *adapter,
adapter->max_rx_ring_size = max_rx_queue_size;
adapter->requested_tx_ring_size = tx_queue_size;
adapter->requested_rx_ring_size = rx_queue_size;
+
+ return 0;
}
static int ena_device_validate_params(struct ena_adapter *adapter,
@@ -3190,11 +3204,15 @@ static int ena_device_init(struct ena_adapter *adapter, struct pci_dev *pdev,
goto err_admin_init;
}
- ena_calc_io_queue_size(adapter, get_feat_ctx);
+ rc = ena_calc_io_queue_size(adapter, get_feat_ctx);
+ if (unlikely(rc))
+ goto err_admin_init;
return 0;
err_admin_init:
+ ena_com_abort_admin_commands(ena_dev);
+ ena_com_wait_for_abort_completion(ena_dev);
ena_com_delete_host_info(ena_dev);
ena_com_admin_destroy(ena_dev);
err_mmio_read_less:
--
2.40.1
next prev parent reply other threads:[~2024-01-30 9:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 9:53 [PATCH v2 net-next 00/11] ENA driver changes darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 01/11] net: ena: Remove an unused field darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 02/11] net: ena: Add more documentation for RX copybreak darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 03/11] net: ena: Minor cosmetic changes darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 04/11] net: ena: Enable DIM by default darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 05/11] net: ena: Remove CQ tail pointer update darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 06/11] net: ena: Change error print during ena_device_init() darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 07/11] net: ena: Add more information on TX timeouts darinzon
2024-02-01 12:17 ` Paolo Abeni
2024-02-01 13:21 ` Arinzon, David
2024-02-01 14:36 ` Paolo Abeni
2024-02-01 15:43 ` Arinzon, David
2024-02-01 12:27 ` Simon Horman
2024-02-01 12:53 ` Arinzon, David
2024-01-30 9:53 ` [PATCH v2 net-next 08/11] net: ena: Relocate skb_tx_timestamp() to improve time stamping accuracy darinzon
2024-01-30 9:53 ` [PATCH v2 net-next 09/11] net: ena: Change default print level for netif_ prints darinzon
2024-01-30 9:53 ` darinzon [this message]
2024-01-30 9:53 ` [PATCH v2 net-next 11/11] net: ena: Reduce lines with longer column width boundary darinzon
2024-02-01 16:12 ` Jakub Kicinski
2024-02-01 17:40 ` Arinzon, David
2024-02-01 12:30 ` [PATCH v2 net-next 00/11] ENA driver changes patchwork-bot+netdevbpf
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=20240130095353.2881-11-darinzon@amazon.com \
--to=darinzon@amazon$(echo .)com \
--cc=akiyano@amazon$(echo .)com \
--cc=aliguori@amazon$(echo .)com \
--cc=alisaidi@amazon$(echo .)com \
--cc=benh@amazon$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=dwmw@amazon$(echo .)com \
--cc=evostrov@amazon$(echo .)com \
--cc=itzko@amazon$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=matua@amazon$(echo .)com \
--cc=msw@amazon$(echo .)com \
--cc=nafea@amazon$(echo .)com \
--cc=ndagan@amazon$(echo .)com \
--cc=netanel@amazon$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nkoler@amazon$(echo .)com \
--cc=ofirt@amazon$(echo .)com \
--cc=osamaabb@amazon$(echo .)com \
--cc=saeedb@amazon$(echo .)com \
--cc=shannon.nelson@amd$(echo .)com \
--cc=shayagr@amazon$(echo .)com \
--cc=zorik@amazon$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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