Skip to contentSkip to conversation

bonding corrections and additions

PATCH Superseded Eric Kinzie 2 participants 6 messages Sep 30, 2015 – Oct 19, 2015

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover bonding corrections and additions

This patchset makes a couple of small corrections to the bonding driver and introduces the ability to use an external state machine for mode 4 operation.

Changes in v2:
. eliminate external_sm field in 802.3ad configuration

    (rte_eth_bond_8023ad_conf).

. stop bonding device before changing the periodic callback function.
start again if needed.
. remove unnecessary calls to valid_bonded_port_id().
. do not check for NULL tx_ring.
. return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP. . remove check for external sm configuration in periodic callback . check for valid LACPDU in test application's rx callback
. add "Fixes:" tags

Changes in v3:
. update rte_eth_bond_version.map

Changes in v4:
. version functions that modify slowrx_cb

Changes in v5:
. remove "__vsym" from source files and use updated symbol version macros

Eric Kinzie (4):
bond mode 4: copy entire config structure
bond mode 4: do not ignore multicast
bond mode 4: allow external state machine
bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c                |  217 ++++++++++++++++++-
 drivers/net/bonding/Makefile                      |    2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c         |  241 ++++++++++++++++++++-
 drivers/net/bonding/rte_eth_bond_8023ad.h         |   44 ++++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_pmd.c            |    1 +
 drivers/net/bonding/rte_eth_bond_version.map      |    3 +
 7 files changed, 522 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v5 1/4 bond mode 4: copy entire config structure

From: Eric Kinzie <[email protected]>

Copy all needed fields from the mode8023ad_private structure in bond_mode_8023ad_conf_get(). This help ensure that a subsequent call to rte_eth_bond_8023ad_setup() is not passed uninitialized data that would result in either incorrect behavior or a failed sanity check.

Fixes 46fb43683679 ("bond: add mode 4")
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -0
index c0f0b99..08f679f 100644
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
 	conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / ms_ticks;
 	conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
 	conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+	conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }
 
 void
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v5 2/4 bond mode 4: do not ignore multicast

In reply to Eric Kinzie

From: Eric Kinzie <[email protected]>

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous mode in order to receive LACPDUs and must filter unwanted packets after the traffic has been "collected". Allow broadcast and multicast through so that ARP and IPv6 neighbor discovery continue to work.

Fixes 46fb43683679 ("bond: add mode 4")
---
 app/test/test_link_bonding_mode4.c     |    7 +++++--
 drivers/net/bonding/rte_eth_bond_pmd.c |    1 +
 2 files changed, 6 insertions(+), 2 deletions(-)
app/test/test_link_bonding_mode4.c +5 -2
index 460539d..d785393 100644
@@ -749,8 +749,11 @@ test_mode4_rx(void)
 	rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
 	ether_addr_copy(&bonded_mac, &dst_mac);
 
