From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 17624AFD5 for ; Tue, 17 Jun 2014 20:09:31 +0200 (CEST) Received: by mail-wg0-f46.google.com with SMTP id y10so7343171wgg.17 for ; Tue, 17 Jun 2014 11:09:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=59hH+O/g5WrJJ2CgKyWVmRTmZr6KtzKo8CBEcsj3JlY=; b=VfaysZ51NtprEbNIhVRmWV8APxpxOOrKHha9Ozkzda1CPydCV0mBm4UCoXqXGs810f VGZk9Edx6sz6Q1UXOfAlKlOgPcsi4wnMiPfj/zFIMU1ESHalpGzLWrYyAFMtGm57gbCv 1tIWlwbbjaGmMyf0FY56gfA9nGd3HkI870ba658CHkHlq39FpCTudVd+SY7JiLeZdKyH xScMZKaPbllRsV12ZoG6gi5DSusXv8ASYxC4ajjSLf733dM0ZAgI/U62/WtXKmbLE5wH DkBkjmUS6GoQHkMRW+XiXMPxzX82nmkkuIdwAB3WdOsMvb7Tdre5HmSz1RrQL1J2Nch8 Zheg== X-Gm-Message-State: ALoCoQmyrnnd1dDAWic99MbJHioJLzMPmumySe6xeWYXYiR/YmSA8XxIY2OCVbCQdyfm+Pm/6bI/ X-Received: by 10.194.77.39 with SMTP id p7mr16727947wjw.85.1403028588305; Tue, 17 Jun 2014 11:09:48 -0700 (PDT) Received: from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id ge17sm1711552wic.0.2014.06.17.11.09.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jun 2014 11:09:47 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Tue, 17 Jun 2014 20:09:28 +0200 Message-Id: <1403028572-24794-4-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403028572-24794-1-git-send-email-david.marchand@6wind.com> References: <1403028572-24794-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v3 3/7] ethdev: store min rx buffer size 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: , X-List-Received-Date: Tue, 17 Jun 2014 18:09:32 -0000 This avoids code duplication in PMD when dealing with mtu changes. Signed-off-by: David Marchand --- lib/librte_ether/rte_ethdev.c | 20 +++++++++++++++----- lib/librte_ether/rte_ethdev.h | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 9b9d5f6..9061c7d 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -884,6 +884,8 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) { + int ret; + uint32_t mbp_buf_size; struct rte_eth_dev *dev; struct rte_pktmbuf_pool_private *mbp_priv; struct rte_eth_dev_info dev_info; @@ -924,13 +926,14 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, return (-ENOSPC); } mbp_priv = rte_mempool_get_priv(mp); - if ((uint32_t) (mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM) < - dev_info.min_rx_bufsize) { + mbp_buf_size = mbp_priv->mbuf_data_room_size; + + if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) { PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d " "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)" "=%d)\n", mp->name, - (int)mbp_priv->mbuf_data_room_size, + (int)mbp_buf_size, (int)(RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize), (int)RTE_PKTMBUF_HEADROOM, @@ -938,8 +941,15 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, return (-EINVAL); } - return (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, - socket_id, rx_conf, mp); + ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, + socket_id, rx_conf, mp); + if (!ret) { + if (!dev->data->min_rx_buf_size || + dev->data->min_rx_buf_size > mbp_buf_size) + dev->data->min_rx_buf_size = mbp_buf_size; + } + + return ret; } int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index a410afd..581259d 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1515,6 +1515,9 @@ struct rte_eth_dev_data { struct rte_eth_conf dev_conf; /**< Configuration applied to device. */ uint16_t max_frame_size; /**< Default is ETHER_MAX_LEN (1518). */ + uint32_t min_rx_buf_size; + /**< Common rx buffer size handled by all queues */ + uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */ struct ether_addr* mac_addrs;/**< Device Ethernet Link address. */ uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR]; -- 1.7.10.4