From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id D459C7CF2 for ; Thu, 8 Jun 2017 02:01:14 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id q97so12042570wrb.2 for ; Wed, 07 Jun 2017 17:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Zs0XBqzwWx9XtQ8OmtyitDOXmEM3FAt4V0nyt4K/ESc=; b=cxa5aiMA3fz661aU2+C7kfJ6PdAuZ7YzV2V2wvo3GbcSEarynYS/rbB8ngMJfiG2aT GmtANv2UJiJqVv/sd7dhyIFp/f+dEcotil69n9YppjjrGjR1FIjb0ae6PegSkpbsO3D4 WKNn1BOezmQVzxDO1sXc+lEwNyZoy+pTg0gDhG+C3DiDa3JjUIuZ5V/I/yjqmTTizi7d w+ntUXeWduv0+7L+RilKdqH/eFyxmqRb57z2CTpK5J/DOBA1rIBC2xXmg3y1XqxQXO4B SqWxDz6irxZ7/ogGKSaAWtI0ZbeKRjvIyyUekwfYFj5cfDbLdyFA4jbnWBIJWoLMkBRa f4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Zs0XBqzwWx9XtQ8OmtyitDOXmEM3FAt4V0nyt4K/ESc=; b=mDg6OttIc5tB+WtRb3wXi4K5fFc7PGFDfNZUTylXPCTUbjiIP1opdFPp33QC6ImZoR /3iEDe/oag+QcEyiXR/8euQi1ySXzIKiuD6+PTr6z/Xr9DDPQQk/jTyFNbCNJ7j4+N6M it8/ObsdJVoikt5M/Ug884BmiTdnVbiB3GK5JrG14bWKO7oXLFRriWCe1UKQJEX3xxzk fOItPOF5jctk9Ry0GaHUgeopyL2UvKy2BuLTmMBLzM5RoEl+PTx8pJrpkgBVCYd2q9wG Z1D9f0tYcEM681eylpeAR1XC1v4qz9B7KGZzPVX0kpKhiCnzscA6/mHgbNMenzENIdJu qGpw== X-Gm-Message-State: AODbwcDcx6GCS+tJogatIk5JWz5BFIHFBI69J1rQTz2TWD1+f/eDMtN9 pafMJUcFDyrz7THjHCQ= X-Received: by 10.223.133.181 with SMTP id 50mr16004482wrt.27.1496880074345; Wed, 07 Jun 2017 17:01:14 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id y42sm4266707wrc.51.2017.06.07.17.01.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 17:01:13 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 02:00:59 +0200 Message-Id: <65d6b36ea418739e8ba34248d773efc90ff2d4bc.1496877142.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 2/4] bus/net: implement hotplug bus operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2017 00:01:15 -0000 Signed-off-by: Gaetan Rivet --- drivers/bus/net/rte_bus_net.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/bus/net/rte_bus_net.c b/drivers/bus/net/rte_bus_net.c index 27a43f4..f5c7c95 100644 --- a/drivers/bus/net/rte_bus_net.c +++ b/drivers/bus/net/rte_bus_net.c @@ -253,11 +253,71 @@ rte_bus_net_pci_xfrm(const struct rte_devargs *src, return ret < 0 || ret > (int)sizeof(dst->name) || dst->args == NULL; } +static struct rte_device * +net_plug(struct rte_devargs *da) +{ + struct rte_net_device *dev; + + dev = net_scan_one(da->name); + if (dev == NULL) { + rte_errno = EFAULT; + return NULL; + } + if (net_probe_one(dev)) { + rte_errno = ENODEV; + return NULL; + } + return dev->sh_dev; +} + +static int +net_unplug(struct rte_device *dev) +{ + struct rte_net_device *ndev; + void *tmp; + int ret; + int err; + + FOREACH_NET_DEVICE_SAFE(ndev, tmp) { + struct rte_device *rdev; + struct rte_devargs *da; + struct rte_devargs *sub; + + if (dev != &ndev->device && + dev != ndev->sh_dev) + continue; + rdev = ndev->sh_dev; + if (rdev == NULL) + continue; + da = ndev->device.devargs; + sub = rdev->devargs; + ret = sub->bus->unplug(rdev); + if (ret) { + err = rte_errno; + ERROR("unplug failed"); + rte_errno = err; + return ret; + } + free(sub); + rte_eal_devargs_rmv(da); + REMOVE_NET_DEVICE(ndev); + free(ndev); + break; + } + if (ndev == NULL) { + ERROR("no such device"); + return -ENODEV; + } + return 0; +} + struct rte_bus rte_bus_net = { .scan = net_scan, .probe = net_probe, .find_device = net_find_device, .parse = net_parse, + .plug = net_plug, + .unplug = net_unplug, .conf = { .scan_mode = RTE_BUS_SCAN_UNDEFINED, }, -- 2.1.4