DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: Marcin Wojtas <mw@semihalf.com>,
	Michal Krawczyk <mk@semihalf.com>,
	Guy Tzalik <gtzalik@amazon.com>,
	Evgeny Schemeilin <evgenys@amazon.com>
Cc: dev@dpdk.org, matua@amazon.com, Rafal Kozik <rk@semihalf.com>
Subject: [dpdk-dev] [PATCH v2 18/26] net/ena: validate Tx req id
Date: Mon,  4 Jun 2018 14:09:46 +0200	[thread overview]
Message-ID: <20180604120955.17319-9-mk@semihalf.com> (raw)
In-Reply-To: <20180604120955.17319-1-mk@semihalf.com>

From: Rafal Kozik <rk@semihalf.com>

Validate Tx req id during clearing completed packets.
If id is wrong, trigger NIC reset.

Signed-off-by: Rafal Kozik <rk@semihalf.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 11fe40814..4b853a964 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -384,6 +384,27 @@ static inline int validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id)
 	return -EFAULT;
 }
 
+static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id)
+{
+	struct ena_tx_buffer *tx_info = NULL;
+
+	if (likely(req_id < tx_ring->ring_size)) {
+		tx_info = &tx_ring->tx_buffer_info[req_id];
+		if (likely(tx_info->mbuf))
+			return 0;
+	}
+
+	if (tx_info)
+		RTE_LOG(ERR, PMD, "tx_info doesn't have valid mbuf\n");
+	else
+		RTE_LOG(ERR, PMD, "Invalid req_id: %hu\n", req_id);
+
+	/* Trigger device reset */
+	tx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_TX_REQ_ID;
+	tx_ring->adapter->trigger_reset	= true;
+	return -EFAULT;
+}
+
 static void ena_config_host_info(struct ena_com_dev *ena_dev)
 {
 	struct ena_admin_host_info *host_info;
@@ -2093,6 +2114,10 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	/* Clear complete packets  */
 	while (ena_com_tx_comp_req_id_get(tx_ring->ena_com_io_cq, &req_id) >= 0) {
+		rc = validate_tx_req_id(tx_ring, req_id);
+		if (rc)
+			break;
+
 		/* Get Tx info & store how many descs were processed  */
 		tx_info = &tx_ring->tx_buffer_info[req_id];
 		total_tx_descs += tx_info->tx_descs;
-- 
2.14.1

  parent reply	other threads:[~2018-06-04 12:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 12:09 [dpdk-dev] [PATCH v2 10/26] net/ena: add watchdog and keep alive AENQ handler Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 11/26] net/ena: add checking for admin queue state Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 12/26] net/ena: make watchdog configurable Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 13/26] net/ena: add RX out of order completion Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 14/26] net/ena: linearize Tx mbuf Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 15/26] net/ena: add info about max number of Tx/Rx descriptors Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 16/26] net/ena: unimplemented handler error Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 17/26] net/ena: rework configuration of IO queue numbers Michal Krawczyk
2018-06-04 12:09 ` Michal Krawczyk [this message]
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 19/26] net/ena: add (un)likely statements Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 20/26] net/ena: adjust error checking and cleaning Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 21/26] net/ena: update numa node Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 22/26] net/ena: check pointer before memset Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 23/26] net/ena: change memory type Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 24/26] net/ena: fix GENMASK_ULL macro Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 25/26] net/ena: store handle after memory allocation Michal Krawczyk
2018-06-04 12:09 ` [dpdk-dev] [PATCH v2 26/26] net/ena: set link speed as none Michal Krawczyk

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=20180604120955.17319-9-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=matua@amazon.com \
    --cc=mw@semihalf.com \
    --cc=rk@semihalf.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).