DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Gautam Dawar <gdawar@solarflare.com>
Subject: [dpdk-dev] [PATCH 27/29] net/sfc/base: provide APIs to configure and reset vPort
Date: Mon, 10 Jun 2019 08:38:42 +0100	[thread overview]
Message-ID: <1560152324-20538-28-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1560152324-20538-1-git-send-email-arybchenko@solarflare.com>

From: Gautam Dawar <gdawar@solarflare.com>

Implement functions to set vPort VLAN and MAC address and reset the vPort.

Signed-off-by: Gautam Dawar <gdawar@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/base/ef10_evb.c  |  83 +++++++++++++++++++++++++++++
 drivers/net/sfc/base/ef10_impl.h |   9 ++++
 drivers/net/sfc/base/ef10_nic.c  |   6 +++
 drivers/net/sfc/base/efx.h       |  24 +++++++++
 drivers/net/sfc/base/efx_evb.c   | 109 +++++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/base/efx_impl.h  |   4 ++
 6 files changed, 235 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/net/sfc/base/ef10_evb.c
index aaa97f6..6b6d7cc 100644
--- a/drivers/net/sfc/base/ef10_evb.c
+++ b/drivers/net/sfc/base/ef10_evb.c
@@ -330,6 +330,74 @@
 	return (rc);
 }
 
+	__checkReturn				efx_rc_t
+efx_mcdi_vport_reconfigure(
+	__in					efx_nic_t *enp,
+	__in					efx_vport_id_t vport_id,
+	__in_opt				uint16_t *vidp,
+	__in_bcount_opt(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
+	__out_opt				boolean_t *fn_resetp)
+{
+	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VPORT_RECONFIGURE_IN_LEN,
+		MC_CMD_VPORT_RECONFIGURE_OUT_LEN);
+	efx_mcdi_req_t req;
+	efx_rc_t rc;
+	uint32_t reset_flag = 0;
+
+	req.emr_cmd = MC_CMD_VPORT_RECONFIGURE;
+	req.emr_in_buf = payload;
+	req.emr_in_length = MC_CMD_VPORT_RECONFIGURE_IN_LEN;
+	req.emr_out_buf = payload;
+	req.emr_out_length = MC_CMD_VPORT_RECONFIGURE_OUT_LEN;
+
+	MCDI_IN_SET_DWORD(req, VPORT_RECONFIGURE_IN_VPORT_ID, vport_id);
+
+	if (vidp != NULL) {
+		MCDI_IN_POPULATE_DWORD_1(req, VPORT_RECONFIGURE_IN_FLAGS,
+			VPORT_RECONFIGURE_IN_REPLACE_VLAN_TAGS, 1);
+		if (*vidp != EFX_FILTER_VID_UNSPEC) {
+			MCDI_IN_SET_DWORD(req,
+				VPORT_RECONFIGURE_IN_NUM_VLAN_TAGS, 1);
+			MCDI_IN_POPULATE_DWORD_1(req,
+				VPORT_RECONFIGURE_IN_VLAN_TAGS,
+				VPORT_RECONFIGURE_IN_VLAN_TAG_0, *vidp);
+		}
+	}
+
+	if ((addrp != NULL) && (efx_is_zero_eth_addr(addrp) == B_FALSE)) {
+		MCDI_IN_POPULATE_DWORD_1(req, VPORT_RECONFIGURE_IN_FLAGS,
+			 VPORT_RECONFIGURE_IN_REPLACE_MACADDRS, 1);
+		MCDI_IN_SET_DWORD(req, VPORT_RECONFIGURE_IN_NUM_MACADDRS, 1);
+		EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t,
+					VPORT_RECONFIGURE_IN_MACADDRS), addrp);
+	}
+
+	efx_mcdi_execute(enp, &req);
+	if (req.emr_rc != 0) {
+		rc = req.emr_rc;
+		goto fail1;
+	}
+
+	if (req.emr_out_length_used < MC_CMD_VPORT_RECONFIGURE_OUT_LEN) {
+		rc = EMSGSIZE;
+		goto fail2;
+	}
+
+	reset_flag = MCDI_OUT_DWORD_FIELD(req, VPORT_RECONFIGURE_OUT_FLAGS,
+					    VPORT_RECONFIGURE_OUT_RESET_DONE);
+
+	if (fn_resetp != NULL)
+		*fn_resetp = (reset_flag != 0);
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
 	__checkReturn	efx_rc_t
 ef10_evb_vswitch_alloc(
 	__in		efx_nic_t *enp,
@@ -453,5 +521,20 @@
 	return (efx_mcdi_port_assign(enp, vport_id, vf_index));
 }
 
