Skip to content

Commit

Permalink
bond: new link bonding library
Browse files Browse the repository at this point in the history
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Reviewed-by: Robert Sanford <rsanford2@gmail.com>
  • Loading branch information
declanwd authored and Thomas Monjalon committed Jul 1, 2014
1 parent 6e81eb5 commit 2efb58c
Show file tree
Hide file tree
Showing 12 changed files with 2,678 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/common_bsdapp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
#
CONFIG_RTE_LIBRTE_PMD_PCAP=y

#
# Compile link bonding PMD library
#
CONFIG_RTE_LIBRTE_PMD_BOND=y

#
# Do prefetch of packet data within PMD driver receive function
#
Expand Down
5 changes: 5 additions & 0 deletions config/common_linuxapp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
#
CONFIG_RTE_LIBRTE_PMD_PCAP=n

#
# Compile link bonding PMD library
#
CONFIG_RTE_LIBRTE_PMD_BOND=y

#
# Compile Xen PMD
#
Expand Down
1 change: 1 addition & 0 deletions doc/doxy-api-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ There are many libraries, so their headers may be grouped by topics:
- **device**:
[ethdev] (@ref rte_ethdev.h),
[devargs] (@ref rte_devargs.h),
[bond] (@ref rte_eth_bond.h),
[KNI] (@ref rte_kni.h),
[PCI] (@ref rte_pci.h),
[PCI IDs] (@ref rte_pci_dev_ids.h)
Expand Down
1 change: 1 addition & 0 deletions doc/doxy-api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ INPUT = doc/doxy-api-index.md \
lib/librte_pipeline \
lib/librte_port \
lib/librte_power \
lib/librte_pmd_bond \
lib/librte_ring \
lib/librte_sched \
lib/librte_table \
Expand Down
1 change: 1 addition & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
Expand Down
61 changes: 61 additions & 0 deletions lib/librte_pmd_bond/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# BSD LICENSE
#
# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

include $(RTE_SDK)/mk/rte.vars.mk

#
# library name
#
LIB = librte_pmd_bond.a

CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)

#
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_api.c
SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_pmd.c
SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_args.c

#
# Export include files
#
SYMLINK-y-include += rte_eth_bond.h

# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs

include $(RTE_SDK)/mk/rte.lib.mk
255 changes: 255 additions & 0 deletions lib/librte_pmd_bond/rte_eth_bond.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _RTE_ETH_BOND_H_
#define _RTE_ETH_BOND_H_

/**
* @file rte_bond.h
*
* RTE Link Bonding Ethernet Device
* Link Bonding for 1GbE and 10GbE ports to allow the aggregation of multiple
* (slave) NICs into a single logical interface. The bonded device processes
* these interfaces based on the mode of operation specified and supported.
* This implementation supports 4 modes of operation round robin, active backup
* balance and broadcast. Providing redundant links, fault tolerance and/or
* load balancing of network ports
*/

#ifdef __cplusplus
extern "C" {
#endif

#include <rte_ether.h>

/* Supported modes of operation of link bonding library */

#define BONDING_MODE_ROUND_ROBIN (0)
/**< Round Robin (Mode 0).
* In this mode all transmitted packets will be balanced equally across all
* active slaves of the bonded in a round robin fashion. */
#define BONDING_MODE_ACTIVE_BACKUP (1)
/**< Active Backup (Mode 1).
* In this mode all packets transmitted will be transmitted on the primary
* slave until such point as the primary slave is no longer available and then
* transmitted packets will be sent on the next available slaves. The primary
* slave can be defined by the user but defaults to the first active slave
* available if not specified. */
#define BONDING_MODE_BALANCE (2)
/**< Balance (Mode 2).
* In this mode all packets transmitted will be balanced across the available
* slaves using one of three available transmit policies - l2, l2+3 or l3+4.
* See BALANCE_XMIT_POLICY macros definitions for further details on transmit
* policies. */
#define BONDING_MODE_BROADCAST (3)
/**< Broadcast (Mode 3).
* In this mode all transmitted packets will be transmitted on all available
* active slaves of the bonded. */

/* Balance Mode Transmit Policies */
#define BALANCE_XMIT_POLICY_LAYER2 (0)
/**< Layer 2 (Ethernet MAC) */
#define BALANCE_XMIT_POLICY_LAYER23 (1)
/**< Layer 2+3 (Ethernet MAC + IP Addresses) transmit load balancing */
#define BALANCE_XMIT_POLICY_LAYER34 (2)
/**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */

/**
* Create a bonded rte_eth_dev device
*
* @param name Name of new link bonding device.
* @param mode Mode to initialize bonding device in.
* @param socket_id Socket Id on which to allocate eth_dev resources.
*
* @return
* Port Id of created rte_eth_dev on success, negative value otherwise
*/
int
rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id);

