From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id 1375571B3 for ; Mon, 4 Jun 2018 14:10:11 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id o9-v6so24808902lfk.1 for ; Mon, 04 Jun 2018 05:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fcvsqgp4EU15XKkJ0CJU9WPwz3VPtxWijyPqbXdKHT8=; b=GSO9SQlnN1Rwejh9PNxixVlu0UNKcwDEmi3YNZiW+pzo/VwyI4nANJeS+5RmQ/8DR9 trEKAEKta4m5wwSHInh6k3AkzJxwrGD1t5z6C5Pu6WEpQXAMgKwe+8LHunOXmPZjaD5v VsPrwyDP1nEuTn3u6TULDT3bnaR8n0QutjKNAI6b3lCxsg9T2Ryoel/KlekORizu3G7Z p9wZ/P9S3boleUNnWZSSEDwuUkSHqoPG5zyV/44JrLhCj8il8uspqUrzyoK3yAS67sn6 Wc639oF0SqdJrBEWZtOksKHhaBmUoCjIAT0QyB18922K9HkKTC+C9CqGHe9c+TS4yvs9 V4Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fcvsqgp4EU15XKkJ0CJU9WPwz3VPtxWijyPqbXdKHT8=; b=cGIUQqjLbKP/gkOOt65a7WcOnVstMM+yD52Bm/CrpFdWJjed32S2BqDkqyhYnPwvPL 3ZV5Mg+vmoB71hGmCz6JvKA2VrDRvgq0fTdYdMEiMUdAvqKYLdO+AHfYH/dm9rzE/K5r zb6XRrkPFemmkAbpfqacO6UFqQgvH1i2wAM8gT9Y2XMPITa2AxmHcYvkWrR86+4BBn99 RcnnBBTyEJq6aX1LzrFjYYpFD31x6Fg2nmmFwwAg/Wk9rrjrfTtoa2dGErKn/I0tR6Hn kNCW2Fpavo+vK+7yjUcblI7tSY3mdkKZme7wiDogrrL8k/UuM/gwJHsjOeET/jUOXaBf +rEA== X-Gm-Message-State: ALKqPwceAK4YkxZKEbSCe5gsU8naSQtwXj0NkIlW4dGl2rvd8aTFQW4g zy3oYKGqA9Agiwmj0y1DyZj0Cg== X-Google-Smtp-Source: ADUXVKJk1vUWmgl+yvlbwjjWSJFXd6vVBy9Ht5JIHuCL7/BAz/rBI3/NTOdRWB9jBowVO2NRLsmHlg== X-Received: by 2002:a19:6450:: with SMTP id b16-v6mr13361258lfj.46.1528114210713; Mon, 04 Jun 2018 05:10:10 -0700 (PDT) Received: from mkPC.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id g23-v6sm3817415lfi.49.2018.06.04.05.10.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 05:10:10 -0700 (PDT) From: Michal Krawczyk To: Marcin Wojtas , Michal Krawczyk , Guy Tzalik , Evgeny Schemeilin Cc: dev@dpdk.org, matua@amazon.com, Rafal Kozik Date: Mon, 4 Jun 2018 14:09:46 +0200 Message-Id: <20180604120955.17319-9-mk@semihalf.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180604120955.17319-1-mk@semihalf.com> References: <20180604120955.17319-1-mk@semihalf.com> Subject: [dpdk-dev] [PATCH v2 18/26] net/ena: validate Tx req id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jun 2018 12:10:11 -0000 From: Rafal Kozik Validate Tx req id during clearing completed packets. If id is wrong, trigger NIC reset. Signed-off-by: Rafal Kozik Acked-by: Michal Krawczyk --- 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