All of lore.kernel.org
 help / color / mirror / Atom feed
From: <ecree@xilinx.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<linux-net-drivers@amd.com>
Cc: <netdev@vger.kernel.org>, Edward Cree <ecree.xilinx@gmail.com>
Subject: [PATCH net-next v2 11/14] sfc: fetch existing assigned MAC address from FW when creating VF rep
Date: Wed, 27 Jul 2022 18:46:01 +0100	[thread overview]
Message-ID: <74faecee040a5dd9c08c404f04afd4ad0d2bb6fa.1658943678.git.ecree.xilinx@gmail.com> (raw)
In-Reply-To: <cover.1658943677.git.ecree.xilinx@gmail.com>

From: Edward Cree <ecree.xilinx@gmail.com>

For the sake of code commonality, this changes the PF probe path to also
 use MC_CMD_GET_CLIENT_MAC_ADDRESSES instead of the old
 MC_CMD_GET_MAC_ADDRESSES.

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
---
 drivers/net/ethernet/sfc/ef100_nic.c | 32 +++++++++++++++++++---------
 drivers/net/ethernet/sfc/ef100_nic.h |  2 ++
 drivers/net/ethernet/sfc/ef100_rep.c |  6 ++++++
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index f79587a2f4ab..2d244a425821 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -130,23 +130,34 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx)
 
 /*	MCDI calls
  */
-static int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address)
+int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
+			  int client_handle, bool empty_ok)
 {
-	MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN);
+	MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1));
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN);
 	size_t outlen;
 	int rc;
 
-	BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0);
+	MCDI_SET_DWORD(inbuf, GET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
+		       client_handle);
 
-	rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0,
-			  outbuf, sizeof(outbuf), &outlen);
+	rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_MAC_ADDRESSES, inbuf,
+			  sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
 	if (rc)
 		return rc;
-	if (outlen < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)
-		return -EIO;
 
-	ether_addr_copy(mac_address,
-			MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE));
+	if (outlen >= MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)) {
+		ether_addr_copy(mac_address,
+				MCDI_PTR(outbuf,
+					 GET_CLIENT_MAC_ADDRESSES_OUT_MAC_ADDRS));
+	} else if (empty_ok) {
+		pci_warn(efx->pci_dev,
+			 "No MAC address provisioned for client ID %#x.\n",
+			 client_handle);
+		eth_zero_addr(mac_address);
+	} else {
+		return -ENOENT;
+	}
 	return 0;
 }
 
@@ -1127,7 +1138,8 @@ int ef100_probe_netdev_pf(struct efx_nic *efx)
 	struct net_device *net_dev = efx->net_dev;
 	int rc;
 
-	rc = ef100_get_mac_address(efx, net_dev->perm_addr);
+	rc = ef100_get_mac_address(efx, net_dev->perm_addr, CLIENT_HANDLE_SELF,
+				   false);
 	if (rc)
 		goto fail;
 	/* Assign MAC address */
diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
index cf78a5a2b7d6..5241fc1d928e 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.h
+++ b/drivers/net/ethernet/sfc/ef100_nic.h
@@ -17,6 +17,8 @@
 extern const struct efx_nic_type ef100_pf_nic_type;
 extern const struct efx_nic_type ef100_vf_nic_type;
 
+int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
+			  int client_handle, bool empty_ok);
 int efx_ef100_lookup_client_id(struct efx_nic *efx, efx_qword_t pciefn, u32 *id);
 int ef100_probe_netdev_pf(struct efx_nic *efx);
 int ef100_probe_vf(struct efx_nic *efx);
diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c
index 3c5f22a6c3b5..ebab4579e63b 100644
--- a/drivers/net/ethernet/sfc/ef100_rep.c
+++ b/drivers/net/ethernet/sfc/ef100_rep.c
@@ -199,6 +199,7 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx,
 
 static int efx_ef100_configure_rep(struct efx_rep *efv)
 {
+	struct net_device *net_dev = efv->net_dev;
 	struct efx_nic *efx = efv->parent;
 	efx_qword_t pciefn;
 	u32 selector;
@@ -229,6 +230,11 @@ static int efx_ef100_configure_rep(struct efx_rep *efv)
 	} else {
 		pci_dbg(efx->pci_dev, "VF %u client ID %#x\n",
 			efv->idx, efv->clid);
+
+		/* Get the assigned MAC address */
+		(void)ef100_get_mac_address(efx, net_dev->perm_addr, efv->clid,
+					    true);
+		eth_hw_addr_set(net_dev, net_dev->perm_addr);
 	}
 
 	return efx_tc_configure_default_rule_rep(efv);

  parent reply	other threads:[~2022-07-27 18:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 17:45 [PATCH net-next v2 00/14] sfc: VF representors for EF100 - RX side ecree
2022-07-27 17:45 ` [PATCH net-next v2 01/14] sfc: plumb ef100 representor stats ecree
2022-07-27 17:45 ` [PATCH net-next v2 02/14] sfc: ef100 representor RX NAPI poll ecree
2022-07-27 17:45 ` [PATCH net-next v2 03/14] sfc: ef100 representor RX top half ecree
2022-07-27 17:45 ` [PATCH net-next v2 04/14] sfc: determine wire m-port at EF100 PF probe time ecree
2022-07-27 17:45 ` [PATCH net-next v2 05/14] sfc: check ef100 RX packets are from the wire ecree
2022-07-27 17:45 ` [PATCH net-next v2 06/14] sfc: receive packets from EF100 VFs into representors ecree
2022-07-27 17:45 ` [PATCH net-next v2 07/14] sfc: insert default MAE rules to connect VFs to representors ecree
2022-07-27 17:45 ` [PATCH net-next v2 08/14] sfc: move table locking into filter_table_{probe,remove} methods ecree
2022-07-27 17:45 ` [PATCH net-next v2 09/14] sfc: use a dynamic m-port for representor RX and set it promisc ecree
2022-07-27 17:46 ` [PATCH net-next v2 10/14] sfc: look up VF's client ID when creating representor ecree
2022-07-27 17:46 ` ecree [this message]
2022-07-27 17:46 ` [PATCH net-next v2 12/14] sfc: set EF100 VF MAC address through representor ecree
2022-07-28  3:10   ` Jakub Kicinski
2022-07-28 15:47     ` Edward Cree
2022-07-28 16:20       ` Jakub Kicinski
2022-07-28 18:12         ` Edward Cree
2022-07-28 18:32           ` Jakub Kicinski
2022-07-28 18:54             ` Edward Cree
2022-07-28 19:27               ` Jakub Kicinski
2022-07-28 20:23                 ` Edward Cree
2022-07-29  1:45                   ` Jakub Kicinski
2022-07-29 15:17                     ` Edward Cree
2022-07-27 17:46 ` [PATCH net-next v2 13/14] sfc: get provisioned MAC address on EF100 VF probe ecree
2022-07-27 17:46 ` [PATCH net-next v2 14/14] sfc: implement ethtool get/set RX ring size for EF100 reps ecree

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=74faecee040a5dd9c08c404f04afd4ad0d2bb6fa.1658943678.git.ecree.xilinx@gmail.com \
    --to=ecree@xilinx.com \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-net-drivers@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.