From patchwork Tue Aug 26 14:12:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 242 Return-Path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id E9857B3C0 for ; Tue, 26 Aug 2014 16:08:24 +0200 (CEST) Received: by mail-wi0-f177.google.com with SMTP id ho1so4228685wib.4 for ; Tue, 26 Aug 2014 07:12:25 -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=/vM3hv12SQ19FVIZ9HOOKv81dc26fSjqAcT/1Gy+rw4=; b=JCa4rsyx04kdq9/OIcNwmOIOFUX1DvAUnd+gCy9cHxGWXBr5vU6BjmuSK/dzEIKh78 Qcqv1MN73KwSQ/TvF7e/Qxd8TjmuMiHBGHAhWwYuPu3AIyFFsOe/3uqaDLiujM8ZG4ya MOW5tNUSz6SpZZtRTKsP4uOYj9gp2UUH+5sUPmo1/gHTzCFBDHXlV6CsYbwAJwtClGT5 0ckDw3XZiBbIKaFI2ZJbediYmJQh1DeFg5CnEIxXMqlr8JIzCHskyiFMWtpMajunBrof skqk8gz4XtZUk3qAP4aeZ2xHsG/vAX6EpEnv61HdaliFenYxFqCl34LzcX4XK+WAo8IL 6NRw== X-Gm-Message-State: ALoCoQmh30qfAPxrIN1sNdI/eoD9/447N6mE+Ht9yTuNTHz8P0lO5bPYEPCYY7x5gBr/NDjkSVhV X-Received: by 10.180.13.49 with SMTP id e17mr21859491wic.61.1409062344994; Tue, 26 Aug 2014 07:12:24 -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 cy9sm12568145wib.18.2014.08.26.07.12.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 07:12:24 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Tue, 26 Aug 2014 16:12:16 +0200 Message-Id: <1409062338-26477-2-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1409062338-26477-1-git-send-email-david.marchand@6wind.com> References: <1409062338-26477-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 1/3] bond: move param parsing in dev_configure 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, 26 Aug 2014 14:08:25 -0000 Rework bond pmd initialisation so that we don't need to modify eal for this pmd to work. Signed-off-by: David Marchand --- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 33 ++++++++++++++++++++++------ lib/librte_pmd_bond/rte_eth_bond_private.h | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index d72d6ed..42cf37a 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -707,11 +707,8 @@ bond_ethdev_close(struct rte_eth_dev *dev __rte_unused) { } -static int -bond_ethdev_configure(struct rte_eth_dev *dev __rte_unused) -{ - return 0; -} +/* forward declaration */ +static int bond_ethdev_configure(struct rte_eth_dev *dev); static void bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) @@ -1027,6 +1024,7 @@ struct eth_dev_ops default_dev_ops = { static int bond_init(const char *name, const char *params) { + struct bond_dev_private *internals; struct rte_kvargs *kvlist; uint8_t bonding_mode, socket_id; int arg_count, port_id; @@ -1078,10 +1076,31 @@ bond_init(const char *name, const char *params) name, bonding_mode, socket_id); return -1; } + internals = rte_eth_devices[port_id].data->dev_private; + internals->kvlist = kvlist; RTE_LOG(INFO, EAL, "Create bonded device %s on port %d in mode %u on socket %u.\n", name, port_id, bonding_mode, socket_id); + return 0; +} + +/* this part will resolve the slave portids after all the other pdev and vdev + * have been allocated */ +static int +bond_ethdev_configure(struct rte_eth_dev *dev) +{ + char *name = dev->data->name; + struct bond_dev_private *internals = dev->data->dev_private; + struct rte_kvargs *kvlist = internals->kvlist; + int arg_count, port_id = dev - rte_eth_devices; + + /* + * if no kvlist, it means that this bonded device has been created + * through the bonding api. + */ + if (!kvlist) + return 0; /* Parse MAC address for bonded device */ arg_count = rte_kvargs_count(kvlist, PMD_BOND_MAC_ADDR_KVARG); @@ -1199,8 +1218,8 @@ bond_init(const char *name, const char *params) } static struct rte_driver bond_drv = { - .name = PMD_BOND_NAME, - .type = PMD_BDEV, + .name = "eth_bond", + .type = PMD_VDEV, .init = bond_init, }; diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h index 60f1e8d..1db6e4d 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_private.h +++ b/lib/librte_pmd_bond/rte_eth_bond_private.h @@ -123,6 +123,8 @@ struct bond_dev_private { /** Persisted configuration of slaves */ struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS]; + + struct rte_kvargs *kvlist; }; extern struct eth_dev_ops default_dev_ops;