netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Edward Cree <ecree@solarflare.com>
To: <linux-net-drivers@solarflare.com>, <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>
Subject: [PATCH net-next 05/14] sfc: commonise some MAC configuration code
Date: Tue, 30 Jun 2020 13:11:35 +0100	[thread overview]
Message-ID: <34c4ed3c-8e71-8eb6-fe9f-9f1ed6099e73@solarflare.com> (raw)
In-Reply-To: <14a93b71-3d4e-4663-82be-a2281cd1105e@solarflare.com>

Refactor it a little as we go, and introduce efx_mcdi_set_mtu() which we
 will later use for ef100 to change MTU without touching other MAC settings.

Signed-off-by: Edward Cree <ecree@solarflare.com>
---
 drivers/net/ethernet/sfc/mcdi_port.c        | 13 --------
 drivers/net/ethernet/sfc/mcdi_port_common.c | 36 +++++++++++++++++++--
 drivers/net/ethernet/sfc/mcdi_port_common.h |  1 +
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c
index 133f8b8ec3b3..98eeb404f68d 100644
--- a/drivers/net/ethernet/sfc/mcdi_port.c
+++ b/drivers/net/ethernet/sfc/mcdi_port.c
@@ -176,19 +176,6 @@ static int efx_mcdi_phy_probe(struct efx_nic *efx)
 	return rc;
 }
 
-int efx_mcdi_port_reconfigure(struct efx_nic *efx)
-{
-	struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-	u32 caps = (efx->link_advertising[0] ?
-		    ethtool_linkset_to_mcdi_cap(efx->link_advertising) :
-		    phy_cfg->forced_cap);
-
-	caps |= ethtool_fec_caps_to_mcdi(efx->fec_config);
-
-	return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
-				 efx->loopback_mode, 0);
-}
-
 static void efx_mcdi_phy_remove(struct efx_nic *efx)
 {
 	struct efx_mcdi_phy_data *phy_data = efx->phy_data;
diff --git a/drivers/net/ethernet/sfc/mcdi_port_common.c b/drivers/net/ethernet/sfc/mcdi_port_common.c
index e0608d0d961b..56af8b54a864 100644
--- a/drivers/net/ethernet/sfc/mcdi_port_common.c
+++ b/drivers/net/ethernet/sfc/mcdi_port_common.c
@@ -476,6 +476,24 @@ int efx_mcdi_phy_test_alive(struct efx_nic *efx)
 	return 0;
 }
 
+int efx_mcdi_port_reconfigure(struct efx_nic *efx)
+{
+	struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+	u32 caps = (efx->link_advertising[0] ?
+		    ethtool_linkset_to_mcdi_cap(efx->link_advertising) :
+		    phy_cfg->forced_cap);
+
+	caps |= ethtool_fec_caps_to_mcdi(efx->fec_config);
+
+	return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
+				 efx->loopback_mode, 0);
+}
+
+static unsigned int efx_calc_mac_mtu(struct efx_nic *efx)
+{
+	return EFX_MAX_FRAME_LEN(efx->net_dev->mtu);
+}
+
 int efx_mcdi_set_mac(struct efx_nic *efx)
 {
 	u32 fcntl;
@@ -487,8 +505,7 @@ int efx_mcdi_set_mac(struct efx_nic *efx)
 	ether_addr_copy(MCDI_PTR(cmdbytes, SET_MAC_IN_ADDR),
 			efx->net_dev->dev_addr);
 
-	MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
-		       EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
+	MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU, efx_calc_mac_mtu(efx));
 	MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
 
 	/* Set simple MAC filter for Siena */
@@ -521,6 +538,21 @@ int efx_mcdi_set_mac(struct efx_nic *efx)
 			    NULL, 0, NULL);
 }
 
