net/bonding: Support configuration for LACP fast timers
diff mbox series

Message ID 41992913-213C-4922-9893-35F3B516A872@juniper.net
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • net/bonding: Support configuration for LACP fast timers
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/iol-testing fail Testing issues
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch warning coding style issues

Commit Message

Kiran KN April 21, 2020, 7:53 a.m. UTC
Add a rte APIs to set/get the timeout for LACP

signed-off-by: Kiran KN <kirankn@juniper.net>

---
 drivers/net/bonding/eth_bond_private.h    |  8 ++++++++
 drivers/net/bonding/rte_eth_bond.h        | 26 ++++++++++++++++++++++++++
 drivers/net/bonding/rte_eth_bond_8023ad.c |  6 ++++++
 drivers/net/bonding/rte_eth_bond_8023ad.h |  9 +++++++++
 drivers/net/bonding/rte_eth_bond_api.c    | 27 +++++++++++++++++++++++++++
 drivers/net/bonding/rte_eth_bond_args.c   | 25 +++++++++++++++++++++++++
 drivers/net/bonding/rte_eth_bond_pmd.c    | 30 +++++++++++++++++++++++++++++-
 7 files changed, 130 insertions(+), 1 deletion(-)

Comments

Min Hu (Connor) Nov. 25, 2020, 12:10 p.m. UTC | #1
+/* LACP Rate */
+#define LACP_RATE_SLOW  (0)
+#define LACP_RATE_FAST  (1)

parentheses here can be deleted.


		/* Set balance mode transmit policy*/
		
blank space shoud be added before "*/".
+		if (rte_eth_bond_lacp_rate_set(port_id, lacp_rate)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lacp rate on bonded device %s\n", name);
+			return -1;
+		}


Add a rte APIs to set/get the timeout for LACP

signed-off-by: Kiran KN <kirankn@juniper.net>

By the way, I wish commit info can be more detailed for
These two APIs£¬then we can know the API functino more.
thanks.

Patch
diff mbox series

diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index c9b2d0fe4..8bab10ee1 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -28,11 +28,14 @@ 
 #define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
 #define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
 #define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
+#define PMD_BOND_LACP_RATE_KVARG			("lacp_rate")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define PMD_BOND_LACP_RATE_FAST_KVARG		("fast")
+#define PMD_BOND_LACP_RATE_SLOW_KVARG		("slow")
 extern int bond_logtype;
 
 #define RTE_BOND_LOG(lvl, msg, ...)		\
@@ -180,6 +183,7 @@  struct bond_dev_private {
 
 	void *vlan_filter_bmpmem;		/* enabled vlan filter bitmap */
 	struct rte_bitmap *vlan_filter_bmp;
+	uint8_t lacp_rate;
 };
 
 extern const struct eth_dev_ops default_dev_ops;
@@ -306,6 +310,10 @@  int
 bond_ethdev_parse_time_ms_kvarg(const char *key,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_lacp_rate_kvarg(const char *key,
+		const char *value, void *extra_args);
+
 void
 bond_tlb_disable(struct bond_dev_private *internals);
 
diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index 874aa91a5..0e90ba2cf 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -88,6 +88,10 @@  extern "C" {
 #define BALANCE_XMIT_POLICY_LAYER34		(2)
 /**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */
 
+/* LACP Rate */
+#define LACP_RATE_SLOW  (0)
+#define LACP_RATE_FAST  (1)
+
 /**
  * Create a bonded rte_eth_dev device
  *
@@ -343,6 +347,28 @@  rte_eth_bond_link_up_prop_delay_set(uint16_t bonded_port_id,
 int
 rte_eth_bond_link_up_prop_delay_get(uint16_t bonded_port_id);
 
+/**
+ * Set the lacp rate for the slave interface
+ *
+ * @param bonded_port_id    Port ID of bonded device.
+ * @param lacp_rate     0 - slow, 1 - fast
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_lacp_rate_set(uint16_t bonded_port_id, uint8_t lacp_rate);
+
+/**
+ * Get the lacp rate for the slave device
+ *
+ * @param bonded_port_id    Port ID of bonded device.
+ *
+ * @return
+ *  lacp rate on success, negative value otherwise.
+ */
+int
+rte_eth_bond_lacp_rate_get(uint16_t bonded_port_id);
 
 #ifdef __cplusplus
 }
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index b77a37ddb..e3159004a 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -491,6 +491,12 @@  mux_machine(struct bond_dev_private *internals, uint16_t slave_id)
 		MODE4_DEBUG("Out of sync -> ATTACHED\n");
 	}
 