-	/* Assert that dst address is not bonding address */
-	dst_mac.addr_bytes[0]++;
+	/* Assert that dst address is not bonding address.  Do not set the
+	 * least significant bit of the zero byte as this would create a
+	 * multicast address.
+	 */
+	dst_mac.addr_bytes[0] += 2;
 
 	/* First try with promiscuous mode enabled.
 	 * Add 2 packets to each slave. First with bonding MAC address, second with
drivers/net/bonding/rte_eth_bond_pmd.c +1 -0
index 5cc6372..733022b 100644
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs,
 			 * mode and packet address does not match. */
 			if (unlikely(hdr->ether_type == ether_type_slow_be ||
 				!collecting || (!promisc &&
+					!is_multicast_ether_addr(&hdr->d_addr) &&
 					!is_same_ether_addr(&bond_mac, &hdr->d_addr)))) {
 
 				if (hdr->ether_type == ether_type_slow_be) {
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v5 3/4 bond mode 4: allow external state machine

In reply to Eric Kinzie

From: Eric Kinzie <[email protected]>

Provide functions to allow an external 802.3ad state machine to transmit and recieve LACPDUs and to set the collection/distribution flags on slave interfaces.

Size of struct rte_eth_bond_8023ad_conf changed. Increment LIBABIVER and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get functions.

---
 drivers/net/bonding/Makefile                      |    2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c         |  240 ++++++++++++++++++++-
 drivers/net/bonding/rte_eth_bond_8023ad.h         |   44 ++++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_version.map      |    3 +
 5 files changed, 314 insertions(+), 3 deletions(-)
drivers/net/bonding/Makefile +1 -1
index dee0875..8b892ca 100644
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 EXPORT_MAP := rte_eth_bond_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
drivers/net/bonding/rte_eth_bond_8023ad.c +238 -2

285 lines not on this page · raw message

drivers/net/bonding/rte_eth_bond_8023ad.h +44 -0

60 lines not on this page · raw message

drivers/net/bonding/rte_eth_bond_8023ad_private.h +28 -0
index 8adee70..cb39004 100644
@@ -39,6 +39,7 @@
 #include <rte_ether.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
+#include <rte_compat.h>
 
 #include "rte_eth_bond_8023ad.h"
 
@@ -173,6 +174,8 @@ struct mode8023ad_private {
 	uint64_t tx_period_timeout;
 	uint64_t rx_marker_timeout;
 	uint64_t update_timeout_us;
+	rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb;
+	uint8_t external_sm;
 };
 
 /**
@@ -211,6 +214,31 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
 void
 bond_mode_8023ad_setup(struct rte_eth_dev *dev,
 		struct rte_eth_bond_8023ad_conf *conf);
+void __vsym
+bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev,
+		struct rte_eth_bond_8023ad_conf *conf);
+void __vsym
+bond_mode_8023ad_setup_v21(struct rte_eth_dev *dev,
+		struct rte_eth_bond_8023ad_conf *conf);
+
+/**
+ * @internal
+ *
+ * Retreive mode 4 configuration of bonded interface.
+ *
+ * @param dev Bonded interface
+ * @param conf Bonded interface configuration
+ */
+void
+bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
+		struct rte_eth_bond_8023ad_conf *conf);
+void __vsym
+bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev,
+		struct rte_eth_bond_8023ad_conf *conf);
+void __vsym
+bond_mode_8023ad_conf_get_v21(struct rte_eth_dev *dev,
+		struct rte_eth_bond_8023ad_conf *conf);
+
 
 /**
  * @internal
drivers/net/bonding/rte_eth_bond_version.map +3 -0
index 22bd920..0b76e41 100644
@@ -17,6 +17,9 @@ DPDK_2.0 {
 	rte_eth_bond_slaves_get;
 	rte_eth_bond_xmit_policy_get;
 	rte_eth_bond_xmit_policy_set;
+	rte_eth_bond_8023ad_ext_collect;
+	rte_eth_bond_8023ad_ext_distrib;
+	rte_eth_bond_8023ad_ext_slowtx;
 
 	local: *;
 };
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v5 4/4 bond mode 4: tests for external state machine

In reply to Eric Kinzie

From: Eric Kinzie <[email protected]>

This adds test cases for exercising the external state machine API to the mode 4 autotest.

---
 app/test/test_link_bonding_mode4.c |  210 ++++++++++++++++++++++++++++++++++--
 1 file changed, 201 insertions(+), 9 deletions(-)
app/test/test_link_bonding_mode4.c +201 -9
index d785393..6a459cd 100644
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
 	.lpbk_mode = 0,
 };
 
+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
 	for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); _i++)
 
@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
 	return 0;
 }
 
+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+	struct ether_hdr *hdr;
+	struct slow_protocol_frame *slow_hdr;
+
+	RTE_VERIFY(lacp_pkt != NULL);
+
+	hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+	RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+	slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+	RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+	lacpdu_rx_count[slave_id]++;
+	rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
 	uint8_t i;
 
@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
 	rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
 	rte_eth_promiscuous_disable(test_params.bonded_port_id);
 
-	if (start)
-		TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-			"Failed to start bonded device");
+	if (external_sm) {
+		struct rte_eth_bond_8023ad_conf conf;
+
+		rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+		conf.slowrx_cb = lacp_recv_cb;
+		rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+	}
+
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+		"Failed to start bonded device");
 
 	return TEST_SUCCESS;
 }
@@ -642,7 +670,7 @@ test_mode4_lacp(void)
 {
 	int retval;
 
-	retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+	retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
 	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
 
 	/* Test LACP handshake function */
@@ -740,7 +768,7 @@ test_mode4_rx(void)
 	struct ether_addr dst_mac;
 	struct ether_addr bonded_mac;
 
-	retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 1);
+	retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 0);
 	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
 
 	retval = bond_handshake();
@@ -917,7 +945,7 @@ test_mode4_tx_burst(void)
 	struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
 	struct ether_addr bonded_mac;
 
-	retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+	retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
 	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
 
 	retval = bond_handshake();
@@ -1101,7 +1129,7 @@ test_mode4_marker(void)
 	uint8_t i, j;
 	const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);
 
-	retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 1);
+	retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 0);
 	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
 
 	/* Test LACP handshake function */
@@ -1186,7 +1214,7 @@ test_mode4_expired(void)
 
 	struct rte_eth_bond_8023ad_conf conf;
 
-	retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 1);
+	retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 0);
 	/* Set custom timeouts to make test last shorter. */
 	rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
 	conf.fast_periodic_ms = 100;
@@ -1268,6 +1296,156 @@ test_mode4_expired(void)
 }
 
 static int
