Patchwork [dpdk-dev,20/38] net/sfc/base: support different event descriptor sizes

login
register
mail settings
Submitter Andrew Rybchenko
Date Feb. 7, 2019, 4:29 p.m.
Message ID <1549556983-10896-21-git-send-email-arybchenko@solarflare.com>
Download mbox | patch
Permalink /patch/720871/
State New
Headers show

Comments

Andrew Rybchenko - Feb. 7, 2019, 4:29 p.m.
From: Igor Romanov <igor.romanov@oktetlabs.ru>

For consistency with the size of Tx descriptors, the size of event
descriptors should be a part of NIC config, not a macro that is
common for all NIC families. Also, add a max number of EvQ buffers
define which is needed to initialize an MCDI buffer at compile time.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/base/ef10_ev.c       | 12 ++++++------
 drivers/net/sfc/base/ef10_impl.h     | 20 ++++++++++++++++++++
 drivers/net/sfc/base/efx.h           | 20 ++++++++++++++++++++
 drivers/net/sfc/base/efx_ev.c        | 18 ++++++++++++++++++
 drivers/net/sfc/base/hunt_impl.h     |  2 ++
 drivers/net/sfc/base/hunt_nic.c      |  1 +
 drivers/net/sfc/base/medford2_impl.h |  2 ++
 drivers/net/sfc/base/medford2_nic.c  |  1 +
 drivers/net/sfc/base/medford_impl.h  |  2 ++
 drivers/net/sfc/base/medford_nic.c   |  1 +
 drivers/net/sfc/base/siena_impl.h    |  1 +
 drivers/net/sfc/base/siena_nic.c     |  1 +
 12 files changed, 75 insertions(+), 6 deletions(-)

