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 34A3BAE99 for ; Fri, 13 Jun 2014 15:37:39 +0200 (CEST) Received: by mail-wg0-f46.google.com with SMTP id y10so2773125wgg.5 for ; Fri, 13 Jun 2014 06:37:54 -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:cc:subject:date:message-id:in-reply-to :references; bh=5tzfwzqXw0lVpfoiy3E5PPzvXWCJzUH7E4bjfbvmY7Q=; b=l2kBJeKZnvj/tgMIWi46SjIqZwVGd+2XwgZ9xJovA/g3LSbiwpvuh9se9RNSj1JgTf NV8DZz5vU5b9cPgG9vbnTDIC+YFECQjqx9hU2LH035huMFGmvLx3xChF7Ue1w4zHMI0g cg62RcD7MwM9GQqGZJFScw96+WknZiH6or6faV3pePzb+ITrqylvoFRo15SQziDS73LM RXfjLBYeDp/qyLR+QrY2XBJnMK6qON4jwfaSYKRyhIWqRY3Lt9/6KbZ3YmXCNkJYAB7O 7vppZMp/JTSAJAjMuyoPESkEseRgJ8xdrPn0QTg17Bb8uPEiAY7mMw7STgTwIKwl1omi GyqA== X-Gm-Message-State: ALoCoQmB3iBQVWW8HMH3oeSyNmAWwytgiTwYQU1FIrfPWj61B72RwJ02vzhtFeRluJvxewCtTlQ7 X-Received: by 10.180.90.145 with SMTP id bw17mr4879692wib.43.1402666674398; Fri, 13 Jun 2014 06:37:54 -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 s9sm2568157wix.13.2014.06.13.06.37.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jun 2014 06:37:53 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Fri, 13 Jun 2014 15:37:39 +0200 Message-Id: <1402666663-10260-4-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402666663-10260-1-git-send-email-david.marchand@6wind.com> References: <1402666663-10260-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 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: Fri, 13 Jun 2014 13:37:39 -0000 This avoids code duplication in PMD when dealing with mtu changes. Signed-off-by: David Marchand --- lib/librte_ether/rte_ethdev.c | 19 ++++++++++++++----- lib/librte_ether/rte_ethdev.h | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index e881ebe..df18b7b 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -879,6 +879,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; @@ -919,13 +921,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, @@ -933,8 +936,14 @@ 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 > 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 5113b7a..3701023 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1262,6 +1262,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