+	if (internals->lacp_rate)
+		ACTOR_STATE_SET(port, LACP_SHORT_TIMEOUT);
+	else
+		ACTOR_STATE_CLR(port, LACP_SHORT_TIMEOUT);
+
+
 	if (!ACTOR_STATE(port, SYNCHRONIZATION)) {
 		/* attach mux to aggregator */
 		RTE_ASSERT((port->actor_state & (STATE_COLLECTING |
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.h b/drivers/net/bonding/rte_eth_bond_8023ad.h
index 62265f449..5623e1424 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.h
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.h
@@ -331,4 +331,13 @@  rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id);
 int
 rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 		enum rte_bond_8023ad_agg_selection agg_selection);
+
+/**
+ * Set slave to use fast lacp timeout
+ * @param port_id Bonding device id
+ * @return
+ *   0 on success, negative value otherwise
+ */
+int
+rte_eth_bond_8023ad_ext_set_fast(uint16_t port_id, uint16_t slave_id);
 #endif /* RTE_ETH_BOND_8023AD_H_ */
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index f38eb3b47..9157a7295 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -1050,3 +1050,30 @@  rte_eth_bond_link_up_prop_delay_get(uint16_t bonded_port_id)
 
 	return internals->link_up_delay_ms;
 }
+
+int
+rte_eth_bond_lacp_rate_set(uint16_t bonded_port_id, uint8_t lacp_rate)
+{
+    struct bond_dev_private *internals;
+
+    if (valid_bonded_port_id(bonded_port_id) != 0)
+        return -1;
+
+    internals = rte_eth_devices[bonded_port_id].data->dev_private;
+    internals->lacp_rate = lacp_rate;
+
+    return 0;
+}
+
+int
+rte_eth_bond_lacp_rate_get(uint16_t bonded_port_id)
+{
+    struct bond_dev_private *internals;
+
+    if (valid_bonded_port_id(bonded_port_id) != 0)
+        return -1;
+
+    internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+    return internals->lacp_rate;
+}
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index abdf55261..732685198 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -18,6 +18,7 @@  const char *pmd_bond_init_valid_arguments[] = {
 	PMD_BOND_SOCKET_ID_KVARG,
 	PMD_BOND_MAC_ADDR_KVARG,
 	PMD_BOND_AGG_MODE_KVARG,
+	PMD_BOND_LACP_RATE_KVARG,
 	"driver",
 	NULL
 };
@@ -299,3 +300,27 @@  bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
 
 	return 0;
 }
+
+int
+bond_ethdev_parse_lacp_rate_kvarg(const char *key __rte_unused,
+        const char *value, void *extra_args)
+{
+    uint8_t lacp_rate;
+
+    if (value == NULL || extra_args == NULL)
+        return -1;
+
+    if (strcmp(PMD_BOND_LACP_RATE_FAST_KVARG, value) == 0)
+        lacp_rate = LACP_RATE_FAST;
+    else if (strcmp("1", value) == 0)
+        lacp_rate = LACP_RATE_FAST;
+    else if (strcmp(PMD_BOND_LACP_RATE_SLOW_KVARG, value) == 0)
+        lacp_rate = LACP_RATE_SLOW;
+    else if (strcmp("0", value) == 0)
+        lacp_rate = LACP_RATE_SLOW;
+    else
+        return -1;
+
+    *(uint8_t *)extra_args = lacp_rate;
+    return 0;
+}
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 707a0f3cd..e1f105233 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3727,6 +3727,33 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	/* Parse/set lacp rate */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LACP_RATE_KVARG);
+	if (arg_count == 1) {
+		uint8_t lacp_rate;
+
+		if (rte_kvargs_process(kvlist, PMD_BOND_LACP_RATE_KVARG,
+				&bond_ethdev_parse_lacp_rate_kvarg, &lacp_rate) !=
+						0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lacp rate specified for bonded device %s\n",
+					name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_lacp_rate_set(port_id, lacp_rate)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lacp rate on bonded device %s\n", name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Lacp rate can be specified only once for bonded device %s\n", name);
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -3748,7 +3775,8 @@  RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"mac=<mac addr> "
 	"lsc_poll_period_ms=<int> "
 	"up_delay=<int> "
-	"down_delay=<int>");
+	"down_delay=<int> "
+        "lacp_rate=[fast | slow]");
 
 int bond_logtype;