Patch

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 4f711992e..b80cb0a35 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -123,7 +123,7 @@  efx_mcdi_init_evq(
 {
 	efx_mcdi_req_t req;
 	EFX_MCDI_DECLARE_BUF(payload,
-		MC_CMD_INIT_EVQ_IN_LEN(EFX_EVQ_NBUFS(EF10_EVQ_MAXNEVS)),
+		MC_CMD_INIT_EVQ_IN_LEN(EF10_EVQ_MAXNBUFS),
 		MC_CMD_INIT_EVQ_OUT_LEN);
 	efx_qword_t *dma_addr;
 	uint64_t addr;
@@ -133,8 +133,8 @@  efx_mcdi_init_evq(
 	int ev_cut_through;
 	efx_rc_t rc;
 
-	npages = EFX_EVQ_NBUFS(nevs);
-	if (MC_CMD_INIT_EVQ_IN_LEN(npages) > MC_CMD_INIT_EVQ_IN_LENMAX) {
+	npages = efx_evq_nbufs(enp, nevs);
+	if (npages > EF10_EVQ_MAXNBUFS) {
 		rc = EINVAL;
 		goto fail1;
 	}
@@ -259,7 +259,7 @@  efx_mcdi_init_evq_v2(
 {
 	efx_mcdi_req_t req;
 	EFX_MCDI_DECLARE_BUF(payload,
-		MC_CMD_INIT_EVQ_V2_IN_LEN(EFX_EVQ_NBUFS(EF10_EVQ_MAXNEVS)),
+		MC_CMD_INIT_EVQ_V2_IN_LEN(EF10_EVQ_MAXNBUFS),
 		MC_CMD_INIT_EVQ_V2_OUT_LEN);
 	boolean_t interrupting;
 	unsigned int evq_type;
@@ -269,8 +269,8 @@  efx_mcdi_init_evq_v2(
 	int i;
 	efx_rc_t rc;
 
-	npages = EFX_EVQ_NBUFS(nevs);
-	if (MC_CMD_INIT_EVQ_V2_IN_LEN(npages) > MC_CMD_INIT_EVQ_V2_IN_LENMAX) {
+	npages = efx_evq_nbufs(enp, nevs);
+	if (npages > EF10_EVQ_MAXNBUFS) {
 		rc = EINVAL;
 		goto fail1;
 	}
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 11c61d9e6..fae94fe83 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -19,12 +19,32 @@  extern "C" {
 
 #define	EF10_TXQ_MINNDESCS	512
 
+#define	EF10_EVQ_DESC_SIZE	(sizeof (efx_qword_t))
 #define	EF10_RXQ_DESC_SIZE	(sizeof (efx_qword_t))
 #define	EF10_TXQ_DESC_SIZE	(sizeof (efx_qword_t))
 
+/* Number of hardware EVQ buffers (for compile-time resource dimensions) */
+#define	EF10_EVQ_MAXNBUFS	(64)
+
 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
 #define	EF10_TXQ_MAXNBUFS	8
 
+#if EFSYS_OPT_HUNTINGTON
+# if (EF10_EVQ_MAXNBUFS < HUNT_EVQ_MAXNBUFS)
+#  error "EF10_EVQ_MAXNBUFS too small"
+# endif
+#endif /* EFSYS_OPT_HUNTINGTON */
+#if EFSYS_OPT_MEDFORD
+# if (EF10_EVQ_MAXNBUFS < MEDFORD_EVQ_MAXNBUFS)
+#  error "EF10_EVQ_MAXNBUFS too small"
+# endif
+#endif /* EFSYS_OPT_MEDFORD */
+#if EFSYS_OPT_MEDFORD2
+# if (EF10_EVQ_MAXNBUFS < MEDFORD2_EVQ_MAXNBUFS)
+#  error "EF10_EVQ_MAXNBUFS too small"
+# endif
+#endif /* EFSYS_OPT_MEDFORD2 */
+
 /* Number of hardware PIO buffers (for compile-time resource dimensions) */
 #define	EF10_MAX_PIOBUF_NBUFS	(16)
 
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 101bb4cd2..43de0a8a6 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -1284,6 +1284,7 @@  typedef struct efx_nic_cfg_s {
 	uint32_t		enc_evq_timer_quantum_ns;
 	uint32_t		enc_evq_timer_max_us;
 	uint32_t		enc_clk_mult;
+	uint32_t		enc_ev_desc_size;
 	uint32_t		enc_rx_desc_size;
 	uint32_t		enc_tx_desc_size;
 	uint32_t		enc_rx_prefix_size;
@@ -1987,9 +1988,28 @@  efx_ev_fini(
 #define	EFX_EVQ_MAXNEVS		32768
 #define	EFX_EVQ_MINNEVS		512
 
+/*
+ * This macro is deprecated and will be removed.
+ * Use the function efx_evq_size() instead.
+ */
 #define	EFX_EVQ_SIZE(_nevs)	((_nevs) * sizeof (efx_qword_t))
+
+/*
+ * This macro is deprecated and will be removed.
+ * Use the function efx_evq_nbufs() instead.
+ */
 #define	EFX_EVQ_NBUFS(_nevs)	(EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
 
+extern	__checkReturn	size_t
+efx_evq_size(
+	__in	const efx_nic_t *enp,
+	__in	unsigned int ndescs);
+
+extern	__checkReturn	unsigned int
+efx_evq_nbufs(
+	__in	const efx_nic_t *enp,
+	__in	unsigned int ndescs);
+
 #define	EFX_EVQ_FLAGS_TYPE_MASK		(0x3)
 #define	EFX_EVQ_FLAGS_TYPE_AUTO		(0x0)
 #define	EFX_EVQ_FLAGS_TYPE_THROUGHPUT	(0x1)
diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index 51c422c2d..21f4c226c 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/base/efx_ev.c
@@ -173,6 +173,24 @@  efx_ev_init(
 	return (rc);
 }
 
+	__checkReturn	size_t
+efx_evq_size(
+	__in	const efx_nic_t *enp,
+	__in	unsigned int ndescs)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+
+	return (ndescs * encp->enc_ev_desc_size);
+}
+
+	__checkReturn	unsigned int
+efx_evq_nbufs(
+	__in	const efx_nic_t *enp,
+	__in	unsigned int ndescs)
+{
+	return (efx_evq_size(enp, ndescs) / EFX_BUF_SIZE);
+}
+
 		void
 efx_ev_fini(
 	__in	efx_nic_t *enp)
diff --git a/drivers/net/sfc/base/hunt_impl.h b/drivers/net/sfc/base/hunt_impl.h
index 0e9a1e280..a76602d52 100644
--- a/drivers/net/sfc/base/hunt_impl.h
+++ b/drivers/net/sfc/base/hunt_impl.h
@@ -19,6 +19,8 @@  extern "C" {
 #define	HUNT_TXQ_MAXNDESCS			4096
 #define	HUNT_TXQ_MAXNDESCS_BUG35388_WORKAROUND	2048
 
+#define	HUNT_EVQ_MAXNBUFS	(64)
+
 /* Missing register definitions */
 #ifndef	ER_DZ_TX_PIOBUF_OFST
 #define	ER_DZ_TX_PIOBUF_OFST 0x00001000
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 2fb54d85a..054d4f432 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -186,6 +186,7 @@  hunt_board_cfg(
 	/* Checksums for TSO sends can be incorrect on Huntington. */
 	encp->enc_bug61297_workaround = B_TRUE;
 
+	encp->enc_ev_desc_size = EF10_EVQ_DESC_SIZE;
 	encp->enc_rx_desc_size = EF10_RXQ_DESC_SIZE;
 	encp->enc_tx_desc_size = EF10_TXQ_DESC_SIZE;
 
diff --git a/drivers/net/sfc/base/medford2_impl.h b/drivers/net/sfc/base/medford2_impl.h
index 87af5f686..86f374e74 100644
--- a/drivers/net/sfc/base/medford2_impl.h
+++ b/drivers/net/sfc/base/medford2_impl.h
@@ -14,6 +14,8 @@  extern "C" {
 
 #define	MEDFORD2_TXQ_MAXNDESCS	2048
 
+#define	MEDFORD2_EVQ_MAXNBUFS	(64)
+
 #ifndef	ER_EZ_TX_PIOBUF_SIZE
 #define	ER_EZ_TX_PIOBUF_SIZE	4096
 #endif
diff --git a/drivers/net/sfc/base/medford2_nic.c b/drivers/net/sfc/base/medford2_nic.c
index 7d0c80047..16621d190 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -101,6 +101,7 @@  medford2_board_cfg(
 	encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns <<
 		    FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000;
 
+	encp->enc_ev_desc_size = EF10_EVQ_DESC_SIZE;
 	encp->enc_rx_desc_size = EF10_RXQ_DESC_SIZE;
 	encp->enc_tx_desc_size = EF10_TXQ_DESC_SIZE;
 
diff --git a/drivers/net/sfc/base/medford_impl.h b/drivers/net/sfc/base/medford_impl.h
index 1afedc7f3..b0be35a72 100644
--- a/drivers/net/sfc/base/medford_impl.h
+++ b/drivers/net/sfc/base/medford_impl.h
@@ -14,6 +14,8 @@  extern "C" {
 
 #define	MEDFORD_TXQ_MAXNDESCS	2048
 
+#define	MEDFORD_EVQ_MAXNBUFS	(64)
+
 #ifndef	ER_EZ_TX_PIOBUF_SIZE
 #define	ER_EZ_TX_PIOBUF_SIZE	4096
 #endif
diff --git a/drivers/net/sfc/base/medford_nic.c b/drivers/net/sfc/base/medford_nic.c
index fd711a96f..01a346267 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -99,6 +99,7 @@  medford_board_cfg(
 	encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns <<
 		    FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000;
 
+	encp->enc_ev_desc_size = EF10_EVQ_DESC_SIZE;
 	encp->enc_rx_desc_size = EF10_RXQ_DESC_SIZE;
 	encp->enc_tx_desc_size = EF10_TXQ_DESC_SIZE;
 
diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/net/sfc/base/siena_impl.h
index 068960025..4af9845fe 100644
--- a/drivers/net/sfc/base/siena_impl.h
+++ b/drivers/net/sfc/base/siena_impl.h
@@ -34,6 +34,7 @@  extern "C" {
 #define	SIENA_RXQ_MAXNDESCS	4096
 #define	SIENA_RXQ_MINNDESCS	512
 
+#define	SIENA_EVQ_DESC_SIZE	(sizeof (efx_qword_t))
 #define	SIENA_RXQ_DESC_SIZE	(sizeof (efx_qword_t))
 #define	SIENA_TXQ_DESC_SIZE	(sizeof (efx_qword_t))
 
diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/net/sfc/base/siena_nic.c
index 894cf8144..7ba595b75 100644
--- a/drivers/net/sfc/base/siena_nic.c
+++ b/drivers/net/sfc/base/siena_nic.c
@@ -104,6 +104,7 @@  siena_board_cfg(
 	encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns <<
 		FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000;
 
+	encp->enc_ev_desc_size = SIENA_EVQ_DESC_SIZE;
 	encp->enc_rx_desc_size = SIENA_RXQ_DESC_SIZE;
 	encp->enc_tx_desc_size = SIENA_TXQ_DESC_SIZE;