From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by dpdk.org (Postfix) with ESMTP id AEDFA1B1C7 for ; Thu, 7 Jun 2018 11:44:04 +0200 (CEST) Received: by mail-lf0-f68.google.com with SMTP id g21-v6so11670304lfb.4 for ; Thu, 07 Jun 2018 02:44:04 -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=/kfiPClVLW8UBUzJEh1yi7ZvDw9p9uTLR9veQRPE9FM=; b=0mR8owbnv0zG05/wOJXo4b+z+uV+32o4x/vf4O0WSAvoSJLR8M3Z94JxYpkRiSJ20o 48zLkqPMfyrWP7naXDqeATAp61lXK0h3JxU1zzjC/BooerMH+fmKkN+EqR3r56bKnhZ4 JrrA6012Gzh4kPIplikA39bemI8FbNyF032dWeE4Ex1tqppVAqRWaEw2jJZkupP8b6DO BxSrQdTQrzSSN6NfEdxvHdoUfMS/A+2s97pz7snGySDxfn99cmc8tSzZz4jWrW2nxiu3 mtX2WdVlsI7FuTjy9I4JqCnSQj7htFeVaImXdNuih9YMV/6hTEPEraTMvqLq+1AgQGqR xnDg== 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=/kfiPClVLW8UBUzJEh1yi7ZvDw9p9uTLR9veQRPE9FM=; b=knWr1fwt6veZU8uW/EWM0EPslXl5Rkvme09iJAwkc0880fx1R88dKs1+OreGjIlzdJ 06gNVnxX1whCjUFr7lyHcyS0AQMnFtAxhhILw3KuggybK8Dury2zyKkna80mE27J384U tfEQIdq68r+0i6sXfkiAb4HgHg1chXqJeC4aWv0vUz4f5G+OP9dLiqhVWVsoeD8S22CQ q/yEknkr9DGXzw2UTdqsJ/PfD5Vpa0ajzjmVube++saITJp8IFC2j+T5jUczCs4+G5B+ 1EXcgQUbiOwv6dJLHEn4GnycqC9BwJ05AxopGWRlFcao01wjCJ1N7Yhfc5z1HqRQv/62 UxkA== X-Gm-Message-State: APt69E1QkLxeCx9nGRWk9Vq8YyjxuwpzPxKF8eq5WtF4ujl//xC0Glbh ASmRJvfX45KUkaKnrCy7C0xZcg== X-Google-Smtp-Source: ADUXVKKRiqalYSEzZWN4X2qGCcTu56yXQ5aSO0waX9Lqmj1H8hCLDuaBMBccH9tmL18o75X8yHdRBQ== X-Received: by 2002:a19:8f1d:: with SMTP id r29-v6mr866378lfd.88.1528364644358; Thu, 07 Jun 2018 02:44:04 -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 p28-v6sm3612368lfh.24.2018.06.07.02.44.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 02:44:02 -0700 (PDT) From: Michal Krawczyk To: Marcin Wojtas , Michal Krawczyk , Guy Tzalik , Evgeny Schemeilin Cc: dev@dpdk.org, matua@amazon.com, Rafal Kozik Date: Thu, 7 Jun 2018 11:43:14 +0200 Message-Id: <20180607094322.14312-19-mk@semihalf.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180607094322.14312-1-mk@semihalf.com> References: <20180607094322.14312-1-mk@semihalf.com> Subject: [dpdk-dev] [PATCH v3 19/27] 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: Thu, 07 Jun 2018 09:44:04 -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 1f7463496..5fbf0e5d5 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