/**
* Add a rte_eth_dev device as a slave to the bonded device
*
* @param bonded_port_id Port ID of bonded device.
* @param slave_port_id Port ID of slave device.
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id);

/**
* Remove a slave rte_eth_dev device from the bonded device
*
* @param bonded_port_id Port ID of bonded device.
* @param slave_port_id Port ID of slave device.
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id);

/**
* Set link bonding mode of bonded device
*
* @param bonded_port_id Port ID of bonded device.
* @param mode Bonding mode to set
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode);

/**
* Get link bonding mode of bonded device
*
* @param bonded_port_id Port ID of bonded device.
*
* @return
* link bonding mode on success, negative value otherwise
*/
int
rte_eth_bond_mode_get(uint8_t bonded_port_id);

/**
* Set slave rte_eth_dev as primary slave of bonded device
*
* @param bonded_port_id Port ID of bonded device.
* @param slave_port_id Port ID of slave device.
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id);

/**
* Get primary slave of bonded device
*
* @param bonded_port_id Port ID of bonded device.
*
* @return
* Port Id of primary slave on success, -1 on failure
*/
int
rte_eth_bond_primary_get(uint8_t bonded_port_id);

/**
* Populate an array with list of the slaves port id's of the bonded device
*
* @param bonded_port_id Port ID of bonded eth_dev to interrogate
* @param slaves Array to be populated with the current active slaves
* @param len Length of slaves array
*
* @return
* Number of slaves associated with bonded device on success,
* negative value otherwise
*/
int
rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len);

/**
* Populate an array with list of the active slaves port id's of the bonded
* device.
*
* @param bonded_port_id Port ID of bonded eth_dev to interrogate
* @param slaves Array to be populated with the current active slaves
* @param len Length of slaves array
*
* @return
* Number of active slaves associated with bonded device on success,
* negative value otherwise
*/
int
rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
uint8_t len);

/**
* Set explicit MAC address to use on bonded device and it's slaves.
*
* @param bonded_port_id Port ID of bonded device.
* @param mac_addr MAC Address to use on bonded device overriding
* slaves MAC addresses
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
struct ether_addr *mac_addr);

/**
* Reset bonded device to use MAC from primary slave on bonded device and it's
* slaves.
*
* @param bonded_port_id Port ID of bonded device.
*
* @return
* 0 on success, negative value otherwise
*/
int
rte_eth_bond_mac_address_reset(uint8_t bonded_port_id);

/**
* Set the transmit policy for bonded device to use when it is operating in
* balance mode, this parameter is otherwise ignored in other modes of
* operation.
*
* @param bonded_port_id Port ID of bonded device.
* @param policy Balance mode transmission policy.
*
* @return
* 0 on success, negative value otherwise.
*/
int
rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);

/**
* Get the transmit policy set on bonded device for balance mode operation
*
* @param bonded_port_id Port ID of bonded device.
*
* @return
* Balance transmit policy on success, negative value otherwise.
*/
int
rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 2efb58c

Please sign in to comment.