From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CCE2F4285A; Tue, 28 Mar 2023 18:50:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 601B34021D; Tue, 28 Mar 2023 18:50:49 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 2F4AC40156 for ; Tue, 28 Mar 2023 18:50:48 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.65.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by agw.arknetworks.am (Postfix) with ESMTPSA id 823F4E0827; Tue, 28 Mar 2023 20:50:47 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH] common/sfc_efx/base: support link status change v2 events Date: Tue, 28 Mar 2023 20:51:12 +0400 Message-Id: <20230328165112.6535-1-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org FW should send link status change events in either v1 or v2 format depending on the preference which the driver can express during CMD_DRV_ATTACH stage. At the moment, libefx does not request v2, so v1 events must arrive. However, FW does not honour this choice and always sends v2 events. So teach libefx to parse such and add v2 request to CMD_DRV_ATTACH, correspondingly. Signed-off-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/ef10_ev.c | 6 +++++- drivers/common/sfc_efx/base/ef10_impl.h | 1 + drivers/common/sfc_efx/base/ef10_phy.c | 28 +++++++++++++++++++------ drivers/common/sfc_efx/base/efx_mcdi.c | 10 +++++++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/common/sfc_efx/base/ef10_ev.c b/drivers/common/sfc_efx/base/ef10_ev.c index ba078940b6..011ef49de7 100644 --- a/drivers/common/sfc_efx/base/ef10_ev.c +++ b/drivers/common/sfc_efx/base/ef10_ev.c @@ -868,6 +868,7 @@ ef10_ev_mcdi( efx_nic_t *enp = eep->ee_enp; unsigned int code; boolean_t should_abort = B_FALSE; + boolean_t ev_is_v2 = B_FALSE; EFX_EV_QSTAT_INCR(eep, EV_MCDI_RESPONSE); @@ -905,10 +906,13 @@ ef10_ev_mcdi( break; #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */ + case MCDI_EVENT_CODE_LINKCHANGE_V2: + ev_is_v2 = B_TRUE; + /* Fallthrough */ case MCDI_EVENT_CODE_LINKCHANGE: { efx_link_mode_t link_mode; - ef10_phy_link_ev(enp, eqp, &link_mode); + ef10_phy_link_ev(enp, eqp, ev_is_v2, &link_mode); should_abort = eecp->eec_link_change(arg, link_mode); break; } diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h index 2aae208f27..017e561f19 100644 --- a/drivers/common/sfc_efx/base/ef10_impl.h +++ b/drivers/common/sfc_efx/base/ef10_impl.h @@ -753,6 +753,7 @@ extern void ef10_phy_link_ev( __in efx_nic_t *enp, __in efx_qword_t *eqp, + __in boolean_t ev_is_v2, __out efx_link_mode_t *link_modep); LIBEFX_INTERNAL diff --git a/drivers/common/sfc_efx/base/ef10_phy.c b/drivers/common/sfc_efx/base/ef10_phy.c index 954436b9e0..49babdecd5 100644 --- a/drivers/common/sfc_efx/base/ef10_phy.c +++ b/drivers/common/sfc_efx/base/ef10_phy.c @@ -166,6 +166,7 @@ mcdi_phy_decode_link_mode( ef10_phy_link_ev( __in efx_nic_t *enp, __in efx_qword_t *eqp, + __in boolean_t ev_is_v2, __out efx_link_mode_t *link_modep) { efx_port_t *epp = &(enp->en_port); @@ -174,13 +175,31 @@ ef10_phy_link_ev( unsigned int fcntl; efx_phy_fec_type_t fec = MC_CMD_FEC_NONE; efx_link_mode_t link_mode; + unsigned int ev_lp_cap; + unsigned int ev_fcntl; + unsigned int ev_speed; uint32_t lp_cap_mask; + if (ev_is_v2) { + link_flags = (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN); + if (MCDI_EV_FIELD(eqp, LINKCHANGE_V2_FLAGS_LINK_UP)) + link_flags |= (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN); + + ev_lp_cap = MCDI_EV_FIELD(eqp, LINKCHANGE_V2_LP_CAP); + ev_fcntl = MCDI_EV_FIELD(eqp, LINKCHANGE_V2_FCNTL); + ev_speed = MCDI_EV_FIELD(eqp, LINKCHANGE_V2_SPEED); + } else { + link_flags = MCDI_EV_FIELD(eqp, LINKCHANGE_LINK_FLAGS); + ev_lp_cap = MCDI_EV_FIELD(eqp, LINKCHANGE_LP_CAP); + ev_fcntl = MCDI_EV_FIELD(eqp, LINKCHANGE_FCNTL); + ev_speed = MCDI_EV_FIELD(eqp, LINKCHANGE_SPEED); + } + /* * Convert the LINKCHANGE speed enumeration into mbit/s, in the * same way as GET_LINK encodes the speed */ - switch (MCDI_EV_FIELD(eqp, LINKCHANGE_SPEED)) { + switch (ev_speed) { case MCDI_EVENT_LINKCHANGE_SPEED_100M: speed = 100; break; @@ -207,13 +226,10 @@ ef10_phy_link_ev( break; } - link_flags = MCDI_EV_FIELD(eqp, LINKCHANGE_LINK_FLAGS); - mcdi_phy_decode_link_mode(enp, link_flags, speed, - MCDI_EV_FIELD(eqp, LINKCHANGE_FCNTL), + mcdi_phy_decode_link_mode(enp, link_flags, speed, ev_fcntl, MC_CMD_FEC_NONE, &link_mode, &fcntl, &fec); - mcdi_phy_decode_cap(MCDI_EV_FIELD(eqp, LINKCHANGE_LP_CAP), - &lp_cap_mask); + mcdi_phy_decode_cap(ev_lp_cap, &lp_cap_mask); /* * It's safe to update ep_lp_cap_mask without the driver's port lock diff --git a/drivers/common/sfc_efx/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c index 6274cf6bac..acf7f02246 100644 --- a/drivers/common/sfc_efx/base/efx_mcdi.c +++ b/drivers/common/sfc_efx/base/efx_mcdi.c @@ -1620,10 +1620,16 @@ efx_mcdi_drv_attach( * such example is the ESXi native driver that attempts attaching with * FULL_FEATURED datapath firmware type first and fall backs to * DONT_CARE datapath firmware type if MC_CMD_DRV_ATTACH fails. + * + * Always set WANT_V2_LINKCHANGES to 1. Old firmware that only supports + * v1 will ignore it, and for newer firmware it ensures that it always + * sends v2 if possible. While EF100 always uses v2, there are some + * older EF10 firmwares that only send v2 if it is requested. */ - MCDI_IN_POPULATE_DWORD_2(req, DRV_ATTACH_IN_NEW_STATE, + MCDI_IN_POPULATE_DWORD_3(req, DRV_ATTACH_IN_NEW_STATE, DRV_ATTACH_IN_ATTACH, attach ? 1 : 0, - DRV_ATTACH_IN_SUBVARIANT_AWARE, EFSYS_OPT_FW_SUBVARIANT_AWARE); + DRV_ATTACH_IN_SUBVARIANT_AWARE, EFSYS_OPT_FW_SUBVARIANT_AWARE, + DRV_ATTACH_IN_WANT_V2_LINKCHANGES, 1); MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_UPDATE, 1); MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_FIRMWARE_ID, enp->efv); -- 2.17.1