From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1C5E1A00BE; Tue, 7 Jul 2020 03:51:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A1E71DCAE; Tue, 7 Jul 2020 03:51:34 +0200 (CEST) Received: from huawei.com (szxga08-in.huawei.com [45.249.212.255]) by dpdk.org (Postfix) with ESMTP id 5AA8B1DC93 for ; Tue, 7 Jul 2020 03:51:32 +0200 (CEST) Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id C33F4ECC141C31BE3961; Tue, 7 Jul 2020 09:51:30 +0800 (CST) Received: from DGGEMM423-HUB.china.huawei.com (10.1.198.40) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 7 Jul 2020 09:51:29 +0800 Received: from DGGEMM527-MBS.china.huawei.com ([169.254.5.197]) by dggemm423-hub.china.huawei.com ([10.1.198.40]) with mapi id 14.03.0487.000; Tue, 7 Jul 2020 09:51:22 +0800 From: "Liyunqi (FENIX)" To: "dev@dpdk.org" CC: "Huwei (Xavier)" , "chas3@att.com" , Songyujin , "Liweifeng (DOPRA MSS)" Thread-Topic: [RFC PATCH] net/bonding: change the state machine to defaulted Thread-Index: AQHWUPxZdw4XEnY2tECPQle2v0FLEqj7X5Kw Date: Tue, 7 Jul 2020 01:51:21 +0000 Message-ID: References: <20200703133146.22195-1-liweifeng2@huawei.com> In-Reply-To: <20200703133146.22195-1-liweifeng2@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.105.44] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: [dpdk-dev] [RFC PATCH] net/bonding: change the state machine to defaulted 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" A dpdk bonding 802.3ad network as follows: +----------+ +-----------+ |dpdk lacp |slave1 <------> port1|switch lacp| | |slave2 <------> port2| | +----------+ +-----------+ If a fiber optic go wrong about single pass during normal runing like this: slave2 -----> port2 ok slave2 <----- port2 error: salve2 receive no LACPDU Some packets from switc= h to dpdk will choose port2 and lost. Dpdk lacp state machine will transits to the expired state if no LACPDU is = received before the current_while_timer expires. But if no LACPDU is receiv= ed before the current_while_timer expires again, dpdk lacp state machine ha= s no change. Port2 can not change to inactive depend on the received LACPDU= . According to IEEE 802.3ad, if no lacpdu is received before the current_whil= e_timer expires again, the state machine should transits from expired to de= faulted. Port2 will change to inactive depend on the LACPDU with defaulted = state. This Patch add a state machine change from expired to defaulted when no lac= pdu is received before the current_while_timer expires again according to I= EEE 802.3ad: If no LACPDU is received before the current_while timer expires again, the = state machine transits to the DEFAULTED state. The recordDefault function o= verwrites the current operational parameters for the Partner with administr= atively configured values. This allows configuration of aggregations and in= dividual links when no protocol partner is present, while still permitting = an active partner to override default settings. The update_Default_Selected function sets the Selected variable FALSE if th= e Link Aggregation Group has changed. Since all operational parameters are = now set to locally administered values there can be no disagreement as to t= he Link Aggregation Group, so the Matched variable is set TRUE. The relevant description is in the chapter 43.4.12 of the link below: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=3D&arnumber=3D850426 Signed-off-by: Weifeng Li --- drivers/net/bonding/eth_bond_8023ad_private.h | 2 ++ drivers/net/bonding/rte_eth_bond_8023ad.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/bonding/eth_bond_8023ad_private.h b/drivers/net/bo= nding/eth_bond_8023ad_private.h index 6e44ffd..76f8b8d 100644 --- a/drivers/net/bonding/eth_bond_8023ad_private.h +++ b/drivers/net/bonding/eth_bond_8023ad_private.h @@ -50,6 +50,7 @@ #define SM_FLAGS_MOVED 0x0100 #define SM_FLAGS_PARTNER_SHORT_TIMEOUT 0x0200 #define SM_FLAGS_NTT 0x0400 +#define SM_FLAGS_EXPIRED 0x0800 =20 #define BOND_LINK_FULL_DUPLEX_KEY 0x01 #define BOND_LINK_SPEED_KEY_10M 0x02 @@ -103,6 +104,7 @@ struct port { =20 /** The operational Partner's port parameters */ struct port_params partner; + struct port_params partner_admin; =20 /* Additional port parameters not listed in documentation */ /** State machine flags */ diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bondin= g/rte_eth_bond_8023ad.c index b77a37d..bfa418d 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -356,16 +356,28 @@ =20 timer_set(&port->current_while_timer, timeout); ACTOR_STATE_CLR(port, EXPIRED); + SM_FLAG_CLR(port, EXPIRED); return; /* No state change */ } =20 /* If CURRENT state timer is not running (stopped or expired) * transit to EXPIRED state from DISABLED or CURRENT */ if (!timer_is_running(&port->current_while_timer)) { - ACTOR_STATE_SET(port, EXPIRED); - PARTNER_STATE_CLR(port, SYNCHRONIZATION); - PARTNER_STATE_SET(port, LACP_SHORT_TIMEOUT); - timer_set(&port->current_while_timer, internals->mode4.short_timeout); + if (SM_FLAG(port, EXPIRED)) { + port->selected =3D UNSELECTED; + memcpy(&port->partner, &port->partner_admin, + sizeof(struct port_params)); + record_default(port); + ACTOR_STATE_CLR(port, EXPIRED); + timer_cancel(&port->current_while_timer); + } else { + SM_FLAG_SET(port, EXPIRED); + ACTOR_STATE_SET(port, EXPIRED); + PARTNER_STATE_CLR(port, SYNCHRONIZATION); + PARTNER_STATE_SET(port, LACP_SHORT_TIMEOUT); + timer_set(&port->current_while_timer, + internals->mode4.short_timeout); + } } } =20 @@ -1020,6 +1032,7 @@ port->actor.port_number =3D rte_cpu_to_be_16(slave_id + 1); =20 memcpy(&port->partner, &initial, sizeof(struct port_params)); + memcpy(&port->partner_admin, &initial, sizeof(struct port_params)); =20 /* default states */ port->actor_state =3D STATE_AGGREGATION | STATE_LACP_ACTIVE | STATE_DEFAU= LTED; -- 1.8.3.1 ----- This e-mail and its attachments contain confidential information from HUAWE= I, which is intended only for the person or entity whose address is listed = above.=20 Any use of the information contained herein in any way (including, but not = limited to, total or partial disclosure, reproduction, or dissemination) by= persons other than the intended recipient(s) is prohibited. If you receive this e-m= ail in error, please notify the sender by phone or email immediately and de= lete it! -----