+test_mode4_ext_ctrl(void)
+{
+	/*
+	 * configure bonded interface without the external sm enabled
+	 *   . try to transmit lacpdu (should fail)
+	 *   . try to set collecting and distributing flags (should fail)
+	 * reconfigure w/external sm
+	 *   . transmit one lacpdu on each slave using new api
+	 *   . make sure each slave receives one lacpdu using the callback api
+	 *   . transmit one data pdu on each slave (should fail)
+	 *   . enable distribution and collection, send one data pdu each again
+	 */
+
+	int retval;
+	struct slave_conf *slave = NULL;
+	uint8_t i;
+
+	struct rte_mbuf *lacp_tx_buf[SLAVE_COUNT];
+	struct ether_addr src_mac, dst_mac;
+	struct lacpdu_header lacpdu = {
+		.lacpdu = {
+			.subtype = SLOW_SUBTYPE_LACP,
+		},
+	};
+
+	ether_addr_copy(&parnter_system, &src_mac);
+	ether_addr_copy(&slow_protocol_mac_addr, &dst_mac);
+
+	initialize_eth_header(&lacpdu.eth_hdr, &src_mac, &dst_mac,
+			      ETHER_TYPE_SLOW, 0, 0);
+
+	for (i = 0; i < SLAVE_COUNT; i++) {
+		lacp_tx_buf[i] = rte_pktmbuf_alloc(test_params.mbuf_pool);
+		rte_memcpy(rte_pktmbuf_mtod(lacp_tx_buf[i], char *),
+			   &lacpdu, sizeof(lacpdu));
+		rte_pktmbuf_pkt_len(lacp_tx_buf[i]) = sizeof(lacpdu);
+	}
+
+	retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
+	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
+
+	FOR_EACH_SLAVE(i, slave) {
+		TEST_ASSERT_FAIL(rte_eth_bond_8023ad_ext_slowtx(
+						test_params.bonded_port_id,
+						slave->port_id, lacp_tx_buf[i]),
+				 "Slave should not allow manual LACP xmit");
+		TEST_ASSERT_FAIL(rte_eth_bond_8023ad_ext_collect(
+						test_params.bonded_port_id,
+						slave->port_id, 1),
+				 "Slave should not allow external state controls");
+	}
+
+	free_pkts(lacp_tx_buf, RTE_DIM(lacp_tx_buf));
+
+	retval = remove_slaves_and_stop_bonded_device();
+	TEST_ASSERT_SUCCESS(retval, "Bonded device cleanup failed.");
+
+	return TEST_SUCCESS;
+}
+
+
+static int
+test_mode4_ext_lacp(void)
+{
+	int retval;
+	struct slave_conf *slave = NULL;
+	uint8_t all_slaves_done = 0, i;
+	uint16_t nb_pkts;
+	const unsigned delay = bond_get_update_timeout_ms();
+
+	struct rte_mbuf *lacp_tx_buf[SLAVE_COUNT];
+	struct rte_mbuf *buf[SLAVE_COUNT];
+	struct ether_addr src_mac, dst_mac;
+	struct lacpdu_header lacpdu = {
+		.lacpdu = {
+			.subtype = SLOW_SUBTYPE_LACP,
+		},
+	};
+
+	ether_addr_copy(&parnter_system, &src_mac);
+	ether_addr_copy(&slow_protocol_mac_addr, &dst_mac);
+
+	initialize_eth_header(&lacpdu.eth_hdr, &src_mac, &dst_mac,
+			      ETHER_TYPE_SLOW, 0, 0);
+
+	for (i = 0; i < SLAVE_COUNT; i++) {
+		lacp_tx_buf[i] = rte_pktmbuf_alloc(test_params.mbuf_pool);
+		rte_memcpy(rte_pktmbuf_mtod(lacp_tx_buf[i], char *),
+			   &lacpdu, sizeof(lacpdu));
+		rte_pktmbuf_pkt_len(lacp_tx_buf[i]) = sizeof(lacpdu);
+	}
+
+	retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+	TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
+
+	memset(lacpdu_rx_count, 0, sizeof(lacpdu_rx_count));
+
+	/* Wait for new settings to be applied. */
+	for (i = 0; i < 30; ++i)
+		rte_delay_ms(delay);
+
+	FOR_EACH_SLAVE(i, slave) {
+		retval = rte_eth_bond_8023ad_ext_slowtx(
+						test_params.bonded_port_id,
+						slave->port_id, lacp_tx_buf[i]);
+		TEST_ASSERT_SUCCESS(retval,
+				    "Slave should allow manual LACP xmit");
+	}
+
+	nb_pkts = bond_tx(NULL, 0);
+	TEST_ASSERT_EQUAL(nb_pkts, 0, "Packets transmitted unexpectedly");
+
+	FOR_EACH_SLAVE(i, slave) {
+		nb_pkts = slave_get_pkts(slave, buf, RTE_DIM(buf));
+		TEST_ASSERT_EQUAL(nb_pkts, 1, "found %u packets on slave %d\n",
+				  nb_pkts, i);
+		slave_put_pkts(slave, buf, nb_pkts);
+	}
+
+	nb_pkts = bond_rx(buf, RTE_DIM(buf));
+	free_pkts(buf, nb_pkts);
+	TEST_ASSERT_EQUAL(nb_pkts, 0, "Packets received unexpectedly");
+
+	/* wait for the periodic callback to run */
+	for (i = 0; i < 30 && all_slaves_done == 0; ++i) {
+		uint8_t s, total = 0;
+
+		rte_delay_ms(delay);
+		FOR_EACH_SLAVE(s, slave) {
+			total += lacpdu_rx_count[slave->port_id];
+		}
+
+		if (total >= SLAVE_COUNT)
+			all_slaves_done = 1;
+	}
+
+	FOR_EACH_SLAVE(i, slave) {
+		TEST_ASSERT_EQUAL(lacpdu_rx_count[slave->port_id], 1,
+				  "Slave port %u should have received 1 lacpdu (count=%u)",
+				  slave->port_id,
+				  lacpdu_rx_count[slave->port_id]);
+	}
+
+	retval = remove_slaves_and_stop_bonded_device();
+	TEST_ASSERT_SUCCESS(retval, "Test cleanup failed.");
+
+	return TEST_SUCCESS;
+}
+
+static int
 check_environment(void)
 {
 	struct slave_conf *port;
@@ -1383,6 +1561,18 @@ test_mode4_expired_wrapper(void)
 	return test_mode4_executor(&test_mode4_expired);
 }
 