+	__checkReturn				efx_rc_t
+ef10_evb_vport_reconfigure(
+	__in					efx_nic_t *enp,
+	__in					efx_vswitch_id_t vswitch_id,
+	__in					efx_vport_id_t vport_id,
+	__in_opt				uint16_t *vidp,
+	__in_bcount_opt(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
+	__out_opt				boolean_t *fn_resetp)
+{
+	_NOTE(ARGUNUSED(vswitch_id))
+
+	return (efx_mcdi_vport_reconfigure(enp, vport_id, vidp,
+			addrp, fn_resetp));
+}
+
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 #endif /* EFSYS_OPT_EVB */
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e9ce31a..20f2a5c 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1342,6 +1342,15 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 	__in		efx_vport_id_t vport_id,
 	__in		uint32_t vf_index);
 
+extern	__checkReturn				efx_rc_t
+ef10_evb_vport_reconfigure(
+	__in					efx_nic_t *enp,
+	__in					efx_vswitch_id_t vswitch_id,
+	__in					efx_vport_id_t vport_id,
+	__in_opt				uint16_t *vidp,
+	__in_bcount_opt(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
+	__out_opt				boolean_t *fn_resetp);
+
 #endif  /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index a647daa..b25ce19 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1108,6 +1108,12 @@
 	else
 		encp->enc_datapath_cap_evb = B_FALSE;
 
+	/* Check if the firmware supports vport reconfiguration */
+	if (CAP_FLAGS1(req, VPORT_RECONFIGURE))
+		encp->enc_vport_reconfigure_supported = B_TRUE;
+	else
+		encp->enc_vport_reconfigure_supported = B_FALSE;
+
 	/* Check if the firmware supports VLAN insertion */
 	if (CAP_FLAGS1(req, TX_VLAN_INSERTION))
 		encp->enc_hw_tx_insert_vlan_enabled = B_TRUE;
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index e43302a..0e6e842 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -1370,6 +1370,8 @@ enum {
 	uint32_t		enc_hw_pf_count;
 	/* Datapath firmware vadapter/vport/vswitch support */
 	boolean_t		enc_datapath_cap_evb;
+	/* Datapath firmware vport reconfigure support */
+	boolean_t		enc_vport_reconfigure_supported;
 	boolean_t		enc_rx_disable_scatter_supported;
 	boolean_t		enc_allow_set_mac_with_installed_filters;
 	boolean_t		enc_enhanced_set_mac_supported;
@@ -3420,6 +3422,28 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 	__in				efx_nic_t *enp,
 	__in				efx_vswitch_t *evp);
 
+extern	__checkReturn			efx_rc_t
+efx_evb_vport_mac_set(
+	__in				efx_nic_t *enp,
+	__in				efx_vswitch_t *evp,
+	__in				efx_vport_id_t vport_id,
+	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp);
+
+extern	__checkReturn	efx_rc_t
+efx_evb_vport_vlan_set(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_t *evp,
+	__in		efx_vport_id_t vport_id,
+	__in		uint16_t vid);
+
+extern	__checkReturn			efx_rc_t
+efx_evb_vport_reset(
+	__in				efx_nic_t *enp,
+	__in				efx_vswitch_t *evp,
+	__in				efx_vport_id_t vport_id,
+	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
+	__in				uint16_t vid,
+	__out				boolean_t *is_fn_resetp);
 #endif /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/net/sfc/base/efx_evb.c
index 27b466f..d48e1d7 100644
--- a/drivers/net/sfc/base/efx_evb.c
+++ b/drivers/net/sfc/base/efx_evb.c
@@ -23,6 +23,7 @@
 	NULL,		/* eeo_vadaptor_alloc */
 	NULL,		/* eeo_vadaptor_free */
 	NULL,		/* eeo_vport_assign */
+	NULL,		/* eeo_vport_reconfigure */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -39,6 +40,7 @@
 	ef10_evb_vadaptor_alloc,	/* eeo_vadaptor_alloc */
 	ef10_evb_vadaptor_free,		/* eeo_vadaptor_free */
 	ef10_evb_vport_assign,		/* eeo_vport_assign */
+	ef10_evb_vport_reconfigure,	/* eeo_vport_reconfigure */
 };
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
@@ -348,7 +350,114 @@
 	return (rc);
 }
 
