From patchwork Wed Oct 12 21:12:02 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: 16523 X-Patchwork-Delegate: bruce.richardson@intel.com 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 F281A376C; Wed, 12 Oct 2016 23:12:18 +0200 (CEST) Received: from alln-iport-4.cisco.com (alln-iport-4.cisco.com [173.37.142.91]) by dpdk.org (Postfix) with ESMTP id 068332BCE for ; Wed, 12 Oct 2016 23:12:16 +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=1476306737; x=1477516337; h=from:to:cc:subject:date:message-id; bh=usedlKSanxabXPF841PI4yy6p254j3MJiIp/MmTbry0=; b=RA1kvngKZGxC2uDSa/YsrJfK+d8Zj/OZ/PXgb/Qd/Zl/DhudZ7iC4pAC eVTkfQO4yEZj+JxcVKnJSjP7GEMbHlj/HEG8ZW3l4xA73FiEK7us5/eq3 2le4kDzYL33bXYUQWL2iamQR4GJ1pt+L+wPAxJiQdQAK8pHTK0C6tZ1NK w=; X-IronPort-AV: E=Sophos;i="5.31,485,1473120000"; d="scan'208";a="334152625" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2016 21:12:16 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id u9CLCGX4001620; Wed, 12 Oct 2016 21:12:16 GMT Received: by cisco.com (Postfix, from userid 392789) id 232C33FAAE47; Wed, 12 Oct 2016 14:12:16 -0700 (PDT) From: John Daley To: bruce.richardson@intel.com Cc: dev@dpdk.org, John Daley Date: Wed, 12 Oct 2016 14:12:02 -0700 Message-Id: <20161012211203.23250-1-johndale@cisco.com> X-Mailer: git-send-email 2.10.0 Subject: [dpdk-dev] [PATCH 1/2] 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;