From: Ivan Malov <ivan.malov@arknetworks.am>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Ferruh Yigit <ferruh.yigit@amd.com>,
Andy Moreton <amoreton@xilinx.com>
Subject: [PATCH] common/sfc_efx/base: support link status change v2 events
Date: Tue, 28 Mar 2023 20:51:12 +0400 [thread overview]
Message-ID: <20230328165112.6535-1-ivan.malov@arknetworks.am> (raw)
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 <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
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
next reply other threads:[~2023-03-28 16:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 16:51 Ivan Malov [this message]
2023-03-30 7:16 ` Andrew Rybchenko
2023-04-07 9:24 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328165112.6535-1-ivan.malov@arknetworks.am \
--to=ivan.malov@arknetworks.am \
--cc=amoreton@xilinx.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).