SHA256
1
0
forked from pool/dpdk
dpdk/0015-bonding-fix-detach-of-slave-devices.patch

148 lines
5.4 KiB
Diff
Raw Normal View History

Accepting request 399089 from home:ndas:branches:network - Applied all the fixes recommended by upstream for v2.2 stable release(bsc#981996). [+0008-app-testpmd-handle-SIGINT-and-SIGTERM.patch, +0009-bonding-copy-entire-config-structure-in-mode-4.patch, +0010-bonding-fix-active-slaves-with-no-primary.patch, +0011-bonding-do-not-ignore-multicast-in-mode-4.patch, +0012-bonding-do-not-activate-slave-twice.patch, +0013-bonding-fix-crash-when-no-slave-device.patch, +0014-bonding-fix-detach-of-bonded-device.patch, +0015-bonding-fix-detach-of-slave-devices.patch, +0016-eal-linux-support-built-in-kernel-modules.patch, +0017-examples-l3fwd-handle-SIGINT-and-SIGTERM.patch, +0018-fm10k-fix-VLAN-flag-in-scattered-Rx.patch, +0019-i40e-base-fix-driver-load-failure.patch, +0020-i40e-base-fix-missing-check-for-stopped-admin-queue.patch, +0021-i40e-fix-inverted-check-for-no-refcount.patch, +0022-i40e-fix-overflow.patch, +0023-i40e-fix-VLAN-filtering.patch, +0024-mempool-fix-leak-when-creation-fails.patch, +0025-pcap-fix-captured-frame-length.patch, +0026-port-fix-crash-for-ethdev-writer-nodrop.patch, +0027-port-fix-crash-for-ring-writer-nodrop.patch, +0028-tools-fix-unbinding-failure-handling.patch, +0029-tools-support-Python-3-in-bind-script.patch, +0030-tools-support-binding-to-built-in-kernel-modules.patch, +0031-vhost-fix-leak-of-fds-and-mmaps.patch, +0032-virtio-fix-crash-in-statistics-functions.patch, +0033-virtio-fix-descriptors-pointing-to-the-same-buffer.patch, +0034-virtio-fix-restart.patch] OBS-URL: https://build.opensuse.org/request/show/399089 OBS-URL: https://build.opensuse.org/package/show/network/dpdk?expand=0&rev=3
2016-05-31 13:30:42 +02:00
From df3e8ad73f4c92b4eb8f49ff33271d4a09e6a04a Mon Sep 17 00:00:00 2001
From: Bernard Iremonger <bernard.iremonger@intel.com>
Date: Wed, 10 Feb 2016 10:13:45 +0000
Subject: [PATCH] bonding: fix detach of slave devices
Ensure that a bonded slave device is not detached,
until it is removed from the bonded device.
Fixes: 2efb58cbab6e ("bond: new link bonding library")
Fixes: a45b288ef21a ("bond: support link status polling")
Fixes: 494adb7f63f2 ("ethdev: add device fields from PCI layer")
Fixes: b1fb53a39d88 ("ethdev: remove some PCI specific handling")
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
---
drivers/net/bonding/rte_eth_bond_api.c | 33 +++++++++++----------------------
lib/librte_ether/rte_ethdev.c | 8 ++++++--
lib/librte_ether/rte_ethdev.h | 2 ++
3 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 484a6f3..a0995ec 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -314,38 +314,23 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
{
struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
struct bond_dev_private *internals;
- struct bond_dev_private *temp_internals;
struct rte_eth_link link_props;
struct rte_eth_dev_info dev_info;
- int i, j;
-
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;
- /* Verify that new slave device is not already a slave of another
- * bonded device */
- for (i = rte_eth_dev_count()-1; i >= 0; i--) {
- if (check_for_bonded_ethdev(&rte_eth_devices[i]) == 0) {
- temp_internals = rte_eth_devices[i].data->dev_private;
-
- for (j = 0; j < temp_internals->slave_count; j++) {
- /* Device already a slave of a bonded device */
- if (temp_internals->slaves[j].port_id == slave_port_id) {
- RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
- slave_port_id);
- 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");
+ return -1;
+ }
/* Add slave details to bonded device */
+ slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
slave_add(internals, slave_eth_dev);
rte_eth_dev_info_get(slave_port_id, &dev_info);
@@ -385,6 +370,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
if (internals->link_props_set) {
if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
&(slave_eth_dev->data->dev_link))) {
+ slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
RTE_BOND_LOG(ERR,
"Slave port %d link speed/duplex not supported",
slave_port_id);
@@ -416,6 +402,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
if (bonded_eth_dev->data->dev_started) {
if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
+ slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
slave_port_id);
return -1;
@@ -468,7 +455,7 @@ __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
{
struct rte_eth_dev *bonded_eth_dev;
struct bond_dev_private *internals;
-
+ struct rte_eth_dev *slave_eth_dev;
int i, slave_idx;
if (valid_slave_port_id(slave_port_id) != 0)
@@ -508,7 +495,9 @@ __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
mac_address_set(&rte_eth_devices[slave_port_id],
&(internals->slaves[slave_idx].persisted_mac_addr));
- slave_remove(internals, &rte_eth_devices[slave_port_id]);
+ slave_eth_dev = &rte_eth_devices[slave_port_id];
+ slave_remove(internals, slave_eth_dev);
+ slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
/* first slave in the active list will be the primary by default,
* otherwise use first device in list */
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f0e7473..db35102 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -495,7 +495,11 @@ rte_eth_dev_is_detachable(uint8_t port_id)
return -ENOTSUP;
}
dev_flags = rte_eth_devices[port_id].data->dev_flags;
- return !(dev_flags & RTE_ETH_DEV_DETACHABLE);
+ if ((dev_flags & RTE_ETH_DEV_DETACHABLE) &&
+ (!(dev_flags & RTE_ETH_DEV_BONDED_SLAVE)))
+ return 0;
+ else
+ return 1;
}
/* attach the new physical device, then store port_id of the device */
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d867976..b5704e1 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1662,6 +1662,8 @@ struct rte_eth_dev_data {
#define RTE_ETH_DEV_DETACHABLE 0x0001
/** Device supports link state interrupt */
#define RTE_ETH_DEV_INTR_LSC 0x0002
+/** Device is a bonded slave */
+#define RTE_ETH_DEV_BONDED_SLAVE 0x0004
/**
* @internal
--
2.6.2