All of lore.kernel.org
 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 v4 net-next 11/16] sfc_ef100: read datapath caps, implement check_caps
Date: Fri, 24 Jul 2020 16:59:45 +0100	[thread overview]
Message-ID: <e70f569a-445b-7c31-07b8-a9feb9ba1132@solarflare.com> (raw)
In-Reply-To: <d224dbb2-ef20-dca9-d50b-7f583b45d859@solarflare.com>

Signed-off-by: Edward Cree <ecree@solarflare.com>
---
 drivers/net/ethernet/sfc/ef100_nic.c | 58 +++++++++++++++++++++++++++-
 drivers/net/ethernet/sfc/ef100_nic.h |  2 +
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index c6703527bbe9..3fb81d6e8df3 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -124,6 +124,49 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx)
 {
 }
 
+/*	MCDI calls
+ */
+static int efx_ef100_init_datapath_caps(struct efx_nic *efx)
+{
+	MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_V4_OUT_LEN);
+	struct ef100_nic_data *nic_data = efx->nic_data;
+	u8 vi_window_mode;
+	size_t outlen;
+	int rc;
+
+	BUILD_BUG_ON(MC_CMD_GET_CAPABILITIES_IN_LEN != 0);
+
+	rc = efx_mcdi_rpc(efx, MC_CMD_GET_CAPABILITIES, NULL, 0,
+			  outbuf, sizeof(outbuf), &outlen);
+	if (rc)
+		return rc;
+	if (outlen < MC_CMD_GET_CAPABILITIES_V4_OUT_LEN) {
+		netif_err(efx, drv, efx->net_dev,
+			  "unable to read datapath firmware capabilities\n");
+		return -EIO;
+	}
+
+	nic_data->datapath_caps = MCDI_DWORD(outbuf,
+					     GET_CAPABILITIES_OUT_FLAGS1);
+	nic_data->datapath_caps2 = MCDI_DWORD(outbuf,
+					      GET_CAPABILITIES_V2_OUT_FLAGS2);
+
+	vi_window_mode = MCDI_BYTE(outbuf,
+				   GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
+	rc = efx_mcdi_window_mode_to_stride(efx, vi_window_mode);
+	if (rc)
+		return rc;
+
+	if (efx_ef100_has_cap(nic_data->datapath_caps2, TX_TSO_V3))
+		efx->net_dev->features |= NETIF_F_TSO | NETIF_F_TSO6;
+	efx->num_mac_stats = MCDI_WORD(outbuf,
+				       GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
+	netif_dbg(efx, probe, efx->net_dev,
+		  "firmware reports num_mac_stats = %u\n",
+		  efx->num_mac_stats);
+	return 0;
+}
+
 /*	Event handling
  */
 static int ef100_ev_probe(struct efx_channel *channel)
@@ -296,8 +339,16 @@ static int ef100_reset(struct efx_nic *efx, enum reset_type reset_type)
 static unsigned int ef100_check_caps(const struct efx_nic *efx,
 				     u8 flag, u32 offset)
 {
-	/* stub */
-	return 0;
+	const struct ef100_nic_data *nic_data = efx->nic_data;
+
+	switch (offset) {
+	case MC_CMD_GET_CAPABILITIES_V8_OUT_FLAGS1_OFST:
+		return nic_data->datapath_caps & BIT_ULL(flag);
+	case MC_CMD_GET_CAPABILITIES_V8_OUT_FLAGS2_OFST:
+		return nic_data->datapath_caps2 & BIT_ULL(flag);
+	default:
+		return 0;
+	}
 }
 
 /*	NIC level access functions
@@ -408,6 +459,9 @@ static int ef100_probe_main(struct efx_nic *efx)
 	}
 	if (rc)
 		goto fail;
+	rc = efx_ef100_init_datapath_caps(efx);
+	if (rc < 0)
+		goto fail;
 
 	efx->max_vis = EF100_MAX_VIS;
 
diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
index 5d376e2d98a7..392611cc33b5 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.h
+++ b/drivers/net/ethernet/sfc/ef100_nic.h
@@ -20,6 +20,8 @@ void ef100_remove(struct efx_nic *efx);
 struct ef100_nic_data {
 	struct efx_nic *efx;
 	struct efx_buffer mcdi_buf;
+	u32 datapath_caps;
+	u32 datapath_caps2;
 	u16 warm_boot_count;
 	DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS);
 };


  parent reply	other threads:[~2020-07-24 15:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 15:56 [PATCH v4 net-next 00/16] sfc: driver for EF100 family NICs, part 1 Edward Cree
2020-07-24 15:57 ` [PATCH v4 net-next 01/16] sfc: remove efx_ethtool_nway_reset() Edward Cree
2020-07-24 15:57 ` [PATCH v4 net-next 02/16] sfc_ef100: add EF100 register definitions Edward Cree
2020-07-24 15:57 ` [PATCH v4 net-next 03/16] sfc_ef100: register accesses on EF100 Edward Cree
2020-07-24 15:57 ` [PATCH v4 net-next 04/16] sfc: skeleton EF100 PF driver Edward Cree
2020-07-24 20:32   ` kernel test robot
2020-07-24 20:32     ` kernel test robot
2020-07-27 10:41     ` Edward Cree
2020-07-27 10:41       ` Edward Cree
2020-07-24 21:44   ` kernel test robot
2020-07-24 21:44     ` kernel test robot
2020-07-24 15:58 ` [PATCH v4 net-next 05/16] sfc_ef100: reset-handling stub Edward Cree
2020-07-24 15:58 ` [PATCH v4 net-next 06/16] sfc_ef100: PHY probe stub Edward Cree
2020-07-24 15:58 ` [PATCH v4 net-next 07/16] sfc_ef100: don't call efx_reset_down()/up() on EF100 Edward Cree
2020-07-24 15:58 ` [PATCH v4 net-next 08/16] sfc_ef100: implement MCDI transport Edward Cree
2020-07-24 15:59 ` [PATCH v4 net-next 09/16] sfc_ef100: implement ndo_open/close and EVQ probing Edward Cree
2020-07-24 21:54   ` kernel test robot
2020-07-24 21:54     ` kernel test robot
2020-07-24 15:59 ` [PATCH v4 net-next 10/16] sfc_ef100: process events for MCDI completions Edward Cree
2020-07-24 15:59 ` Edward Cree [this message]
2020-07-24 16:00 ` [PATCH v4 net-next 12/16] sfc_ef100: extend ef100_check_caps to cover datapath_caps3 Edward Cree
2020-07-24 16:00 ` [PATCH v4 net-next 13/16] sfc_ef100: actually perform resets Edward Cree
2020-07-24 16:00 ` [PATCH v4 net-next 14/16] sfc_ef100: probe the PHY and configure the MAC Edward Cree
2020-07-24 16:01 ` [PATCH v4 net-next 15/16] sfc_ef100: read device MAC address at probe time Edward Cree
2020-07-24 16:01 ` [PATCH v4 net-next 16/16] sfc_ef100: implement ndo_get_phys_port_{id,name} Edward Cree

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=e70f569a-445b-7c31-07b8-a9feb9ba1132@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 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.