From patchwork Wed Oct 12 20:55:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "John Daley (johndale)" X-Patchwork-Id: 16522 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D7F9C37B3; Wed, 12 Oct 2016 22:55:53 +0200 (CEST) Received: from alln-iport-3.cisco.com (alln-iport-3.cisco.com [173.37.142.90]) by dpdk.org (Postfix) with ESMTP id F37042BA6 for ; Wed, 12 Oct 2016 22:55:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1585; q=dns/txt; s=iport; t=1476305752; x=1477515352; h=from:to:cc:subject:date:message-id; bh=usedlKSanxabXPF841PI4yy6p254j3MJiIp/MmTbry0=; b=eDRqVMgly1S5SywYTddwcI5II6ZVifHx28RiWsI+kWcWq+oyN7yJudxa 0Xu2AQqvxxLliZLdbbrU7Otb+p3yQIV/h/aPiNRr04dB267EbVuv4PL9p P8BZ9JF37Tqv4F2SmebvWhPsK4PG/U98YRqKXsmVLJyiaGjIqr1JqAvJT 8=; X-IronPort-AV: E=Sophos;i="5.31,485,1473120000"; d="scan'208";a="334283842" Received: from rcdn-core-9.cisco.com ([173.37.93.145]) by alln-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2016 20:55:51 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-9.cisco.com (8.14.5/8.14.5) with ESMTP id u9CKtpiT011065; Wed, 12 Oct 2016 20:55:51 GMT Received: by cisco.com (Postfix, from userid 392789) id 0E32B3FAAE47; Wed, 12 Oct 2016 13:55:51 -0700 (PDT) From: John Daley To: bruce.richardson@intel.com Cc: dev@dpdk.org, John Daley Date: Wed, 12 Oct 2016 13:55:49 -0700 Message-Id: <20161012205549.27173-1-johndale@cisco.com> X-Mailer: git-send-email 2.10.0 Subject: [dpdk-dev] [PATCH] net/enic: fix crash on MTU update or rxq reconfigure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The incorrect completion queue corresponding to an RQ would be freed if multiple Rx queues are in use and the MTU is changed, or an Rx queue is released. This could lead to a segmentation fault when the device is disabled or even in the Rx or Tx paths. The index of the completion queue corresponding to a RQ needed to be adjusted after Rx scatter was introduced. Fixes: 856d7ba7ed22 ("net/enic: support scattered Rx") Signed-off-by: John Daley Reviewed-by: Nelson Escobar --- drivers/net/enic/enic.h | 5 +++++ drivers/net/enic/enic_main.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 4ea4e4a..13a4b31 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -170,6 +170,11 @@ struct enic { }; +/* Get the CQ index from a Start of Packet(SOP) RQ index */ +static inline unsigned int enic_sop_rq_idx_to_cq_idx(unsigned int sop_idx) +{ + return sop_idx / 2; +} static inline unsigned int enic_rq_sop(unsigned int sop_rq) { return sop_rq / 2; diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 622b317..65a8307 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -541,7 +541,7 @@ void enic_free_rq(void *rxq) if (rq_data->in_use) vnic_rq_free(rq_data); - vnic_cq_free(&enic->cq[rq_sop->index]); + vnic_cq_free(&enic->cq[enic_sop_rq_idx_to_cq_idx(rq_sop->index)]); rq_sop->in_use = 0; rq_data->in_use = 0;