+int efx_mcdi_set_mtu(struct efx_nic *efx)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_MAC_EXT_IN_LEN);
+
+	BUILD_BUG_ON(MC_CMD_SET_MAC_OUT_LEN != 0);
+
+	MCDI_SET_DWORD(inbuf, SET_MAC_EXT_IN_MTU, efx_calc_mac_mtu(efx));
+
+	MCDI_POPULATE_DWORD_1(inbuf, SET_MAC_EXT_IN_CONTROL,
+			      SET_MAC_EXT_IN_CFG_MTU, 1);
+
+	return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, inbuf, sizeof(inbuf),
+			    NULL, 0, NULL);
+}
+
 enum efx_stats_action {
 	EFX_STATS_ENABLE,
 	EFX_STATS_DISABLE,
diff --git a/drivers/net/ethernet/sfc/mcdi_port_common.h b/drivers/net/ethernet/sfc/mcdi_port_common.h
index 54c0acf8e243..f6f81cbeb07e 100644
--- a/drivers/net/ethernet/sfc/mcdi_port_common.h
+++ b/drivers/net/ethernet/sfc/mcdi_port_common.h
@@ -51,6 +51,7 @@ int efx_mcdi_phy_get_fecparam(struct efx_nic *efx,
 			      struct ethtool_fecparam *fec);
 int efx_mcdi_phy_test_alive(struct efx_nic *efx);
 int efx_mcdi_set_mac(struct efx_nic *efx);
+int efx_mcdi_set_mtu(struct efx_nic *efx);
 int efx_mcdi_mac_init_stats(struct efx_nic *efx);
 void efx_mcdi_mac_fini_stats(struct efx_nic *efx);
 int efx_mcdi_port_get_number(struct efx_nic *efx);


  parent reply	other threads:[~2020-06-30 12:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 12:00 [PATCH net-next 00/14] sfc: prerequisites for EF100 driver, part 2 Edward Cree
2020-06-30 12:02 ` [PATCH net-next 01/14] sfc: move NIC-specific mcdi_port declarations out of common header Edward Cree
2020-06-30 12:02 ` [PATCH net-next 02/14] sfc: commonise MCDI MAC stats handling Edward Cree
2020-06-30 12:03 ` [PATCH net-next 03/14] sfc: add missing licence info to mcdi_filters.c Edward Cree
2020-06-30 12:03 ` [PATCH net-next 04/14] sfc: commonise miscellaneous efx functions Edward Cree
2020-06-30 12:11 ` Edward Cree [this message]
2020-06-30 12:11 ` [PATCH net-next 06/14] sfc: commonise efx_sync_rx_buffer() Edward Cree
2020-06-30 12:12 ` [PATCH net-next 07/14] sfc: commonise TSO fallback code Edward Cree
2020-06-30 12:12 ` [PATCH net-next 08/14] sfc: remove duplicate declaration of efx_enqueue_skb_tso() Edward Cree
2020-06-30 12:13 ` [PATCH net-next 09/14] sfc: factor out efx_tx_tso_header_length() and understand encapsulation Edward Cree
2020-06-30 12:13 ` [PATCH net-next 10/14] sfc: move definition of EFX_MC_STATS_GENERATION_INVALID Edward Cree
2020-06-30 12:14 ` [PATCH net-next 11/14] sfc: initialise max_[tx_]channels in efx_init_channels() Edward Cree
2020-06-30 12:14 ` [PATCH net-next 12/14] sfc: commonise efx->[rt]xq_entries initialisation Edward Cree
2020-06-30 12:15 ` [PATCH net-next 13/14] sfc: commonise initialisation of efx->vport_id Edward Cree
2020-06-30 12:15 ` [PATCH net-next 14/14] sfc: don't call tx_remove if there isn't one Edward Cree
2020-06-30 19:44 ` [PATCH net-next 00/14] sfc: prerequisites for EF100 driver, part 2 Jakub Kicinski
2020-06-30 20:09 ` David Miller

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=34c4ed3c-8e71-8eb6-fe9f-9f1ed6099e73@solarflare.com \
    --to=ecree@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /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).