+static int
+test_mode4_ext_ctrl_wrapper(void)
+{
+	return test_mode4_executor(&test_mode4_ext_ctrl);
+}
+
+static int
+test_mode4_ext_lacp_wrapper(void)
+{
+	return test_mode4_executor(&test_mode4_ext_lacp);
+}
+
 static struct unit_test_suite link_bonding_mode4_test_suite  = {
 	.suite_name = "Link Bonding mode 4 Unit Test Suite",
 	.setup = test_setup,
@@ -1393,6 +1583,8 @@ static struct unit_test_suite link_bonding_mode4_test_suite  = {
 		TEST_CASE_NAMED("test_mode4_tx_burst", test_mode4_tx_burst_wrapper),
 		TEST_CASE_NAMED("test_mode4_marker", test_mode4_marker_wrapper),
 		TEST_CASE_NAMED("test_mode4_expired", test_mode4_expired_wrapper),
+		TEST_CASE_NAMED("test_mode4_ext_ctrl", test_mode4_ext_ctrl_wrapper),
+		TEST_CASE_NAMED("test_mode4_ext_lacp", test_mode4_ext_lacp_wrapper),
 		{ NULL, NULL, NULL, NULL, NULL } /**< NULL terminate unit test array */
 	}
 };
Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Eric Kinzie
Quoted 31 lines · Eric Kinzie

This patchset makes a couple of small corrections to the bonding driver and introduces the ability to use an external state machine for mode 4 operation.

Changes in v2:
. eliminate external_sm field in 802.3ad configuration

     (rte_eth_bond_8023ad_conf).

. stop bonding device before changing the periodic callback function.
start again if needed.
. remove unnecessary calls to valid_bonded_port_id().
. do not check for NULL tx_ring.
. return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP. . remove check for external sm configuration in periodic callback . check for valid LACPDU in test application's rx callback
. add "Fixes:" tags

Changes in v3:
. update rte_eth_bond_version.map

Changes in v4:
. version functions that modify slowrx_cb

Changes in v5:
. remove "__vsym" from source files and use updated symbol version macros

Eric Kinzie (4):
bond mode 4: copy entire config structure
bond mode 4: do not ignore multicast
bond mode 4: allow external state machine
bond mode 4: tests for external state machine

Quoted 9 lines
  app/test/test_link_bonding_mode4.c                |  217 ++++++++++++++++++-
  drivers/net/bonding/Makefile                      |    2 +-
  drivers/net/bonding/rte_eth_bond_8023ad.c         |  241 ++++++++++++++++++++-
  drivers/net/bonding/rte_eth_bond_8023ad.h         |   44 ++++
  drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
  drivers/net/bonding/rte_eth_bond_pmd.c            |    1 +
  drivers/net/bonding/rte_eth_bond_version.map      |    3 +
  7 files changed, 522 insertions(+), 14 deletions(-)

Hey Eric, the patch set looks good, the only issue is that the versioning referrers to 2.1 now instead of 2.2, if you could fix that, I'll ack straight away.

Thanks
Declan