DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Richard Houldsworth <rhouldsworth@solarflare.com>
Subject: [dpdk-dev] [PATCH 09/11] net/sfc/base: add accessor to whole link status
Date: Mon, 24 Sep 2018 14:50:28 +0100	[thread overview]
Message-ID: <1537797030-26548-10-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1537797030-26548-1-git-send-email-arybchenko@solarflare.com>

From: Richard Houldsworth <rhouldsworth@solarflare.com>

Add a function which makes an MCDI GET_LINK request and
packages up the results. Currently, the get-link function
is triggered from several entry points which then pass
on or store selected parts of the data. When the driver
needs to obtain the current link state, it is more
efficient to do this in a single call.

Signed-off-by: Richard Houldsworth <rhouldsworth@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/base/ef10_impl.h | 10 +++-------
 drivers/net/sfc/base/ef10_mac.c  |  6 +++---
 drivers/net/sfc/base/ef10_nic.c  |  4 ++--
 drivers/net/sfc/base/ef10_phy.c  | 24 ++++++++++++++++--------
 drivers/net/sfc/base/efx.h       | 15 +++++++++++++++
 drivers/net/sfc/base/efx_impl.h  |  2 +-
 drivers/net/sfc/base/efx_phy.c   | 30 ++++++++++++++++++++++++++----
 7 files changed, 66 insertions(+), 25 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e43e26e68..f971063a1 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -593,11 +593,7 @@ ef10_nvram_buffer_finish(
 /* PHY */
 
 typedef struct ef10_link_state_s {
-	uint32_t		els_adv_cap_mask;
-	uint32_t		els_lp_cap_mask;
-	unsigned int		els_fcntl;
-	efx_phy_fec_type_t	els_fec;
-	efx_link_mode_t		els_link_mode;
+	efx_phy_link_state_t	epls;
 #if EFSYS_OPT_LOOPBACK
 	efx_loopback_type_t	els_loopback;
 #endif
@@ -634,9 +630,9 @@ ef10_phy_oui_get(
 	__out		uint32_t *ouip);
 
 extern	__checkReturn	efx_rc_t
-ef10_phy_fec_type_get(
+ef10_phy_link_state_get(
 	__in		efx_nic_t *enp,
-	__out		efx_phy_fec_type_t *fecp);
+	__out		efx_phy_link_state_t *eplsp);
 
 #if EFSYS_OPT_PHY_STATS
 
diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index ab73828f1..9f10f6f79 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/base/ef10_mac.c
@@ -22,10 +22,10 @@ ef10_mac_poll(
 	if ((rc = ef10_phy_get_link(enp, &els)) != 0)
 		goto fail1;
 
-	epp->ep_adv_cap_mask = els.els_adv_cap_mask;
-	epp->ep_fcntl = els.els_fcntl;
+	epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask;
+	epp->ep_fcntl = els.epls.epls_fcntl;
 
-	*link_modep = els.els_link_mode;
+	*link_modep = els.epls.epls_link_mode;
 
 	return (0);
 
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 1b3d60682..50e23b7d4 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1852,8 +1852,8 @@ ef10_nic_board_cfg(
 	/* Obtain the default PHY advertised capabilities */
 	if ((rc = ef10_phy_get_link(enp, &els)) != 0)
 		goto fail7;
-	epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
-	epp->ep_adv_cap_mask = els.els_adv_cap_mask;
+	epp->ep_default_adv_cap_mask = els.epls.epls_adv_cap_mask;
+	epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask;
 
 	/* Check capabilities of running datapath firmware */
 	if ((rc = ef10_get_datapath_caps(enp)) != 0)
diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index ec3600e96..84ccdde5d 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -286,9 +286,9 @@ ef10_phy_get_link(
 	}
 
 	mcdi_phy_decode_cap(MCDI_OUT_DWORD(req, GET_LINK_OUT_CAP),
-			    &elsp->els_adv_cap_mask);
+			    &elsp->epls.epls_adv_cap_mask);
 	mcdi_phy_decode_cap(MCDI_OUT_DWORD(req, GET_LINK_OUT_LP_CAP),
-			    &elsp->els_lp_cap_mask);
+			    &elsp->epls.epls_lp_cap_mask);
 
 	if (req.emr_out_length_used < MC_CMD_GET_LINK_OUT_V2_LEN)
 		fec = MC_CMD_FEC_NONE;
@@ -298,8 +298,16 @@ ef10_phy_get_link(
 	mcdi_phy_decode_link_mode(enp, MCDI_OUT_DWORD(req, GET_LINK_OUT_FLAGS),
 			    MCDI_OUT_DWORD(req, GET_LINK_OUT_LINK_SPEED),
 			    MCDI_OUT_DWORD(req, GET_LINK_OUT_FCNTL),
-			    fec, &elsp->els_link_mode,
-			    &elsp->els_fcntl, &elsp->els_fec);
+			    fec, &elsp->epls.epls_link_mode,
+			    &elsp->epls.epls_fcntl, &elsp->epls.epls_fec);
+
+	if (req.emr_out_length_used < MC_CMD_GET_LINK_OUT_V2_LEN) {
+		elsp->epls.epls_ld_cap_mask = 0;
+	} else {
+		mcdi_phy_decode_cap(MCDI_OUT_DWORD(req, GET_LINK_OUT_V2_LD_CAP),
+				    &elsp->epls.epls_ld_cap_mask);
+	}
+
 
 #if EFSYS_OPT_LOOPBACK
 	/*
@@ -543,18 +551,18 @@ ef10_phy_oui_get(
 }
 
 	__checkReturn	efx_rc_t
-ef10_phy_fec_type_get(
+ef10_phy_link_state_get(
 	__in		efx_nic_t *enp,
-	__out		efx_phy_fec_type_t  *fecp)
+	__out		efx_phy_link_state_t  *eplsp)
 {
 	efx_rc_t rc;
 	ef10_link_state_t els;
 
-	/* Obtain the active FEC type */
+	/* Obtain the active link state */
 	if ((rc = ef10_phy_get_link(enp, &els)) != 0)
 		goto fail1;
 
-	*fecp = els.els_fec;
+	*eplsp = els.epls;
 
 	return (0);
 
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 246708f9c..8e10e8934 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -3257,6 +3257,21 @@ efx_phy_fec_type_get(
 	__in		efx_nic_t *enp,
 	__out		efx_phy_fec_type_t *typep);
 
+typedef struct efx_phy_link_state_s {
+	uint32_t		epls_adv_cap_mask;
+	uint32_t		epls_lp_cap_mask;
+	uint32_t		epls_ld_cap_mask;
+	unsigned int		epls_fcntl;
+	efx_phy_fec_type_t	epls_fec;
+	efx_link_mode_t		epls_link_mode;
+} efx_phy_link_state_t;
+
+extern	__checkReturn	efx_rc_t
+efx_phy_link_state_get(
+	__in		efx_nic_t *enp,
+	__out		efx_phy_link_state_t  *eplsp);
+
+
 #ifdef	__cplusplus
 }
 #endif
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 9f44d2f64..bad23f819 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -224,7 +224,7 @@ typedef struct efx_phy_ops_s {
 	efx_rc_t	(*epo_reconfigure)(efx_nic_t *);
 	efx_rc_t	(*epo_verify)(efx_nic_t *);
 	efx_rc_t	(*epo_oui_get)(efx_nic_t *, uint32_t *);
-	efx_rc_t	(*epo_fec_type_get)(efx_nic_t *, efx_phy_fec_type_t *);
+	efx_rc_t	(*epo_link_state_get)(efx_nic_t *, efx_phy_link_state_t *);
 #if EFSYS_OPT_PHY_STATS
 	efx_rc_t	(*epo_stats_update)(efx_nic_t *, efsys_mem_t *,
 					    uint32_t *);
diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/net/sfc/base/efx_phy.c
index 63b89e6a4..36a7bbd3d 100644
--- a/drivers/net/sfc/base/efx_phy.c
+++ b/drivers/net/sfc/base/efx_phy.c
@@ -15,7 +15,7 @@ static const efx_phy_ops_t	__efx_phy_siena_ops = {
 	siena_phy_reconfigure,		/* epo_reconfigure */
 	siena_phy_verify,		/* epo_verify */
 	siena_phy_oui_get,		/* epo_oui_get */
-	NULL,				/* epo_fec_type_get */
+	NULL,				/* epo_link_state_get */
 #if EFSYS_OPT_PHY_STATS
 	siena_phy_stats_update,		/* epo_stats_update */
 #endif	/* EFSYS_OPT_PHY_STATS */
@@ -35,7 +35,7 @@ static const efx_phy_ops_t	__efx_phy_ef10_ops = {
 	ef10_phy_reconfigure,		/* epo_reconfigure */
 	ef10_phy_verify,		/* epo_verify */
 	ef10_phy_oui_get,		/* epo_oui_get */
-	ef10_phy_fec_type_get,		/* epo_fec_type_get */
+	ef10_phy_link_state_get,	/* epo_link_state_get */
 #if EFSYS_OPT_PHY_STATS
 	ef10_phy_stats_update,		/* epo_stats_update */
 #endif	/* EFSYS_OPT_PHY_STATS */
@@ -321,19 +321,41 @@ efx_phy_module_get_info(
 efx_phy_fec_type_get(
 	__in		efx_nic_t *enp,
 	__out		efx_phy_fec_type_t *typep)
+{
+	efx_rc_t rc;
+	efx_phy_link_state_t epls;
+
+	if ((rc = efx_phy_link_state_get(enp, &epls)) != 0)
+		goto fail1;
+
+	*typep = epls.epls_fec;
+
+	return (0);
+
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
+	__checkReturn		efx_rc_t
+efx_phy_link_state_get(
+	__in		efx_nic_t *enp,
+	__out		efx_phy_link_state_t *eplsp)
 {
 	efx_port_t *epp = &(enp->en_port);
 	const efx_phy_ops_t *epop = epp->ep_epop;
 	efx_rc_t rc;
 
 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
 
-	if (epop->epo_fec_type_get == NULL) {
+	if (epop->epo_link_state_get == NULL) {
 		rc = ENOTSUP;
 		goto fail1;
 	}
 
-	if ((rc = epop->epo_fec_type_get(enp, typep)) != 0)
+	if ((rc = epop->epo_link_state_get(enp, eplsp)) != 0)
 		goto fail2;
 
 	return (0);
-- 
2.17.1

  parent reply	other threads:[~2018-09-24 13:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 13:50 [dpdk-dev] [PATCH 00/11] net/sfc: update base driver to support 50G and 100G Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 01/11] net/sfc/base: make last byte of module information available Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 02/11] net/sfc/base: expose PHY module device address constants Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 03/11] net/sfc/base: adjust PHY module info interface Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 04/11] net/sfc/base: update to current port mode terminology Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 05/11] net/sfc/base: add X2 port modes to bandwidth calculator Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 06/11] net/sfc/base: support improvements to bandwidth calculations Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 07/11] net/sfc/base: infer port mode bandwidth from max link speed Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 08/11] net/sfc/base: guard Rx scale code with corresponding option Andrew Rybchenko
2018-09-24 13:50 ` Andrew Rybchenko [this message]
2018-09-24 13:50 ` [dpdk-dev] [PATCH 10/11] net/sfc/base: use transceiver ID when reading info Andrew Rybchenko
2018-09-24 13:50 ` [dpdk-dev] [PATCH 11/11] net/sfc: add 50G and 100G XtremeScale X2 family adapters Andrew Rybchenko
2018-09-25 14:32 ` [dpdk-dev] [PATCH 00/11] net/sfc: update base driver to support 50G and 100G 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=1537797030-26548-10-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=rhouldsworth@solarflare.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).