From patchwork Thu Apr 12 12:52:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 897655 X-Patchwork-Delegate: ian.stokes@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jvmi5x6m"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40MLWZ49MLz9s2M for ; Thu, 12 Apr 2018 22:56:26 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6EBDBD9A; Thu, 12 Apr 2018 12:53:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1A565D7C for ; Thu, 12 Apr 2018 12:53:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BAEFC670 for ; Thu, 12 Apr 2018 12:53:11 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id a39-v6so3848452pla.10 for ; Thu, 12 Apr 2018 05:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/7ra0VkxscIZHWNzbFl+6196JJf+zpXSl8EiR5vT2nU=; b=Jvmi5x6mfjVBsoWqgSLSv7bsgZeg9YOR9tq4oosyeOOmWl9bXNVU4I9lFIrCGN/cFL kZ2FTyxutykFjUQ8rtPjGIiQuJAtAxQcM4LNNdudH9tMRtnI/xRWFaSAPh3Uwt8X39mA kz3pcPrzmWbASTMh5TkGsj2c/9UGc5VuIAYr5Ghkp+HLAJ29gt3Dvo8a/P0O7I+DJxEZ JLqugCI8EBaO2bN6uxK7WBrFnGhy2Ms2ykr0lPEs8PdkmKCe/kOeQdefnvf9QHYixS5Z gPwnHHdQ/jxXn75mcVdzINwROjEjfQMshLqD6kwN42SfTTXI5YDVrvnieffiqhhT/PPB BDYA== 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; bh=/7ra0VkxscIZHWNzbFl+6196JJf+zpXSl8EiR5vT2nU=; b=qqEiCUfDLTE5wCKpkYmoOoLGnoD9a1a3arExJmpRNNu3ufVvHCLFcBktSyqHiiMrtY pPB7S2zrzDqfSd6PwQh2IuFeiBHoTlkedsT1LfYmcqCsbx5/AGXMoFysPrXH+ZLwHV7R wKMn821CxLIeTKouep7GthFOPIwM9elhRKKg5bL8pzBsLXccw3hpvoAi5GgbqwCuubRH tZgvB5LGBEZNmTXqKJFH0jKnao7KMovsgsV9bawNk6EOHmYcsaDxVBU1oAsBRufC+GAy rA1Tiyn97MehzCSXOgHPE2Xy96Yxv0fT46u9ONRYd4VIK9pQLl4vHnxtxbkIjCOiRD4q 5bxQ== X-Gm-Message-State: ALQs6tCQOTvmko8vTBIkQmFimbWaLmz9YsidNjAq/3g2knmgzIirfG8B GTWvD5NH2T+Zf5IxOctBMtTJ2ZrM X-Google-Smtp-Source: AIpwx4+HJpxAxxmVmTInRPt1Ch0HpqV0ltS/bh+NJf+3kxuPTQCXmr7pBx50TazoPVYf294Y946Jyw== X-Received: by 2002:a17:902:830b:: with SMTP id bd11-v6mr912285plb.13.1523537591388; Thu, 12 Apr 2018 05:53:11 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([52.229.160.192]) by smtp.gmail.com with ESMTPSA id x17sm7009505pfm.161.2018.04.12.05.53.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 05:53:10 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: dev@openvswitch.org Date: Thu, 12 Apr 2018 05:52:51 -0700 Message-Id: <1523537572-2595-6-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523537572-2595-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1523537572-2595-1-git-send-email-xiangxia.m.yue@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH net-next 5/6] netdev-dpdk: Add check whether dpdk-port is used X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Tonghao Zhang Extend the function, when looking up the dpdk netdev by port id, if the port id is a slave port id, return its master device. The patch changes the function 'netdev_dpdk_lookup_by_port_id'. Signed-off-by: Tonghao Zhang --- lib/netdev-dpdk.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index e1285d1..4ef7d9f 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1363,6 +1363,9 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) return 0; } +static bool +netdev_dpdk_bond_is_include(struct netdev_dpdk *dev, dpdk_port_t port_id); + static struct netdev_dpdk * netdev_dpdk_lookup_by_port_id(dpdk_port_t port_id) OVS_REQUIRES(dpdk_mutex) @@ -1370,7 +1373,8 @@ netdev_dpdk_lookup_by_port_id(dpdk_port_t port_id) struct netdev_dpdk *dev; LIST_FOR_EACH (dev, list_node, &dpdk_list) { - if (dev->port_id == port_id) { + if (dev->port_id == port_id || + netdev_dpdk_bond_is_include(dev, port_id)) { return dev; } } @@ -1432,6 +1436,19 @@ netdev_dpdk_bond_uninit(struct netdev_dpdk *dev) free(dev->bond); } +static bool +netdev_dpdk_bond_is_include(struct netdev_dpdk *dev, + dpdk_port_t port_id) +{ + LIST_EACH_VALID_BOND_SLAVE(dev->bond->slaves) { + if (dev->bond->slaves[i] == port_id) { + return true; + } + } + + return false; +} + /* Check the PCIs or device names requested whether * it's valid or not. */ static bool @@ -1439,6 +1456,7 @@ netdev_dpdk_bond_slave_request(const struct netdev_dpdk *dev OVS_UNUSED, const char *devargs, dpdk_port_t *rs) { dpdk_port_t port_id = DPDK_ETH_PORT_ID_INVALID; + struct netdev_dpdk *dpdk_dev = NULL; char *pci = NULL, *save_ptr = NULL; char *args = xstrdup(devargs); int i; @@ -1449,7 +1467,9 @@ netdev_dpdk_bond_slave_request(const struct netdev_dpdk *dev OVS_UNUSED, pci != NULL; pci = strtok_r(NULL, ",", &save_ptr), i++) { if (rte_eth_dev_get_port_by_name(pci, &port_id) || - !rte_eth_dev_is_valid_port(port_id)) { + !rte_eth_dev_is_valid_port(port_id) || + ((dpdk_dev = netdev_dpdk_lookup_by_port_id(port_id)) && + dpdk_dev != dev)) { VLOG_INFO("Could not get the port id from pci address " "or device name: %s, or the device is not attached, "