+	__checkReturn			efx_rc_t
+efx_evb_vport_mac_set(
+	__in				efx_nic_t *enp,
+	__in				efx_vswitch_t *evp,
+	__in				efx_vport_id_t vport_id,
+	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp)
+{
+	const efx_evb_ops_t *eeop = enp->en_eeop;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_EVB);
+
+	if (eeop->eeo_vport_reconfigure == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if (addrp == NULL) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
+	rc = eeop->eeo_vport_reconfigure(enp, evp->ev_vswitch_id, vport_id,
+		NULL, addrp, NULL);
+	if (rc != 0)
+		goto fail3;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_evb_vport_vlan_set(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_t *evp,
+	__in		efx_vport_id_t vport_id,
+	__in		uint16_t vid)
+{
+	const efx_evb_ops_t *eeop = enp->en_eeop;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_EVB);
+
+	if (eeop->eeo_vport_reconfigure == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
 
+	rc = eeop->eeo_vport_reconfigure(enp, evp->ev_vswitch_id, vport_id,
+		&vid, NULL, NULL);
+	if (rc != 0)
+		goto fail2;
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
+	__checkReturn			efx_rc_t
+efx_evb_vport_reset(
+	__in				efx_nic_t *enp,
+	__in				efx_vswitch_t *evp,
+	__in				efx_vport_id_t vport_id,
+	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
+	__in				uint16_t vid,
+	__out				boolean_t *is_fn_resetp)
+{
+	const efx_evb_ops_t *eeop = enp->en_eeop;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_EVB);
+
+	if (eeop->eeo_vport_reconfigure == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if (is_fn_resetp == NULL) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
+	rc = eeop->eeo_vport_reconfigure(enp, evp->ev_vswitch_id, vport_id,
+		&vid, addrp, is_fn_resetp);
+	if (rc != 0)
+		goto fail3;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
 	__checkReturn	efx_rc_t
 efx_evb_vswitch_destroy(
 	__in		efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 6c72166..fd31a6d 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -684,6 +684,10 @@ struct efx_vswitch_s {
 						efx_vport_id_t);
 	efx_rc_t	(*eeo_vport_assign)(efx_nic_t *, efx_vswitch_id_t,
 						efx_vport_id_t, uint32_t);
+	efx_rc_t	(*eeo_vport_reconfigure)(efx_nic_t *, efx_vswitch_id_t,
+							efx_vport_id_t,
+							uint16_t *, uint8_t *,
+							boolean_t *);
 } efx_evb_ops_t;
 
 extern __checkReturn	boolean_t
-- 
1.8.3.1


  parent reply	other threads:[~2019-06-10  7:42 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10  7:38 [dpdk-dev] [PATCH 00/29] net/sfc/base: update base driver Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 01/29] net/sfc/base: enable chained multicast on all EF10 cards Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 02/29] net/sfc/base: fix signed/unsigned mismatch errors Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 03/29] net/sfc/base: fix shift by more bits than field width Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 04/29] net/sfc/base: improve code style in sensors decoding Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 05/29] net/sfc/base: do not rely on indirect header inclusion Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 06/29] net/sfc/base: add driver version string registration Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 07/29] net/sfc/base: add capabilities for bundle partition support Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 08/29] net/sfc/base: add extensible NVRAM info function Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 09/29] net/sfc/base: add NVRAM info to API Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 10/29] net/sfc/base: update MCDI headers Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 11/29] net/sfc/base: add firmware ID header Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 12/29] net/sfc/base: support direct FW update for bundle partitions Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 13/29] net/sfc/base: transition to the extensible NVRAM info API Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 14/29] net/sfc/base: add background mode firmware updating Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 15/29] net/sfc/base: add definition of bundle metadata partition Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 16/29] net/sfc/base: add definition of OEM TLV Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 17/29] net/sfc/base: export the zero-based MCDI port number Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 18/29] net/sfc/base: introduce of EVB module for SR-IOV support Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 19/29] net/sfc/base: add MCDI wrappers for vPort and vSwitch in EVB Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 20/29] net/sfc/base: add EVB module vSwitch/vPort/vAdaptor ops Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 21/29] net/sfc/base: implement vSwitch create/destroy Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 22/29] net/sfc/base: factor out upstream port vAdaptor allocation Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 23/29] net/sfc/base: support data path with EVB module Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 24/29] net/sfc/base: support proxy auth operations for SR-IOV Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 25/29] net/sfc/base: implement proxy auth MCDI event handling Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 26/29] net/sfc/base: provide proxy APIs to client drivers Andrew Rybchenko
2019-06-10  7:38 ` Andrew Rybchenko [this message]
2019-06-10  7:38 ` [dpdk-dev] [PATCH 28/29] net/sfc/base: provide API to fetch vPort statistics Andrew Rybchenko
2019-06-10  7:38 ` [dpdk-dev] [PATCH 29/29] net/sfc/base: add APIs for PTP privilege configuration Andrew Rybchenko
2019-06-18  7:52 ` [dpdk-dev] [PATCH 00/29] net/sfc/base: update base driver Ferruh Yigit
2019-06-23 22:37   ` Thomas Monjalon
2019-06-24  7:53     ` Andrew Rybchenko
2019-06-24 11:17       ` Ferruh Yigit
2019-06-24 13:07         ` Thomas Monjalon

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=1560152324-20538-28-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=gdawar@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).