From patchwork Wed Jul 5 14:58:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Doherty, Declan" X-Patchwork-Id: 26508 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1080B5592; Wed, 5 Jul 2017 17:01:57 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7231F2C13 for ; Wed, 5 Jul 2017 17:01:53 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jul 2017 08:01:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,312,1496127600"; d="scan'208";a="123019904" Received: from dwdohert-dpdk.ir.intel.com ([163.33.210.152]) by fmsmga006.fm.intel.com with ESMTP; 05 Jul 2017 08:01:52 -0700 From: Declan Doherty To: dev@dpdk.org Cc: Tomasz Kulasek , Declan Doherty Date: Wed, 5 Jul 2017 15:58:55 +0100 Message-Id: <20170705145855.14759-2-declan.doherty@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170705145855.14759-1-declan.doherty@intel.com> References: <20170629173035.13140-1-tomaszx.kulasek@intel.com> <20170705145855.14759-1-declan.doherty@intel.com> Subject: [dpdk-dev] [PATCH v3 2/2] net/bond: allow slaves to also be bonded devices 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tomasz Kulasek This patch removes restrictions in bonded device library which prevent a bonded device to be added to another bonded device with the limitation that 802.3ad mode is not supported if one or more slaves is also a bonded device, --- v3: reworked link management changes and split into separate patch v2 changes: - added dynamic link speed recalculation for a bonding Signed-off-by: Tomasz Kulasek Signed-off-by: Declan Doherty --- drivers/net/bonding/rte_eth_bond_api.c | 28 +++++++++++++++++----------- drivers/net/bonding/rte_eth_bond_private.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 82c4499..824ab4f 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,13 +63,18 @@ valid_bonded_port_id(uint8_t port_id) } int -valid_slave_port_id(uint8_t port_id) +valid_slave_port_id(uint8_t port_id, uint8_t mode) { RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); /* Verify that port_id refers to a non bonded port */ - if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0) + if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0 && + mode == BONDING_MODE_8023AD) { + RTE_BOND_LOG(ERR, "Cannot add slave to bonded device in 802.3ad" + " mode as slave is also a bonded device, only " + "physical devices can be support in this mode."); return -1; + } return 0; } @@ -235,12 +240,12 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id) struct rte_eth_link link_props; struct rte_eth_dev_info dev_info; - if (valid_slave_port_id(slave_port_id) != 0) - return -1; - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; + if (valid_slave_port_id(slave_port_id, internals->mode) != 0) + return -1; + slave_eth_dev = &rte_eth_devices[slave_port_id]; if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { RTE_BOND_LOG(ERR, "Slave device is already a slave of a bonded device"); @@ -389,12 +394,12 @@ __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id) struct rte_eth_dev *slave_eth_dev; int i, slave_idx; - if (valid_slave_port_id(slave_port_id) != 0) - return -1; - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; + if (valid_slave_port_id(slave_port_id, internals->mode) < 0) + return -1; + /* first remove from active slave list */ slave_idx = find_slave_by_id(internals->active_slaves, internals->active_slave_count, slave_port_id); @@ -509,13 +514,14 @@ rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id) { struct bond_dev_private *internals; + internals = rte_eth_devices[bonded_port_id].data->dev_private; + if (valid_bonded_port_id(bonded_port_id) != 0) return -1; - if (valid_slave_port_id(slave_port_id) != 0) + if (valid_slave_port_id(slave_port_id, internals->mode) != 0) return -1; - internals = rte_eth_devices[bonded_port_id].data->dev_private; internals->user_defined_primary_port = 1; internals->primary_port = slave_port_id; diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index 7295192..8fbf4bf 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -204,7 +204,7 @@ int valid_bonded_port_id(uint8_t port_id); int -valid_slave_port_id(uint8_t port_id); +valid_slave_port_id(uint8_t port_id, uint8_t mode); void deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id);