DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library
@ 2020-09-08  9:14 Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
                   ` (16 more replies)
  0 siblings, 17 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, David Marchand, Ferruh Yigit

Network and vDPA drivers share libefx. So, libefx should be moved
to common drivers.

DPDK adaptation of the MCDI interface may be shared as well.

The new common driver name is sfc_efx since it a new home of
libefx base driver. sfc_ prefix is used to make it clear that
it is related to net/sfc (and vdpa/sfc in the future).

In theory, right now all exported libefx functions should be marked
as internal, but it requires corresponding markup in base driver
which sources should have no DPDK specifics since shared by many
drivers. So, it is unclear what to do and how to solve it.

The patch series makes these functions a part of DPDK_21 ABI to
pass build checks. checkpatches.sh does not like it.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: David Marchand <david.marchand@redhat.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>

Andrew Rybchenko (14):
  net/sfc: include header with debug helpers directly
  net/sfc: introduce common driver library
  net/sfc: add dedicated header file with MCDI interface
  net/sfc: move MCDI helper interface to dedicated namespace
  net/sfc: make MCDI logging helper macros local
  net/sfc: start to make MCDI helpers interface shareable
  net/sfc: use own logging helper macros
  net/sfc: avoid usage of NIC pointer from adapter context
  net/sfc: avoid panic in the case of MCDI timeout
  net/sfc: add MCDI callbacks to allocate/free DMA memory
  net/sfc: add MCDI callback to schedule restart
  net/sfc: add MCDI callback to poll management event queue
  net/sfc: use MCDI control structure as libefx ops context
  net/sfc: move MCDI helpers to common driver

 MAINTAINERS                                   |   1 +
 drivers/common/Makefile                       |   4 +
 drivers/common/meson.build                    |   2 +-
 drivers/common/sfc_efx/Makefile               | 112 ++++++
 .../{net/sfc => common/sfc_efx}/base/README   |   0
 .../sfc => common/sfc_efx}/base/ef10_ev.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_evb.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_filter.c |   0
 .../sfc_efx}/base/ef10_firmware_ids.h         |   0
 .../sfc => common/sfc_efx}/base/ef10_image.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_impl.h   |   0
 .../sfc => common/sfc_efx}/base/ef10_intr.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_mac.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_mcdi.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_nic.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_nvram.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_phy.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_proxy.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_rx.c     |   0
 .../sfc_efx}/base/ef10_signed_image_layout.h  |   0
 .../sfc_efx}/base/ef10_tlv_layout.h           |   0
 .../sfc => common/sfc_efx}/base/ef10_tx.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_vpd.c    |   0
 .../{net/sfc => common/sfc_efx}/base/efx.h    |   0
 .../sfc => common/sfc_efx}/base/efx_annote.h  |   0
 .../sfc => common/sfc_efx}/base/efx_bootcfg.c |   0
 .../sfc => common/sfc_efx}/base/efx_check.h   |   0
 .../sfc => common/sfc_efx}/base/efx_crc32.c   |   0
 .../{net/sfc => common/sfc_efx}/base/efx_ev.c |   0
 .../sfc => common/sfc_efx}/base/efx_evb.c     |   0
 .../sfc => common/sfc_efx}/base/efx_filter.c  |   0
 .../sfc => common/sfc_efx}/base/efx_hash.c    |   0
 .../sfc => common/sfc_efx}/base/efx_impl.h    |   0
 .../sfc => common/sfc_efx}/base/efx_intr.c    |   0
 .../sfc => common/sfc_efx}/base/efx_lic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mac.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.c    |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.h    |   0
 .../sfc => common/sfc_efx}/base/efx_mon.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nvram.c   |   0
 .../sfc => common/sfc_efx}/base/efx_phy.c     |   0
 .../sfc => common/sfc_efx}/base/efx_phy_ids.h |   0
 .../sfc => common/sfc_efx}/base/efx_port.c    |   0
 .../sfc => common/sfc_efx}/base/efx_proxy.c   |   0
 .../sfc => common/sfc_efx}/base/efx_regs.h    |   0
 .../sfc_efx}/base/efx_regs_ef10.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi_aoe.h         |   0
 .../sfc_efx}/base/efx_regs_mcdi_strs.h        |   0
 .../sfc_efx}/base/efx_regs_pci.h              |   0
 .../{net/sfc => common/sfc_efx}/base/efx_rx.c |   0
 .../sfc => common/sfc_efx}/base/efx_sram.c    |   0
 .../sfc => common/sfc_efx}/base/efx_tunnel.c  |   0
 .../{net/sfc => common/sfc_efx}/base/efx_tx.c |   0
 .../sfc => common/sfc_efx}/base/efx_types.h   |   0
 .../sfc => common/sfc_efx}/base/efx_vpd.c     |   0
 .../sfc => common/sfc_efx}/base/hunt_impl.h   |   0
 .../sfc => common/sfc_efx}/base/hunt_nic.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.h    |   0
 .../sfc_efx}/base/medford2_impl.h             |   0
 .../sfc_efx}/base/medford2_nic.c              |   0
 .../sfc_efx}/base/medford_impl.h              |   0
 .../sfc => common/sfc_efx}/base/medford_nic.c |   0
 .../sfc => common/sfc_efx}/base/meson.build   |   0
 .../sfc => common/sfc_efx}/base/siena_flash.h |   0
 .../sfc => common/sfc_efx}/base/siena_impl.h  |   0
 .../sfc => common/sfc_efx}/base/siena_mac.c   |   0
 .../sfc => common/sfc_efx}/base/siena_mcdi.c  |   0
 .../sfc => common/sfc_efx}/base/siena_nic.c   |   0
 .../sfc => common/sfc_efx}/base/siena_nvram.c |   0
 .../sfc => common/sfc_efx}/base/siena_phy.c   |   0
 .../sfc => common/sfc_efx}/base/siena_sram.c  |   0
 .../sfc => common/sfc_efx}/base/siena_vpd.c   |   0
 drivers/{net/sfc => common/sfc_efx}/efsys.h   |  58 +--
 drivers/common/sfc_efx/meson.build            |  40 ++
 .../sfc_efx/rte_common_sfc_efx_version.map    | 119 ++++++
 drivers/common/sfc_efx/sfc_efx.c              |  23 ++
 drivers/common/sfc_efx/sfc_efx_debug.h        |  29 ++
 drivers/common/sfc_efx/sfc_efx_log.h          |  22 ++
 drivers/common/sfc_efx/sfc_efx_mcdi.c         | 343 ++++++++++++++++++
 drivers/common/sfc_efx/sfc_efx_mcdi.h         |  75 ++++
 drivers/net/sfc/Makefile                      |  70 +---
 drivers/net/sfc/meson.build                   |   6 +-
 drivers/net/sfc/sfc.c                         |   1 +
 drivers/net/sfc/sfc.h                         |  26 +-
 drivers/net/sfc/sfc_dp_tx.h                   |   1 +
 drivers/net/sfc/sfc_ef10.h                    |   2 +
 drivers/net/sfc/sfc_ef10_essb_rx.c            |   1 +
 drivers/net/sfc/sfc_ef10_rx.c                 |   1 +
 drivers/net/sfc/sfc_ef10_rx_ev.h              |   2 +
 drivers/net/sfc/sfc_ef10_tx.c                 |   1 +
 drivers/net/sfc/sfc_ethdev.c                  |  13 +
 drivers/net/sfc/sfc_filter.c                  |   1 +
 drivers/net/sfc/sfc_flow.c                    |   1 +
 drivers/net/sfc/sfc_log.h                     |  21 +-
 drivers/net/sfc/sfc_mcdi.c                    | 295 ++-------------
 drivers/net/sfc/sfc_port.c                    |   1 +
 mk/rte.app.mk                                 |   1 +
 100 files changed, 870 insertions(+), 402 deletions(-)
 create mode 100644 drivers/common/sfc_efx/Makefile
 rename drivers/{net/sfc => common/sfc_efx}/base/README (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_firmware_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_image.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_signed_image_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tlv_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_annote.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_bootcfg.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_check.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_crc32.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_hash.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_lic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_port.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_ef10.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_aoe.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_strs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_pci.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tunnel.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_types.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/meson.build (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_flash.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/efsys.h (93%)
 create mode 100644 drivers/common/sfc_efx/meson.build
 create mode 100644 drivers/common/sfc_efx/rte_common_sfc_efx_version.map
 create mode 100644 drivers/common/sfc_efx/sfc_efx.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_debug.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_log.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:26   ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly Andrew Rybchenko
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev; +Cc: Steve Yang, stable

From: Steve Yang <stevex.yang@intel.com>

When receiving the unsupported AQ messages, it's taken as an
error. It's not appropriate and triggers too much unnecessary print.

Fixes: 22b123a36d07 ("net/avf: initialize PMD")
Cc: stable@dpdk.org

Signed-off-by: Steve Yang <stevex.yang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index ff2ac3c367..34c31a153a 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -269,7 +269,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 			}
 			break;
 		default:
-			PMD_DRV_LOG(ERR, "Request %u is not supported yet",
+			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
 				    aq_opc);
 			break;
 		}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library Andrew Rybchenko
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Avoid build failures on further restructuring.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.c              | 1 +
 drivers/net/sfc/sfc.h              | 1 +
 drivers/net/sfc/sfc_dp_tx.h        | 1 +
 drivers/net/sfc/sfc_ef10.h         | 2 ++
 drivers/net/sfc/sfc_ef10_essb_rx.c | 1 +
 drivers/net/sfc/sfc_ef10_rx.c      | 1 +
 drivers/net/sfc/sfc_ef10_rx_ev.h   | 2 ++
 drivers/net/sfc/sfc_ef10_tx.c      | 1 +
 drivers/net/sfc/sfc_filter.c       | 1 +
 drivers/net/sfc/sfc_flow.c         | 1 +
 drivers/net/sfc/sfc_mcdi.c         | 1 +
 drivers/net/sfc/sfc_port.c         | 1 +
 12 files changed, 14 insertions(+)

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index c19d81cc88..03ea5dc128 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -16,6 +16,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index cf95ebaf90..cdff9be3ec 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -21,6 +21,7 @@
 
 #include "efx.h"
 
+#include "sfc_debug.h"
 #include "sfc_filter.h"
 
 #ifdef __cplusplus
diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index dcad4fe585..77ae166885 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -12,6 +12,7 @@
 
 #include <rte_ethdev_driver.h>
 
+#include "sfc_debug.h"
 #include "sfc_dp.h"
 #include "sfc_debug.h"
 #include "sfc_tso.h"
diff --git a/drivers/net/sfc/sfc_ef10.h b/drivers/net/sfc/sfc_ef10.h
index f138e8d9b0..07c322f7a6 100644
--- a/drivers/net/sfc/sfc_ef10.h
+++ b/drivers/net/sfc/sfc_ef10.h
@@ -10,6 +10,8 @@
 #ifndef _SFC_EF10_H
 #define _SFC_EF10_H
 
+#include "sfc_debug.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c
index 13b2b824e3..8238cc830d 100644
--- a/drivers/net/sfc/sfc_ef10_essb_rx.c
+++ b/drivers/net/sfc/sfc_ef10_essb_rx.c
@@ -18,6 +18,7 @@
 #include "efx_types.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_tweak.h"
 #include "sfc_dp_rx.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c
index 42e205e1bd..8c6ebaa2fa 100644
--- a/drivers/net/sfc/sfc_ef10_rx.c
+++ b/drivers/net/sfc/sfc_ef10_rx.c
@@ -21,6 +21,7 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_tweak.h"
 #include "sfc_dp_rx.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_ef10_rx_ev.h b/drivers/net/sfc/sfc_ef10_rx_ev.h
index a9896eae56..d15d24f4c1 100644
--- a/drivers/net/sfc/sfc_ef10_rx_ev.h
+++ b/drivers/net/sfc/sfc_ef10_rx_ev.h
@@ -16,6 +16,8 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c
index b91c8068b1..4d7da427cb 100644
--- a/drivers/net/sfc/sfc_ef10_tx.c
+++ b/drivers/net/sfc/sfc_ef10_tx.c
@@ -19,6 +19,7 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_dp_tx.h"
 #include "sfc_tweak.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_filter.c b/drivers/net/sfc/sfc_filter.c
index 7f4f7c47a5..05a9799230 100644
--- a/drivers/net/sfc/sfc_filter.c
+++ b/drivers/net/sfc/sfc_filter.c
@@ -12,6 +12,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 
 boolean_t
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index c8e6fb8bce..1a3c0d618b 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -18,6 +18,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_rx.h"
 #include "sfc_filter.h"
 #include "sfc_flow.h"
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 872e4e76b1..ec62ba95ff 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -14,6 +14,7 @@
 #include "efx_regs_mcdi.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 32a0894a55..4de13267d5 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -10,6 +10,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_kvargs.h"
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Move libefx (base driver) into common driver.

Prepare to add vDPA driver which will use the common driver as well.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 MAINTAINERS                                   |   1 +
 drivers/common/Makefile                       |   4 +
 drivers/common/meson.build                    |   2 +-
 drivers/common/sfc_efx/Makefile               | 111 ++++++++++++++++
 .../{net/sfc => common/sfc_efx}/base/README   |   0
 .../sfc => common/sfc_efx}/base/ef10_ev.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_evb.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_filter.c |   0
 .../sfc_efx}/base/ef10_firmware_ids.h         |   0
 .../sfc => common/sfc_efx}/base/ef10_image.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_impl.h   |   0
 .../sfc => common/sfc_efx}/base/ef10_intr.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_mac.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_mcdi.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_nic.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_nvram.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_phy.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_proxy.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_rx.c     |   0
 .../sfc_efx}/base/ef10_signed_image_layout.h  |   0
 .../sfc_efx}/base/ef10_tlv_layout.h           |   0
 .../sfc => common/sfc_efx}/base/ef10_tx.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_vpd.c    |   0
 .../{net/sfc => common/sfc_efx}/base/efx.h    |   0
 .../sfc => common/sfc_efx}/base/efx_annote.h  |   0
 .../sfc => common/sfc_efx}/base/efx_bootcfg.c |   0
 .../sfc => common/sfc_efx}/base/efx_check.h   |   0
 .../sfc => common/sfc_efx}/base/efx_crc32.c   |   0
 .../{net/sfc => common/sfc_efx}/base/efx_ev.c |   0
 .../sfc => common/sfc_efx}/base/efx_evb.c     |   0
 .../sfc => common/sfc_efx}/base/efx_filter.c  |   0
 .../sfc => common/sfc_efx}/base/efx_hash.c    |   0
 .../sfc => common/sfc_efx}/base/efx_impl.h    |   0
 .../sfc => common/sfc_efx}/base/efx_intr.c    |   0
 .../sfc => common/sfc_efx}/base/efx_lic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mac.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.c    |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.h    |   0
 .../sfc => common/sfc_efx}/base/efx_mon.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nvram.c   |   0
 .../sfc => common/sfc_efx}/base/efx_phy.c     |   0
 .../sfc => common/sfc_efx}/base/efx_phy_ids.h |   0
 .../sfc => common/sfc_efx}/base/efx_port.c    |   0
 .../sfc => common/sfc_efx}/base/efx_proxy.c   |   0
 .../sfc => common/sfc_efx}/base/efx_regs.h    |   0
 .../sfc_efx}/base/efx_regs_ef10.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi_aoe.h         |   0
 .../sfc_efx}/base/efx_regs_mcdi_strs.h        |   0
 .../sfc_efx}/base/efx_regs_pci.h              |   0
 .../{net/sfc => common/sfc_efx}/base/efx_rx.c |   0
 .../sfc => common/sfc_efx}/base/efx_sram.c    |   0
 .../sfc => common/sfc_efx}/base/efx_tunnel.c  |   0
 .../{net/sfc => common/sfc_efx}/base/efx_tx.c |   0
 .../sfc => common/sfc_efx}/base/efx_types.h   |   0
 .../sfc => common/sfc_efx}/base/efx_vpd.c     |   0
 .../sfc => common/sfc_efx}/base/hunt_impl.h   |   0
 .../sfc => common/sfc_efx}/base/hunt_nic.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.h    |   0
 .../sfc_efx}/base/medford2_impl.h             |   0
 .../sfc_efx}/base/medford2_nic.c              |   0
 .../sfc_efx}/base/medford_impl.h              |   0
 .../sfc => common/sfc_efx}/base/medford_nic.c |   0
 .../sfc => common/sfc_efx}/base/meson.build   |   0
 .../sfc => common/sfc_efx}/base/siena_flash.h |   0
 .../sfc => common/sfc_efx}/base/siena_impl.h  |   0
 .../sfc => common/sfc_efx}/base/siena_mac.c   |   0
 .../sfc => common/sfc_efx}/base/siena_mcdi.c  |   0
 .../sfc => common/sfc_efx}/base/siena_nic.c   |   0
 .../sfc => common/sfc_efx}/base/siena_nvram.c |   0
 .../sfc => common/sfc_efx}/base/siena_phy.c   |   0
 .../sfc => common/sfc_efx}/base/siena_sram.c  |   0
 .../sfc => common/sfc_efx}/base/siena_vpd.c   |   0
 drivers/{net/sfc => common/sfc_efx}/efsys.h   |  58 ++++-----
 drivers/common/sfc_efx/meson.build            |  39 ++++++
 .../sfc_efx/rte_common_sfc_efx_version.map    | 122 ++++++++++++++++++
 drivers/common/sfc_efx/sfc_efx.c              |  23 ++++
 drivers/common/sfc_efx/sfc_efx_debug.h        |  29 +++++
 drivers/common/sfc_efx/sfc_efx_log.h          |  22 ++++
 drivers/net/sfc/Makefile                      |  70 +---------
 drivers/net/sfc/meson.build                   |   6 +-
 mk/rte.app.mk                                 |   1 +
 84 files changed, 386 insertions(+), 102 deletions(-)
 create mode 100644 drivers/common/sfc_efx/Makefile
 rename drivers/{net/sfc => common/sfc_efx}/base/README (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_firmware_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_image.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_signed_image_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tlv_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_annote.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_bootcfg.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_check.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_crc32.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_hash.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_lic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_port.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_ef10.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_aoe.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_strs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_pci.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tunnel.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_types.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/meson.build (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_flash.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/efsys.h (93%)
 create mode 100644 drivers/common/sfc_efx/meson.build
 create mode 100644 drivers/common/sfc_efx/rte_common_sfc_efx_version.map
 create mode 100644 drivers/common/sfc_efx/sfc_efx.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_debug.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index ed163f5d59..ee20e261d5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -872,6 +872,7 @@ F: doc/guides/nics/features/qede*.ini
 
 Solarflare sfc_efx
 M: Andrew Rybchenko <arybchenko@solarflare.com>
+F: drivers/common/sfc_efx/
 F: drivers/net/sfc/
 F: doc/guides/nics/sfc_efx.rst
 F: doc/guides/nics/features/sfc_efx.ini
diff --git a/drivers/common/Makefile b/drivers/common/Makefile
index cfb6b4dc88..378ab4281c 100644
--- a/drivers/common/Makefile
+++ b/drivers/common/Makefile
@@ -36,4 +36,8 @@ ifneq (,$(findstring y,$(IAVF-y)))
 DIRS-y += iavf
 endif
 
+ifeq ($(findstring y,$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)),y)
+DIRS-y += sfc_efx
+endif
+
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/common/meson.build b/drivers/common/meson.build
index 9ed4c04ba5..7ac1ca73a2 100644
--- a/drivers/common/meson.build
+++ b/drivers/common/meson.build
@@ -6,6 +6,6 @@ if is_windows
 endif
 
 std_deps = ['eal']
-drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat']
+drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat', 'sfc_efx']
 config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
 driver_name_fmt = 'rte_common_@0@'
diff --git a/drivers/common/sfc_efx/Makefile b/drivers/common/sfc_efx/Makefile
new file mode 100644
index 0000000000..0bd6a593e9
--- /dev/null
+++ b/drivers/common/sfc_efx/Makefile
@@ -0,0 +1,111 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2019-2020 Xilinx, Inc.
+#
+# This software was jointly developed between OKTET Labs (under contract
+# for Solarflare) and Solarflare Communications, Inc.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_common_sfc_efx.a
+
+CFLAGS += -I$(SRCDIR)/base/
+CFLAGS += -I$(SRCDIR)
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# Enable extra warnings
+CFLAGS += -Wextra
+
+# More warnings not enabled by above aggregators
+CFLAGS += -Wdisabled-optimization
+
+# Extra CFLAGS for base driver files
+CFLAGS_BASE_DRIVER += -Wno-sign-compare
+CFLAGS_BASE_DRIVER += -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
+
+# Compiler and version dependent flags
+ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
+CFLAGS += -Waggregate-return
+CFLAGS += -Wnested-externs
+CFLAGS_BASE_DRIVER += -Wno-empty-body
+CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS += -Waggregate-return
+CFLAGS += -Wbad-function-cast
+CFLAGS_BASE_DRIVER += -Wno-empty-body
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
+endif
+LDLIBS += -lrte_eal
+
+#
+# List of base driver object files for which
+# special CFLAGS above should be applied
+#
+BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c))))
+$(foreach obj, $(BASE_DRIVER_OBJS), \
+  $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
+
+EXPORT_MAP := rte_common_sfc_efx_version.map
+
+#
+# all source are stored in SRCS-y
+#
+
+SRCS-y += sfc_efx.c
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += efx_bootcfg.c
+SRCS-y += efx_crc32.c
+SRCS-y += efx_ev.c
+SRCS-y += efx_evb.c
+SRCS-y += efx_filter.c
+SRCS-y += efx_hash.c
+SRCS-y += efx_intr.c
+SRCS-y += efx_lic.c
+SRCS-y += efx_mac.c
+SRCS-y += efx_mcdi.c
+SRCS-y += efx_mon.c
+SRCS-y += efx_nic.c
+SRCS-y += efx_nvram.c
+SRCS-y += efx_phy.c
+SRCS-y += efx_port.c
+SRCS-y += efx_proxy.c
+SRCS-y += efx_rx.c
+SRCS-y += efx_sram.c
+SRCS-y += efx_tunnel.c
+SRCS-y += efx_tx.c
+SRCS-y += efx_vpd.c
+SRCS-y += mcdi_mon.c
+SRCS-y += siena_mac.c
+SRCS-y += siena_mcdi.c
+SRCS-y += siena_nic.c
+SRCS-y += siena_nvram.c
+SRCS-y += siena_phy.c
+SRCS-y += siena_sram.c
+SRCS-y += siena_vpd.c
+SRCS-y += ef10_ev.c
+SRCS-y += ef10_evb.c
+SRCS-y += ef10_filter.c
+SRCS-y += ef10_intr.c
+SRCS-y += ef10_image.c
+SRCS-y += ef10_mac.c
+SRCS-y += ef10_mcdi.c
+SRCS-y += ef10_nic.c
+SRCS-y += ef10_nvram.c
+SRCS-y += ef10_phy.c
+SRCS-y += ef10_proxy.c
+SRCS-y += ef10_rx.c
+SRCS-y += ef10_tx.c
+SRCS-y += ef10_vpd.c
+SRCS-y += hunt_nic.c
+SRCS-y += medford_nic.c
+SRCS-y += medford2_nic.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/sfc/base/README b/drivers/common/sfc_efx/base/README
similarity index 100%
rename from drivers/net/sfc/base/README
rename to drivers/common/sfc_efx/base/README
diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/common/sfc_efx/base/ef10_ev.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_ev.c
rename to drivers/common/sfc_efx/base/ef10_ev.c
diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/common/sfc_efx/base/ef10_evb.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_evb.c
rename to drivers/common/sfc_efx/base/ef10_evb.c
diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_filter.c
rename to drivers/common/sfc_efx/base/ef10_filter.c
diff --git a/drivers/net/sfc/base/ef10_firmware_ids.h b/drivers/common/sfc_efx/base/ef10_firmware_ids.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_firmware_ids.h
rename to drivers/common/sfc_efx/base/ef10_firmware_ids.h
diff --git a/drivers/net/sfc/base/ef10_image.c b/drivers/common/sfc_efx/base/ef10_image.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_image.c
rename to drivers/common/sfc_efx/base/ef10_image.c
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_impl.h
rename to drivers/common/sfc_efx/base/ef10_impl.h
diff --git a/drivers/net/sfc/base/ef10_intr.c b/drivers/common/sfc_efx/base/ef10_intr.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_intr.c
rename to drivers/common/sfc_efx/base/ef10_intr.c
diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/common/sfc_efx/base/ef10_mac.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_mac.c
rename to drivers/common/sfc_efx/base/ef10_mac.c
diff --git a/drivers/net/sfc/base/ef10_mcdi.c b/drivers/common/sfc_efx/base/ef10_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_mcdi.c
rename to drivers/common/sfc_efx/base/ef10_mcdi.c
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_nic.c
rename to drivers/common/sfc_efx/base/ef10_nic.c
diff --git a/drivers/net/sfc/base/ef10_nvram.c b/drivers/common/sfc_efx/base/ef10_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_nvram.c
rename to drivers/common/sfc_efx/base/ef10_nvram.c
diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/common/sfc_efx/base/ef10_phy.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_phy.c
rename to drivers/common/sfc_efx/base/ef10_phy.c
diff --git a/drivers/net/sfc/base/ef10_proxy.c b/drivers/common/sfc_efx/base/ef10_proxy.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_proxy.c
rename to drivers/common/sfc_efx/base/ef10_proxy.c
diff --git a/drivers/net/sfc/base/ef10_rx.c b/drivers/common/sfc_efx/base/ef10_rx.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_rx.c
rename to drivers/common/sfc_efx/base/ef10_rx.c
diff --git a/drivers/net/sfc/base/ef10_signed_image_layout.h b/drivers/common/sfc_efx/base/ef10_signed_image_layout.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_signed_image_layout.h
rename to drivers/common/sfc_efx/base/ef10_signed_image_layout.h
diff --git a/drivers/net/sfc/base/ef10_tlv_layout.h b/drivers/common/sfc_efx/base/ef10_tlv_layout.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_tlv_layout.h
rename to drivers/common/sfc_efx/base/ef10_tlv_layout.h
diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/common/sfc_efx/base/ef10_tx.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_tx.c
rename to drivers/common/sfc_efx/base/ef10_tx.c
diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/common/sfc_efx/base/ef10_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_vpd.c
rename to drivers/common/sfc_efx/base/ef10_vpd.c
diff --git a/drivers/net/sfc/base/efx.h b/drivers/common/sfc_efx/base/efx.h
similarity index 100%
rename from drivers/net/sfc/base/efx.h
rename to drivers/common/sfc_efx/base/efx.h
diff --git a/drivers/net/sfc/base/efx_annote.h b/drivers/common/sfc_efx/base/efx_annote.h
similarity index 100%
rename from drivers/net/sfc/base/efx_annote.h
rename to drivers/common/sfc_efx/base/efx_annote.h
diff --git a/drivers/net/sfc/base/efx_bootcfg.c b/drivers/common/sfc_efx/base/efx_bootcfg.c
similarity index 100%
rename from drivers/net/sfc/base/efx_bootcfg.c
rename to drivers/common/sfc_efx/base/efx_bootcfg.c
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/common/sfc_efx/base/efx_check.h
similarity index 100%
rename from drivers/net/sfc/base/efx_check.h
rename to drivers/common/sfc_efx/base/efx_check.h
diff --git a/drivers/net/sfc/base/efx_crc32.c b/drivers/common/sfc_efx/base/efx_crc32.c
similarity index 100%
rename from drivers/net/sfc/base/efx_crc32.c
rename to drivers/common/sfc_efx/base/efx_crc32.c
diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/common/sfc_efx/base/efx_ev.c
similarity index 100%
rename from drivers/net/sfc/base/efx_ev.c
rename to drivers/common/sfc_efx/base/efx_ev.c
diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/common/sfc_efx/base/efx_evb.c
similarity index 100%
rename from drivers/net/sfc/base/efx_evb.c
rename to drivers/common/sfc_efx/base/efx_evb.c
diff --git a/drivers/net/sfc/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
similarity index 100%
rename from drivers/net/sfc/base/efx_filter.c
rename to drivers/common/sfc_efx/base/efx_filter.c
diff --git a/drivers/net/sfc/base/efx_hash.c b/drivers/common/sfc_efx/base/efx_hash.c
similarity index 100%
rename from drivers/net/sfc/base/efx_hash.c
rename to drivers/common/sfc_efx/base/efx_hash.c
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
similarity index 100%
rename from drivers/net/sfc/base/efx_impl.h
rename to drivers/common/sfc_efx/base/efx_impl.h
diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/common/sfc_efx/base/efx_intr.c
similarity index 100%
rename from drivers/net/sfc/base/efx_intr.c
rename to drivers/common/sfc_efx/base/efx_intr.c
diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/common/sfc_efx/base/efx_lic.c
similarity index 100%
rename from drivers/net/sfc/base/efx_lic.c
rename to drivers/common/sfc_efx/base/efx_lic.c
diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mac.c
rename to drivers/common/sfc_efx/base/efx_mac.c
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mcdi.c
rename to drivers/common/sfc_efx/base/efx_mcdi.c
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/common/sfc_efx/base/efx_mcdi.h
similarity index 100%
rename from drivers/net/sfc/base/efx_mcdi.h
rename to drivers/common/sfc_efx/base/efx_mcdi.h
diff --git a/drivers/net/sfc/base/efx_mon.c b/drivers/common/sfc_efx/base/efx_mon.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mon.c
rename to drivers/common/sfc_efx/base/efx_mon.c
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/common/sfc_efx/base/efx_nic.c
similarity index 100%
rename from drivers/net/sfc/base/efx_nic.c
rename to drivers/common/sfc_efx/base/efx_nic.c
diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/common/sfc_efx/base/efx_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/efx_nvram.c
rename to drivers/common/sfc_efx/base/efx_nvram.c
diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/common/sfc_efx/base/efx_phy.c
similarity index 100%
rename from drivers/net/sfc/base/efx_phy.c
rename to drivers/common/sfc_efx/base/efx_phy.c
diff --git a/drivers/net/sfc/base/efx_phy_ids.h b/drivers/common/sfc_efx/base/efx_phy_ids.h
similarity index 100%
rename from drivers/net/sfc/base/efx_phy_ids.h
rename to drivers/common/sfc_efx/base/efx_phy_ids.h
diff --git a/drivers/net/sfc/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
similarity index 100%
rename from drivers/net/sfc/base/efx_port.c
rename to drivers/common/sfc_efx/base/efx_port.c
diff --git a/drivers/net/sfc/base/efx_proxy.c b/drivers/common/sfc_efx/base/efx_proxy.c
similarity index 100%
rename from drivers/net/sfc/base/efx_proxy.c
rename to drivers/common/sfc_efx/base/efx_proxy.c
diff --git a/drivers/net/sfc/base/efx_regs.h b/drivers/common/sfc_efx/base/efx_regs.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs.h
rename to drivers/common/sfc_efx/base/efx_regs.h
diff --git a/drivers/net/sfc/base/efx_regs_ef10.h b/drivers/common/sfc_efx/base/efx_regs_ef10.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_ef10.h
rename to drivers/common/sfc_efx/base/efx_regs_ef10.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi.h b/drivers/common/sfc_efx/base/efx_regs_mcdi.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi_aoe.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi_aoe.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi_strs.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi_strs.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h
diff --git a/drivers/net/sfc/base/efx_regs_pci.h b/drivers/common/sfc_efx/base/efx_regs_pci.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_pci.h
rename to drivers/common/sfc_efx/base/efx_regs_pci.h
diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
similarity index 100%
rename from drivers/net/sfc/base/efx_rx.c
rename to drivers/common/sfc_efx/base/efx_rx.c
diff --git a/drivers/net/sfc/base/efx_sram.c b/drivers/common/sfc_efx/base/efx_sram.c
similarity index 100%
rename from drivers/net/sfc/base/efx_sram.c
rename to drivers/common/sfc_efx/base/efx_sram.c
diff --git a/drivers/net/sfc/base/efx_tunnel.c b/drivers/common/sfc_efx/base/efx_tunnel.c
similarity index 100%
rename from drivers/net/sfc/base/efx_tunnel.c
rename to drivers/common/sfc_efx/base/efx_tunnel.c
diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/common/sfc_efx/base/efx_tx.c
similarity index 100%
rename from drivers/net/sfc/base/efx_tx.c
rename to drivers/common/sfc_efx/base/efx_tx.c
diff --git a/drivers/net/sfc/base/efx_types.h b/drivers/common/sfc_efx/base/efx_types.h
similarity index 100%
rename from drivers/net/sfc/base/efx_types.h
rename to drivers/common/sfc_efx/base/efx_types.h
diff --git a/drivers/net/sfc/base/efx_vpd.c b/drivers/common/sfc_efx/base/efx_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/efx_vpd.c
rename to drivers/common/sfc_efx/base/efx_vpd.c
diff --git a/drivers/net/sfc/base/hunt_impl.h b/drivers/common/sfc_efx/base/hunt_impl.h
similarity index 100%
rename from drivers/net/sfc/base/hunt_impl.h
rename to drivers/common/sfc_efx/base/hunt_impl.h
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/common/sfc_efx/base/hunt_nic.c
similarity index 100%
rename from drivers/net/sfc/base/hunt_nic.c
rename to drivers/common/sfc_efx/base/hunt_nic.c
diff --git a/drivers/net/sfc/base/mcdi_mon.c b/drivers/common/sfc_efx/base/mcdi_mon.c
similarity index 100%
rename from drivers/net/sfc/base/mcdi_mon.c
rename to drivers/common/sfc_efx/base/mcdi_mon.c
diff --git a/drivers/net/sfc/base/mcdi_mon.h b/drivers/common/sfc_efx/base/mcdi_mon.h
similarity index 100%
rename from drivers/net/sfc/base/mcdi_mon.h
rename to drivers/common/sfc_efx/base/mcdi_mon.h
diff --git a/drivers/net/sfc/base/medford2_impl.h b/drivers/common/sfc_efx/base/medford2_impl.h
similarity index 100%
rename from drivers/net/sfc/base/medford2_impl.h
rename to drivers/common/sfc_efx/base/medford2_impl.h
diff --git a/drivers/net/sfc/base/medford2_nic.c b/drivers/common/sfc_efx/base/medford2_nic.c
similarity index 100%
rename from drivers/net/sfc/base/medford2_nic.c
rename to drivers/common/sfc_efx/base/medford2_nic.c
diff --git a/drivers/net/sfc/base/medford_impl.h b/drivers/common/sfc_efx/base/medford_impl.h
similarity index 100%
rename from drivers/net/sfc/base/medford_impl.h
rename to drivers/common/sfc_efx/base/medford_impl.h
diff --git a/drivers/net/sfc/base/medford_nic.c b/drivers/common/sfc_efx/base/medford_nic.c
similarity index 100%
rename from drivers/net/sfc/base/medford_nic.c
rename to drivers/common/sfc_efx/base/medford_nic.c
diff --git a/drivers/net/sfc/base/meson.build b/drivers/common/sfc_efx/base/meson.build
similarity index 100%
rename from drivers/net/sfc/base/meson.build
rename to drivers/common/sfc_efx/base/meson.build
diff --git a/drivers/net/sfc/base/siena_flash.h b/drivers/common/sfc_efx/base/siena_flash.h
similarity index 100%
rename from drivers/net/sfc/base/siena_flash.h
rename to drivers/common/sfc_efx/base/siena_flash.h
diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/common/sfc_efx/base/siena_impl.h
similarity index 100%
rename from drivers/net/sfc/base/siena_impl.h
rename to drivers/common/sfc_efx/base/siena_impl.h
diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/common/sfc_efx/base/siena_mac.c
similarity index 100%
rename from drivers/net/sfc/base/siena_mac.c
rename to drivers/common/sfc_efx/base/siena_mac.c
diff --git a/drivers/net/sfc/base/siena_mcdi.c b/drivers/common/sfc_efx/base/siena_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/siena_mcdi.c
rename to drivers/common/sfc_efx/base/siena_mcdi.c
diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
similarity index 100%
rename from drivers/net/sfc/base/siena_nic.c
rename to drivers/common/sfc_efx/base/siena_nic.c
diff --git a/drivers/net/sfc/base/siena_nvram.c b/drivers/common/sfc_efx/base/siena_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/siena_nvram.c
rename to drivers/common/sfc_efx/base/siena_nvram.c
diff --git a/drivers/net/sfc/base/siena_phy.c b/drivers/common/sfc_efx/base/siena_phy.c
similarity index 100%
rename from drivers/net/sfc/base/siena_phy.c
rename to drivers/common/sfc_efx/base/siena_phy.c
diff --git a/drivers/net/sfc/base/siena_sram.c b/drivers/common/sfc_efx/base/siena_sram.c
similarity index 100%
rename from drivers/net/sfc/base/siena_sram.c
rename to drivers/common/sfc_efx/base/siena_sram.c
diff --git a/drivers/net/sfc/base/siena_vpd.c b/drivers/common/sfc_efx/base/siena_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/siena_vpd.c
rename to drivers/common/sfc_efx/base/siena_vpd.c
diff --git a/drivers/net/sfc/efsys.h b/drivers/common/sfc_efx/efsys.h
similarity index 93%
rename from drivers/net/sfc/efsys.h
rename to drivers/common/sfc_efx/efsys.h
index c94e6c0b93..657b45e05d 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/common/sfc_efx/efsys.h
@@ -25,8 +25,8 @@
 #include <rte_log.h>
 #include <rte_io.h>
 
-#include "sfc_debug.h"
-#include "sfc_log.h"
+#include "sfc_efx_debug.h"
+#include "sfc_efx_log.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -224,8 +224,8 @@ typedef struct efsys_mem_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		_addr = (volatile uint32_t *)(_base + (_offset));	\
 		(_edp)->ed_u32[0] = _addr[0];				\
@@ -242,8 +242,8 @@ typedef struct efsys_mem_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		_addr = (volatile uint64_t *)(_base + (_offset));	\
 		(_eqp)->eq_u64[0] = _addr[0];				\
@@ -261,8 +261,8 @@ typedef struct efsys_mem_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_addr = (volatile __m128i *)(_base + (_offset));	\
 		(_eop)->eo_u128[0] = _addr[0];				\
@@ -283,8 +283,8 @@ typedef struct efsys_mem_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		EFSYS_PROBE2(mem_writed, unsigned int, (_offset),	\
 					 uint32_t, (_edp)->ed_u32[0]);	\
@@ -301,8 +301,8 @@ typedef struct efsys_mem_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		EFSYS_PROBE3(mem_writeq, unsigned int, (_offset),	\
 					 uint32_t, (_eqp)->eq_u32[1],	\
@@ -320,8 +320,8 @@ typedef struct efsys_mem_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 									\
 		EFSYS_PROBE5(mem_writeo, unsigned int, (_offset),	\
@@ -386,8 +386,8 @@ typedef struct efsys_bar_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
 			SFC_BAR_LOCK(_esbp);				\
@@ -411,8 +411,8 @@ typedef struct efsys_bar_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		SFC_BAR_LOCK(_esbp);					\
 									\
@@ -434,8 +434,8 @@ typedef struct efsys_bar_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -465,8 +465,8 @@ typedef struct efsys_bar_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -491,8 +491,8 @@ typedef struct efsys_bar_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		SFC_BAR_LOCK(_esbp);					\
 									\
@@ -526,8 +526,8 @@ typedef struct efsys_bar_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -625,7 +625,7 @@ typedef rte_spinlock_t efsys_lock_t;
 #define SFC_EFSYS_UNLOCK(_eslp)				\
 	rte_spinlock_unlock((_eslp))
 #define SFC_EFSYS_LOCK_ASSERT_OWNED(_eslp)		\
-	SFC_ASSERT(rte_spinlock_is_locked((_eslp)))
+	SFC_EFX_ASSERT(rte_spinlock_is_locked((_eslp)))
 
 typedef int efsys_lock_state_t;
 
@@ -640,7 +640,7 @@ typedef int efsys_lock_state_t;
 
 #define EFSYS_UNLOCK(_lockp, _state)				\
 	do {							\
-		SFC_ASSERT((_state) == EFSYS_LOCK_MAGIC);	\
+		SFC_EFX_ASSERT((_state) == EFSYS_LOCK_MAGIC);	\
 		SFC_EFSYS_UNLOCK(_lockp);			\
 		_NOTE(CONSTANTCONDITION);			\
 	} while (B_FALSE)
@@ -697,7 +697,7 @@ typedef uint64_t	efsys_stat_t;
 #define EFSYS_ERR(_esip, _code, _dword0, _dword1)			\
 	do {								\
 		(void)(_esip);						\
-		SFC_GENERIC_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)",	\
+		SFC_EFX_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)",	\
 			(_code), (_dword0), (_dword1));			\
 		_NOTE(CONSTANTCONDITION);				\
 	} while (B_FALSE)
diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build
new file mode 100644
index 0000000000..8fab4df792
--- /dev/null
+++ b/drivers/common/sfc_efx/meson.build
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2019-2020 Xilinx, Inc.
+#
+# This software was jointly developed between OKTET Labs (under contract
+# for Solarflare) and Solarflare Communications, Inc.
+
+if arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64')
+	build = false
+	reason = 'only supported on x86_64'
+endif
+
+extra_flags = []
+
+# Enable more warnings
+extra_flags += [
+	'-Wdisabled-optimization'
+]
+
+# Compiler and version dependent flags
+extra_flags += [
+	'-Waggregate-return',
+	'-Wbad-function-cast'
+]
+
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+	'sfc_efx.c',
+)
+
+includes += include_directories('base')
diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
new file mode 100644
index 0000000000..0c719e8250
--- /dev/null
+++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
@@ -0,0 +1,122 @@
+DPDK_21 {
+	global:
+
+	efx_ev_fini;
+	efx_ev_init;
+	efx_ev_qcreate;
+	efx_ev_qdestroy;
+	efx_ev_qpoll;
+	efx_ev_qprime;
+
+	efx_evb_fini;
+	efx_evb_init;
+	efx_evb_vswitch_create;
+	efx_evb_vswitch_destroy;
+	efx_evq_size;
+
+	efx_family;
+
+	efx_filter_fini;
+	efx_filter_init;
+	efx_filter_insert;
+	efx_filter_remove;
+	efx_filter_supported_filters;
+
+	efx_intr_disable;
+	efx_intr_enable;
+	efx_intr_fatal;
+	efx_intr_fini;
+	efx_intr_init;
+	efx_intr_status_line;
+	efx_intr_status_message;
+
+	efx_mac_addr_set;
+	efx_mac_drain;
+	efx_mac_fcntl_get;
+	efx_mac_fcntl_set;
+	efx_mac_filter_default_rxq_clear;
+	efx_mac_filter_default_rxq_set;
+	efx_mac_filter_get_all_ucast_mcast;
+	efx_mac_filter_set;
+	efx_mac_multicast_list_set;
+	efx_mac_pdu_set;
+	efx_mac_stat_name;
+	efx_mac_stats_clear;
+	efx_mac_stats_get_mask;
+	efx_mac_stats_periodic;
+	efx_mac_stats_update;
+	efx_mac_stats_upload;
+
+	efx_mcdi_fini;
+	efx_mcdi_get_proxy_handle;
+	efx_mcdi_init;
+	efx_mcdi_new_epoch;
+	efx_mcdi_request_abort;
+	efx_mcdi_request_poll;
+	efx_mcdi_request_start;
+
+	efx_nic_cfg_get;
+	efx_nic_create;
+	efx_nic_destroy;
+	efx_nic_fini;
+	efx_nic_get_fw_subvariant;
+	efx_nic_get_fw_version;
+	efx_nic_get_vi_pool;
+	efx_nic_init;
+	efx_nic_probe;
+	efx_nic_reset;
+	efx_nic_set_drv_limits;
+	efx_nic_set_fw_subvariant;
+	efx_nic_unprobe;
+
+	efx_phy_adv_cap_get;
+	efx_phy_adv_cap_set;
+
+	efx_port_fini;
+	efx_port_init;
+	efx_port_loopback_set;
+	efx_port_poll;
+
+	efx_pseudo_hdr_hash_get;
+	efx_pseudo_hdr_pkt_length_get;
+
+	efx_rx_fini;
+	efx_rx_hash_default_support_get;
+	efx_rx_init;
+	efx_rx_qcreate;
+	efx_rx_qcreate_es_super_buffer;
+	efx_rx_qdestroy;
+	efx_rx_qenable;
+	efx_rx_qflush;
+	efx_rx_qpost;
+	efx_rx_qpush;
+	efx_rx_scale_context_alloc;
+	efx_rx_scale_context_free;
+	efx_rx_scale_default_support_get;
+	efx_rx_scale_hash_flags_get;
+	efx_rx_scale_key_set;
+	efx_rx_scale_mode_set;
+	efx_rx_scale_tbl_set;
+	efx_rxq_size;
+
+	efx_tunnel_config_udp_add;
+	efx_tunnel_config_udp_remove;
+	efx_tunnel_fini;
+	efx_tunnel_init;
+	efx_tunnel_reconfigure;
+
+	efx_tx_fini;
+	efx_tx_init;
+	efx_tx_qcreate;
+	efx_tx_qdesc_dma_create;
+	efx_tx_qdesc_post;
+	efx_tx_qdesc_tso2_create;
+	efx_tx_qdesc_vlantci_create;
+	efx_tx_qdestroy;
+	efx_tx_qenable;
+	efx_tx_qflush;
+	efx_tx_qpush;
+	efx_txq_size;
+
+	local: *;
+};
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
new file mode 100644
index 0000000000..0b8d5efee9
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#include <rte_log.h>
+
+#include "sfc_efx_log.h"
+
+uint32_t sfc_efx_logtype;
+
+RTE_INIT(sfc_efx_register_logtype)
+{
+	int ret;
+
+	ret = rte_log_register_type_and_pick_level("pmd.common.sfc_efx",
+						   RTE_LOG_NOTICE);
+	sfc_efx_logtype = (ret < 0) ? RTE_LOGTYPE_PMD : ret;
+}
diff --git a/drivers/common/sfc_efx/sfc_efx_debug.h b/drivers/common/sfc_efx/sfc_efx_debug.h
new file mode 100644
index 0000000000..e0bdeeb5a4
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_debug.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_EFX_DEBUG_H_
+#define _SFC_EFX_DEBUG_H_
+
+#include <rte_debug.h>
+
+#ifndef RTE_DEBUG_COMMON_SFC_EFX
+#define RTE_DEBUG_COMMON_SFC_EFX	0
+#endif
+
+#ifdef RTE_DEBUG_COMMON_SFC_EFX
+/* Avoid dependency from RTE_LOG_DP_LEVEL to be able to enable debug check
+ * in the driver only.
+ */
+#define SFC_EFX_ASSERT(exp)		RTE_VERIFY(exp)
+#else
+/* If the driver debug is not enabled, follow DPDK debug/non-debug */
+#define SFC_EFX_ASSERT(exp)		RTE_ASSERT(exp)
+#endif
+
+#endif /* _SFC_EFX_DEBUG_H_ */
diff --git a/drivers/common/sfc_efx/sfc_efx_log.h b/drivers/common/sfc_efx/sfc_efx_log.h
new file mode 100644
index 0000000000..f4417ffc30
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_log.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_EFX_LOG_H_
+#define _SFC_EFX_LOG_H_
+
+/** Generic driver log type */
+extern uint32_t sfc_efx_logtype;
+
+/** Log message, add a prefix and a line break */
+#define SFC_EFX_LOG(level, ...) \
+	rte_log(RTE_LOG_ ## level, sfc_efx_logtype,			\
+		RTE_FMT("sfc_efx: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+			RTE_FMT_TAIL(__VA_ARGS__ ,)))
+
+#endif /* _SFC_EFX_LOG_H_ */
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 20bf343814..648527f4b8 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -13,7 +13,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pmd_sfc_efx.a
 
-CFLAGS += -I$(SRCDIR)/base/
+CFLAGS += -I$(RTE_SDK)/drivers/common/sfc_efx/base
+CFLAGS += -I$(RTE_SDK)/drivers/common/sfc_efx
 CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
@@ -26,39 +27,23 @@ CFLAGS += -Wextra
 # More warnings not enabled by above aggregators
 CFLAGS += -Wdisabled-optimization
 
-# Extra CFLAGS for base driver files
-CFLAGS_BASE_DRIVER += -Wno-sign-compare
-CFLAGS_BASE_DRIVER += -Wno-unused-parameter
-CFLAGS_BASE_DRIVER += -Wno-unused-variable
-
 # Compiler and version dependent flags
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS += -Waggregate-return
 CFLAGS += -Wnested-externs
-CFLAGS_BASE_DRIVER += -Wno-empty-body
-CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
 else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
 CFLAGS += -Waggregate-return
 CFLAGS += -Wbad-function-cast
-CFLAGS_BASE_DRIVER += -Wno-empty-body
 else ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
-CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
 # Suppress ICC false positive warning on 'bulk' may be used before its
 # value is set
 CFLAGS_sfc_ef10_tx.o += -diag-disable 3656
 endif
+LDLIBS += -lrte_common_sfc_efx
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
 LDLIBS += -lrte_bus_pci -lrte_pci
 
-#
-# List of base driver object files for which
-# special CFLAGS above should be applied
-#
-BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c))))
-$(foreach obj, $(BASE_DRIVER_OBJS), \
-  $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
-
 EXPORT_MAP := rte_pmd_sfc_version.map
 
 #
@@ -81,53 +66,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_rx.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_essb_rx.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_tx.c
 
-VPATH += $(SRCDIR)/base
-
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_bootcfg.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_crc32.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_ev.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_evb.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_filter.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_hash.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_intr.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_lic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mac.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mcdi.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mon.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nvram.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_phy.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_port.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_proxy.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_rx.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_sram.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_tunnel.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_tx.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_vpd.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += mcdi_mon.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mac.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mcdi.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nvram.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_phy.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_sram.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_vpd.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_ev.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_evb.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_filter.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_intr.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_image.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mac.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mcdi.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nvram.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_phy.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_proxy.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_rx.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_tx.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_vpd.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += hunt_nic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford_nic.c
-SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford2_nic.c
-
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build
index 35c05ac1dd..26f0323738 100644
--- a/drivers/net/sfc/meson.build
+++ b/drivers/net/sfc/meson.build
@@ -33,9 +33,7 @@ foreach flag: extra_flags
 	endif
 endforeach
 
-subdir('base')
-objs = [base_objs]
-
+deps += ['common_sfc_efx']
 sources = files(
 	'sfc_ethdev.c',
 	'sfc_kvargs.c',
@@ -54,5 +52,3 @@ sources = files(
 	'sfc_ef10_essb_rx.c',
 	'sfc_ef10_tx.c'
 )
-
-includes += include_directories('base')
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index a544259970..d3c165f720 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -234,6 +234,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_common_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFB_PMD)        += -lrte_pmd_nfb
 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFB_PMD)        +=  $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --libs netcope-common)
-- 
2.17.1



^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (2 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

MCDI helpers will be shared by net and vDPA drivers.
Prepare to move it to common/sfc_efx.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h      | 23 +---------------
 drivers/net/sfc/sfc_mcdi.c |  1 +
 drivers/net/sfc/sfc_mcdi.h | 54 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/sfc/sfc_mcdi.h

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index cdff9be3ec..a530b12a8e 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -23,6 +23,7 @@
 
 #include "sfc_debug.h"
 #include "sfc_filter.h"
+#include "sfc_mcdi.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -86,25 +87,6 @@ enum sfc_dev_filter_mode {
 	SFC_DEV_FILTER_NMODES
 };
 
-enum sfc_mcdi_state {
-	SFC_MCDI_UNINITIALIZED = 0,
-	SFC_MCDI_INITIALIZED,
-	SFC_MCDI_BUSY,
-	SFC_MCDI_COMPLETED,
-
-	SFC_MCDI_NSTATES
-};
-
-struct sfc_mcdi {
-	rte_spinlock_t			lock;
-	efsys_mem_t			mem;
-	enum sfc_mcdi_state		state;
-	efx_mcdi_transport_t		transport;
-	uint32_t			logtype;
-	uint32_t			proxy_handle;
-	efx_rc_t			proxy_result;
-};
-
 struct sfc_intr {
 	efx_intr_type_t			type;
 	rte_intr_callback_fn		handler;
@@ -384,9 +366,6 @@ void sfc_stop(struct sfc_adapter *sa);
 
 void sfc_schedule_restart(struct sfc_adapter *sa);
 
-int sfc_mcdi_init(struct sfc_adapter *sa);
-void sfc_mcdi_fini(struct sfc_adapter *sa);
-
 int sfc_configure(struct sfc_adapter *sa);
 void sfc_close(struct sfc_adapter *sa);
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index ec62ba95ff..9a51b3e030 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -13,6 +13,7 @@
 #include "efx_mcdi.h"
 #include "efx_regs_mcdi.h"
 
+#include "sfc_mcdi.h"
 #include "sfc.h"
 #include "sfc_debug.h"
 #include "sfc_log.h"
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
new file mode 100644
index 0000000000..789a16d8bb
--- /dev/null
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2016-2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_MCDI_H
+#define _SFC_MCDI_H
+
+#include <stdint.h>
+
+#include <rte_spinlock.h>
+
+#include "efsys.h"
+#include "efx.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum sfc_mcdi_state {
+	SFC_MCDI_UNINITIALIZED = 0,
+	SFC_MCDI_INITIALIZED,
+	SFC_MCDI_BUSY,
+	SFC_MCDI_COMPLETED,
+
+	SFC_MCDI_NSTATES
+};
+
+struct sfc_mcdi {
+	rte_spinlock_t			lock;
+	efsys_mem_t			mem;
+	enum sfc_mcdi_state		state;
+	efx_mcdi_transport_t		transport;
+	uint32_t			logtype;
+	uint32_t			proxy_handle;
+	efx_rc_t			proxy_result;
+};
+
+
+struct sfc_adapter;
+
+int sfc_mcdi_init(struct sfc_adapter *sa);
+void sfc_mcdi_fini(struct sfc_adapter *sa);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _SFC_MCDI_H */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (3 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

MCDI helpers will be moved to common/sfc_efx and it is better
to do dummy renamings first before non-trivial changes.

Existing functionality should be split into common and network
driver specific parts. Prepare to do it.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h      |   5 +-
 drivers/net/sfc/sfc_mcdi.c | 108 +++++++++++++++++++++----------------
 drivers/net/sfc/sfc_mcdi.h |  22 +++-----
 3 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index a530b12a8e..b3ac752334 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -220,7 +220,7 @@ struct sfc_adapter {
 	rte_spinlock_t			nic_lock;
 	rte_atomic32_t			restart_required;
 
-	struct sfc_mcdi			mcdi;
+	struct sfc_efx_mcdi		mcdi;
 	struct sfc_intr			intr;
 	struct sfc_port			port;
 	struct sfc_filter		filter;
@@ -366,6 +366,9 @@ void sfc_stop(struct sfc_adapter *sa);
 
 void sfc_schedule_restart(struct sfc_adapter *sa);
 
+int sfc_mcdi_init(struct sfc_adapter *sa);
+void sfc_mcdi_fini(struct sfc_adapter *sa);
+
 int sfc_configure(struct sfc_adapter *sa);
 void sfc_close(struct sfc_adapter *sa);
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 9a51b3e030..c97a33d558 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -19,12 +19,12 @@
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
-#define SFC_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us in 1us units */
-#define SFC_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms in 1us units */
-#define SFC_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s in 1us units */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
+#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
 static void
-sfc_mcdi_timeout(struct sfc_adapter *sa)
+sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
 	sfc_warn(sa, "MC TIMEOUT");
 
@@ -32,9 +32,9 @@ sfc_mcdi_timeout(struct sfc_adapter *sa)
 }
 
 static inline boolean_t
-sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
+sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
@@ -46,7 +46,7 @@ sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
 }
 
 static void
-sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
+sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 {
 	efx_nic_t *enp;
 	unsigned int delay_total;
@@ -54,22 +54,22 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 	boolean_t aborted __rte_unused;
 
 	delay_total = 0;
-	delay_us = SFC_MCDI_POLL_INTERVAL_MIN_US;
+	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
 	enp = sa->nic;
 
 	do {
 		boolean_t poll_completed;
 
-		poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
+		poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) :
 					   efx_mcdi_request_poll(enp);
 		if (poll_completed)
 			return;
 
-		if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
+		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
 			if (!proxy) {
 				aborted = efx_mcdi_request_abort(enp);
 				SFC_ASSERT(aborted);
-				sfc_mcdi_timeout(sa);
+				sfc_efx_mcdi_timeout(sa);
 			}
 
 			return;
@@ -80,27 +80,28 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 		delay_total += delay_us;
 
 		/* Exponentially back off the poll frequency */
-		RTE_BUILD_BUG_ON(SFC_MCDI_POLL_INTERVAL_MAX_US > UINT_MAX / 2);
+		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
+				 UINT_MAX / 2);
 		delay_us *= 2;
-		if (delay_us > SFC_MCDI_POLL_INTERVAL_MAX_US)
-			delay_us = SFC_MCDI_POLL_INTERVAL_MAX_US;
+		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
+			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
 
 	} while (1);
 }
 
 static void
-sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
+sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	uint32_t proxy_handle;
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
-	sfc_mcdi_poll(sa, B_FALSE);
+	sfc_efx_mcdi_poll(sa, B_FALSE);
 
 	if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
 		/*
@@ -109,7 +110,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 		 * a non-zero proxy handle (should be the same as
 		 * the value obtained above) and operation status
 		 */
-		sfc_mcdi_poll(sa, B_TRUE);
+		sfc_efx_mcdi_poll(sa, B_TRUE);
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
@@ -121,7 +122,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * request and poll for an ordinary MCDI response
 			 */
 			efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
-			sfc_mcdi_poll(sa, B_FALSE);
+			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
 			sfc_err(sa, "MCDI proxy authorization failed "
@@ -134,20 +135,20 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 }
 
 static void
-sfc_mcdi_ev_cpl(void *arg)
+sfc_efx_mcdi_ev_cpl(void *arg)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi __rte_unused;
+	struct sfc_efx_mcdi *mcdi __rte_unused;
 
 	mcdi = &sa->mcdi;
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	/* MCDI is polled, completions are not expected */
 	SFC_ASSERT(0);
 }
 
 static void
-sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
+sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
 
@@ -161,7 +162,7 @@ sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 #define SFC_MCDI_LOG_BUF_SIZE	128
 
 static size_t
-sfc_mcdi_do_log(const struct sfc_adapter *sa,
+sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 		char *buffer, void *data, size_t data_size,
 		size_t pfxsize, size_t position)
 {
@@ -190,7 +191,7 @@ sfc_mcdi_do_log(const struct sfc_adapter *sa,
 }
 
 static void
-sfc_mcdi_logger(void *arg, efx_log_msg_t type,
+sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *header, size_t header_size,
 		void *data, size_t data_size)
 {
@@ -215,9 +216,10 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
 			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_mcdi_do_log(sa, buffer, header, header_size,
-				pfxsize, pfxsize);
-	start = sfc_mcdi_do_log(sa, buffer, data, data_size, pfxsize, start);
+	start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size,
+				    pfxsize, pfxsize);
+	start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size,
+				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
 		sfc_log_mcdi(sa, "%s", buffer);
@@ -225,19 +227,19 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
 }
 
 static void
-sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 
 	mcdi->proxy_handle = handle;
 	mcdi->proxy_result = result;
 }
 
-int
-sfc_mcdi_init(struct sfc_adapter *sa)
+static int
+sfc_efx_mcdi_init(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi;
+	struct sfc_efx_mcdi *mcdi;
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
@@ -246,11 +248,11 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 
 	mcdi = &sa->mcdi;
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_UNINITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
-	mcdi->state = SFC_MCDI_INITIALIZED;
+	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
 	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
@@ -265,11 +267,11 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 	emtp = &mcdi->transport;
 	emtp->emt_context = sa;
 	emtp->emt_dma_mem = &mcdi->mem;
-	emtp->emt_execute = sfc_mcdi_execute;
-	emtp->emt_ev_cpl = sfc_mcdi_ev_cpl;
-	emtp->emt_exception = sfc_mcdi_exception;
-	emtp->emt_logger = sfc_mcdi_logger;
-	emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response;
+	emtp->emt_execute = sfc_efx_mcdi_execute;
+	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
+	emtp->emt_exception = sfc_efx_mcdi_exception;
+	emtp->emt_logger = sfc_efx_mcdi_logger;
+	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
 	sfc_log_init(sa, "init MCDI");
 	rc = efx_mcdi_init(sa->nic, emtp);
@@ -283,14 +285,14 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 	sfc_dma_free(sa, &mcdi->mem);
 
 fail_dma_alloc:
-	mcdi->state = SFC_MCDI_UNINITIALIZED;
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 	return rc;
 }
 
-void
-sfc_mcdi_fini(struct sfc_adapter *sa)
+static void
+sfc_efx_mcdi_fini(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi;
+	struct sfc_efx_mcdi *mcdi;
 	efx_mcdi_transport_t *emtp;
 
 	sfc_log_init(sa, "entry");
@@ -300,8 +302,8 @@ sfc_mcdi_fini(struct sfc_adapter *sa)
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
-	mcdi->state = SFC_MCDI_UNINITIALIZED;
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_log_init(sa, "fini MCDI");
 	efx_mcdi_fini(sa->nic);
@@ -311,3 +313,15 @@ sfc_mcdi_fini(struct sfc_adapter *sa)
 
 	sfc_dma_free(sa, &mcdi->mem);
 }
+
+int
+sfc_mcdi_init(struct sfc_adapter *sa)
+{
+	return sfc_efx_mcdi_init(sa);
+}
+
+void
+sfc_mcdi_fini(struct sfc_adapter *sa)
+{
+	sfc_efx_mcdi_fini(sa);
+}
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 789a16d8bb..10f5bab666 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -22,31 +22,25 @@
 extern "C" {
 #endif
 
-enum sfc_mcdi_state {
-	SFC_MCDI_UNINITIALIZED = 0,
-	SFC_MCDI_INITIALIZED,
-	SFC_MCDI_BUSY,
-	SFC_MCDI_COMPLETED,
+enum sfc_efx_mcdi_state {
+	SFC_EFX_MCDI_UNINITIALIZED = 0,
+	SFC_EFX_MCDI_INITIALIZED,
+	SFC_EFX_MCDI_BUSY,
+	SFC_EFX_MCDI_COMPLETED,
 
-	SFC_MCDI_NSTATES
+	SFC_EFX_MCDI_NSTATES
 };
 
-struct sfc_mcdi {
+struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
 	efsys_mem_t			mem;
-	enum sfc_mcdi_state		state;
+	enum sfc_efx_mcdi_state		state;
 	efx_mcdi_transport_t		transport;
 	uint32_t			logtype;
 	uint32_t			proxy_handle;
 	efx_rc_t			proxy_result;
 };
 
-
-struct sfc_adapter;
-
-int sfc_mcdi_init(struct sfc_adapter *sa);
-void sfc_mcdi_fini(struct sfc_adapter *sa);
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (4 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Prepare to move MCDI helpers to drivers/common.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_log.h  | 11 -----------
 drivers/net/sfc/sfc_mcdi.c | 21 ++++++++++++++++-----
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
index 5383091c76..4bf44b1f15 100644
--- a/drivers/net/sfc/sfc_log.h
+++ b/drivers/net/sfc/sfc_log.h
@@ -28,9 +28,6 @@ extern uint32_t sfc_logtype_driver;
 /** Device MCDI log type name prefix */
 #define SFC_LOGTYPE_MCDI_STR	SFC_LOGTYPE_PREFIX "mcdi"
 
-/** Level value used by MCDI log statements */
-#define SFC_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
 /* Log PMD message, automatically add prefix and \n */
 #define SFC_LOG(sas, level, type, ...) \
 	do {								\
@@ -92,13 +89,5 @@ extern uint32_t sfc_logtype_driver;
 				RTE_FMT_TAIL(__VA_ARGS__ ,)));		\
 	} while (0)
 
-#define sfc_log_mcdi(sa, ...) \
-	do {								\
-		const struct sfc_adapter *_sa = (sa);			\
-									\
-		SFC_LOG(_sa->priv.shared, SFC_LOG_LEVEL_MCDI,		\
-			_sa->mcdi.logtype, __VA_ARGS__);		\
-	} while (0)
-
 
 #endif /* _SFC_LOG_H_ */
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index c97a33d558..c716caabdf 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -23,6 +23,17 @@
 #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
 #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(sa, ...) \
+	do {								\
+		const struct sfc_adapter *_sa = (sa);			\
+									\
+		SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI,	\
+			_sa->mcdi.logtype, __VA_ARGS__);		\
+	} while (0)
+
 static void
 sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
@@ -178,7 +189,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 			 * at the end which is required by netlogdecode.
 			 */
 			buffer[position] = '\0';
-			sfc_log_mcdi(sa, "%s \\", buffer);
+			sfc_efx_log_mcdi(sa, "%s \\", buffer);
 			/* Preserve prefix for the next log message */
 			position = pfxsize;
 		}
@@ -207,11 +218,11 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	 *
 	 * To avoid wasting time, the actual level is examined in advance.
 	 */
-	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_LOG_LEVEL_MCDI)
+	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
 		return;
 
-	/* The format including prefix added by sfc_log_mcdi() is the format
-	 * consumed by the Solarflare netlogdecode tool.
+	/* The format including prefix added by sfc_efx_log_mcdi() is the
+	 * format consumed by the Solarflare netlogdecode tool.
 	 */
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
@@ -222,7 +233,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
-		sfc_log_mcdi(sa, "%s", buffer);
+		sfc_efx_log_mcdi(sa, "%s", buffer);
 	}
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (5 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros Andrew Rybchenko
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

sfc_adapter is network driver specific structure which finally
should not be used in shared MCDI helpers interface.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index c716caabdf..35e1f3940d 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -248,17 +248,14 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa)
+sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi;
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
 	sfc_log_init(sa, "entry");
 
-	mcdi = &sa->mcdi;
-
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
@@ -301,14 +298,12 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa)
 }
 
 static void
-sfc_efx_mcdi_fini(struct sfc_adapter *sa)
+sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi;
 	efx_mcdi_transport_t *emtp;
 
 	sfc_log_init(sa, "entry");
 
-	mcdi = &sa->mcdi;
 	emtp = &mcdi->transport;
 
 	rte_spinlock_lock(&mcdi->lock);
@@ -328,11 +323,11 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa)
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
-	return sfc_efx_mcdi_init(sa);
+	return sfc_efx_mcdi_init(sa, &sa->mcdi);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
-	sfc_efx_mcdi_fini(sa);
+	sfc_efx_mcdi_fini(sa, &sa->mcdi);
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (6 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Network driver logging macros depends on sfc_adapter which is
specific to the driver and cannot be used in common code.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h        |  2 +
 drivers/net/sfc/sfc_ethdev.c | 13 ++++++
 drivers/net/sfc/sfc_log.h    | 12 ++---
 drivers/net/sfc/sfc_mcdi.c   | 86 +++++++++++++++++++++++-------------
 drivers/net/sfc/sfc_mcdi.h   |  1 +
 5 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index b3ac752334..b20fecb4f8 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -22,6 +22,7 @@
 #include "efx.h"
 
 #include "sfc_debug.h"
+#include "sfc_log.h"
 #include "sfc_filter.h"
 #include "sfc_mcdi.h"
 
@@ -170,6 +171,7 @@ struct sfc_adapter_shared {
 	boolean_t			isolated;
 	uint32_t			tunnel_encaps;
 
+	char				log_prefix[SFC_LOG_PREFIX_MAX];
 	struct rte_pci_addr		pci_addr;
 	uint16_t			port_id;
 
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index acee3e48e4..085f020a4c 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2136,6 +2136,7 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 	int rc;
 	const efx_nic_cfg_t *encp;
 	const struct rte_ether_addr *from;
+	int ret;
 
 	sfc_register_dp();
 
@@ -2147,6 +2148,18 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 		return -sfc_eth_dev_secondary_init(dev, logtype_main);
 
 	/* Required for logging */
+	ret = snprintf(sas->log_prefix, sizeof(sas->log_prefix),
+			"PMD: sfc_efx " PCI_PRI_FMT " #%" PRIu16 ": ",
+			pci_dev->addr.domain, pci_dev->addr.bus,
+			pci_dev->addr.devid, pci_dev->addr.function,
+			dev->data->port_id);
+	if (ret < 0 || ret >= (int)sizeof(sas->log_prefix)) {
+		SFC_GENERIC_LOG(ERR,
+			"reserved log prefix is too short for " PCI_PRI_FMT,
+			pci_dev->addr.domain, pci_dev->addr.bus,
+			pci_dev->addr.devid, pci_dev->addr.function);
+		return -EINVAL;
+	}
 	sas->pci_addr = pci_dev->addr;
 	sas->port_id = dev->data->port_id;
 
diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
index 4bf44b1f15..a2d714afb7 100644
--- a/drivers/net/sfc/sfc_log.h
+++ b/drivers/net/sfc/sfc_log.h
@@ -28,20 +28,16 @@ extern uint32_t sfc_logtype_driver;
 /** Device MCDI log type name prefix */
 #define SFC_LOGTYPE_MCDI_STR	SFC_LOGTYPE_PREFIX "mcdi"
 
+#define SFC_LOG_PREFIX_MAX	32
+
 /* Log PMD message, automatically add prefix and \n */
 #define SFC_LOG(sas, level, type, ...) \
 	do {								\
 		const struct sfc_adapter_shared *_sas = (sas);		\
 									\
 		rte_log(level, type,					\
-			RTE_FMT("PMD: sfc_efx "				\
-				PCI_PRI_FMT " #%" PRIu16		\
-				": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
-				_sas->pci_addr.domain,			\
-				_sas->pci_addr.bus,			\
-				_sas->pci_addr.devid,			\
-				_sas->pci_addr.function,		\
-				_sas->port_id,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_sas->log_prefix,			\
 				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 35e1f3940d..5f6ad0a4aa 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -23,21 +23,37 @@
 #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
 #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
-/** Level value used by MCDI log statements */
-#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
-#define sfc_efx_log_mcdi(sa, ...) \
+#define sfc_efx_mcdi_log(mcdi, level, ...) \
 	do {								\
-		const struct sfc_adapter *_sa = (sa);			\
+		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
 									\
-		SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI,	\
-			_sa->mcdi.logtype, __VA_ARGS__);		\
+		rte_log(level, _mcdi->logtype,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_mcdi->log_prefix,			\
+				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
+#define sfc_efx_mcdi_err(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
+
+#define sfc_efx_mcdi_warn(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
+
+#define sfc_efx_mcdi_info(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
+
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
+
 static void
 sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
-	sfc_warn(sa, "MC TIMEOUT");
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+
+	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
 	sfc_panic(sa, "MCDI timeout handling is not implemented\n");
 }
@@ -125,7 +141,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
-			sfc_err(sa, "Unexpected MCDI proxy event");
+			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
 			emrp->emr_rc = EFAULT;
 		} else if (mcdi->proxy_result == 0) {
 			/*
@@ -136,9 +152,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
-			sfc_err(sa, "MCDI proxy authorization failed "
-				    "(handle=%08x, result=%d)",
-				    proxy_handle, mcdi->proxy_result);
+			sfc_efx_mcdi_err(mcdi,
+				"MCDI proxy authorization failed (handle=%08x, result=%d)",
+				proxy_handle, mcdi->proxy_result);
 		}
 	}
 
@@ -162,8 +178,9 @@ static void
 sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+	struct sfc_efx_mcdi *mcdi  = &sa->mcdi;
 
-	sfc_warn(sa, "MC %s",
+	sfc_efx_mcdi_warn(mcdi, "MC %s",
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
 	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
 
@@ -173,7 +190,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 #define SFC_MCDI_LOG_BUF_SIZE	128
 
 static size_t
-sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
+sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
 		char *buffer, void *data, size_t data_size,
 		size_t pfxsize, size_t position)
 {
@@ -189,7 +206,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 			 * at the end which is required by netlogdecode.
 			 */
 			buffer[position] = '\0';
-			sfc_efx_log_mcdi(sa, "%s \\", buffer);
+			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
 			/* Preserve prefix for the next log message */
 			position = pfxsize;
 		}
@@ -207,6 +224,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *data, size_t data_size)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	char buffer[SFC_MCDI_LOG_BUF_SIZE];
 	size_t pfxsize;
 	size_t start;
@@ -218,7 +236,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	 *
 	 * To avoid wasting time, the actual level is examined in advance.
 	 */
-	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
+	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
 		return;
 
 	/* The format including prefix added by sfc_efx_log_mcdi() is the
@@ -227,13 +245,13 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
 			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size,
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
 				    pfxsize, pfxsize);
-	start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size,
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
 				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
-		sfc_efx_log_mcdi(sa, "%s", buffer);
+		sfc_efx_log_mcdi(mcdi, "%s", buffer);
 	}
 }
 
@@ -248,30 +266,28 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
+sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
+		  uint32_t logtype, const char *log_prefix)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
-	sfc_log_init(sa, "entry");
-
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
+	mcdi->logtype = logtype;
+	mcdi->log_prefix = log_prefix;
+
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
 	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
 			   &mcdi->mem);
 	if (rc != 0)
 		goto fail_dma_alloc;
 
-	mcdi->logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
-					     SFC_LOGTYPE_MCDI_STR,
-					     RTE_LOG_NOTICE);
-
 	emtp = &mcdi->transport;
 	emtp->emt_context = sa;
 	emtp->emt_dma_mem = &mcdi->mem;
@@ -281,7 +297,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	emtp->emt_logger = sfc_efx_mcdi_logger;
 	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
-	sfc_log_init(sa, "init MCDI");
+	sfc_efx_mcdi_info(mcdi, "init MCDI");
 	rc = efx_mcdi_init(sa->nic, emtp);
 	if (rc != 0)
 		goto fail_mcdi_init;
@@ -302,8 +318,6 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
 	efx_mcdi_transport_t *emtp;
 
-	sfc_log_init(sa, "entry");
-
 	emtp = &mcdi->transport;
 
 	rte_spinlock_lock(&mcdi->lock);
@@ -311,7 +325,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
-	sfc_log_init(sa, "fini MCDI");
+	sfc_efx_mcdi_info(mcdi, "fini MCDI");
 	efx_mcdi_fini(sa->nic);
 	memset(emtp, 0, sizeof(*emtp));
 
@@ -323,11 +337,21 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
-	return sfc_efx_mcdi_init(sa, &sa->mcdi);
+	uint32_t logtype;
+
+	sfc_log_init(sa, "entry");
+
+	logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
+				       SFC_LOGTYPE_MCDI_STR,
+				       RTE_LOG_NOTICE);
+
+	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
+				 sa->priv.shared->log_prefix);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
+	sfc_log_init(sa, "entry");
 	sfc_efx_mcdi_fini(sa, &sa->mcdi);
 }
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 10f5bab666..0194825bfa 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -39,6 +39,7 @@ struct sfc_efx_mcdi {
 	uint32_t			logtype;
 	uint32_t			proxy_handle;
 	efx_rc_t			proxy_result;
+	const char			*log_prefix;
 };
 
 #ifdef __cplusplus
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (7 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Prepare to avoid usage of the adapter context in common MCDI helpers.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 19 +++++++++++--------
 drivers/net/sfc/sfc_mcdi.h |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 5f6ad0a4aa..8f446e8bc8 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -75,6 +75,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 static void
 sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 {
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	efx_nic_t *enp;
 	unsigned int delay_total;
 	unsigned int delay_us;
@@ -82,7 +83,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 
 	delay_total = 0;
 	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
-	enp = sa->nic;
+	enp = mcdi->nic;
 
 	do {
 		boolean_t poll_completed;
@@ -127,10 +128,10 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
-	efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
 	sfc_efx_mcdi_poll(sa, B_FALSE);
 
-	if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
+	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
 		/*
 		 * Authorization is required for the MCDI request;
 		 * wait for an MCDI proxy response event to bring
@@ -148,7 +149,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * Authorization succeeded; re-issue the original
 			 * request and poll for an ordinary MCDI response
 			 */
-			efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
 			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
@@ -267,7 +268,7 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 
 static int
 sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix)
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
@@ -277,6 +278,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 
 	rte_spinlock_init(&mcdi->lock);
 
+	mcdi->nic = nic;
+
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
 	mcdi->logtype = logtype;
@@ -298,7 +301,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
 	sfc_efx_mcdi_info(mcdi, "init MCDI");
-	rc = efx_mcdi_init(sa->nic, emtp);
+	rc = efx_mcdi_init(mcdi->nic, emtp);
 	if (rc != 0)
 		goto fail_mcdi_init;
 
@@ -326,7 +329,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_efx_mcdi_info(mcdi, "fini MCDI");
-	efx_mcdi_fini(sa->nic);
+	efx_mcdi_fini(mcdi->nic);
 	memset(emtp, 0, sizeof(*emtp));
 
 	rte_spinlock_unlock(&mcdi->lock);
@@ -346,7 +349,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       RTE_LOG_NOTICE);
 
 	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
-				 sa->priv.shared->log_prefix);
+				 sa->priv.shared->log_prefix, sa->nic);
 }
 
 void
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 0194825bfa..e2105364ad 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -33,6 +33,7 @@ enum sfc_efx_mcdi_state {
 
 struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
+	efx_nic_t			*nic;
 	efsys_mem_t			mem;
 	enum sfc_efx_mcdi_state		state;
 	efx_mcdi_transport_t		transport;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (8 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Implement dummy MCDI timeout handling which simply rejects
further MCDI requests.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 8f446e8bc8..928a08c0a2 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -33,6 +33,9 @@
 				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
+#define sfc_efx_mcdi_crit(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
+
 #define sfc_efx_mcdi_err(mcdi, ...) \
 	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
 
@@ -55,7 +58,9 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
-	sfc_panic(sa, "MCDI timeout handling is not implemented\n");
+	mcdi->state = SFC_EFX_MCDI_DEAD;
+	sfc_efx_mcdi_crit(mcdi,
+		"MCDI timeout handling is not implemented - NIC is unusable");
 }
 
 static inline boolean_t
@@ -124,6 +129,11 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	uint32_t proxy_handle;
 
+	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
+		emrp->emr_rc = ENOEXEC;
+		return;
+	}
+
 	rte_spinlock_lock(&mcdi->lock);
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
@@ -325,7 +335,8 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
+		   mcdi->state == SFC_EFX_MCDI_DEAD);
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_efx_mcdi_info(mcdi, "fini MCDI");
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index e2105364ad..b93b268e32 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -27,6 +27,7 @@ enum sfc_efx_mcdi_state {
 	SFC_EFX_MCDI_INITIALIZED,
 	SFC_EFX_MCDI_BUSY,
 	SFC_EFX_MCDI_COMPLETED,
+	SFC_EFX_MCDI_DEAD,
 
 	SFC_EFX_MCDI_NSTATES
 };
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (9 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Net driver should use rte_eth_dma_zone_reserve(), but it is ethdev
specific API which is not available for vDPA.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 46 +++++++++++++++++++++++++++++++-------
 drivers/net/sfc/sfc_mcdi.h | 12 ++++++++++
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 928a08c0a2..5077fcddd6 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -278,16 +278,22 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 
 static int
 sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic)
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
+		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL)
+		return EINVAL;
+
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
+	mcdi->ops = ops;
+	mcdi->ops_cookie = ops_cookie;
 	mcdi->nic = nic;
 
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
@@ -296,8 +302,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	mcdi->log_prefix = log_prefix;
 
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
-	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
-			   &mcdi->mem);
+	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
 	if (rc != 0)
 		goto fail_dma_alloc;
 
@@ -319,7 +324,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 
 fail_mcdi_init:
 	memset(emtp, 0, sizeof(*emtp));
-	sfc_dma_free(sa, &mcdi->mem);
+	ops->dma_free(ops_cookie, &mcdi->mem);
 
 fail_dma_alloc:
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
@@ -327,7 +332,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 }
 
 static void
-sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
+sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
 {
 	efx_mcdi_transport_t *emtp;
 
@@ -345,9 +350,33 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 
 	rte_spinlock_unlock(&mcdi->lock);
 
-	sfc_dma_free(sa, &mcdi->mem);
+	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
+}
+
+static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
+static int
+sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
+		   efsys_mem_t *esmp)
+{
+	const struct sfc_adapter *sa = cookie;
+
+	return sfc_dma_alloc(sa, name, 0, len, sa->socket_id, esmp);
 }
 
+static sfc_efx_mcdi_dma_free_cb sfc_mcdi_dma_free;
+static void
+sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
+{
+	const struct sfc_adapter *sa = cookie;
+
+	sfc_dma_free(sa, esmp);
+}
+
+static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
+	.dma_alloc	= sfc_mcdi_dma_alloc,
+	.dma_free	= sfc_mcdi_dma_free,
+};
+
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
@@ -360,12 +389,13 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       RTE_LOG_NOTICE);
 
 	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
-				 sa->priv.shared->log_prefix, sa->nic);
+				 sa->priv.shared->log_prefix, sa->nic,
+				 &sfc_mcdi_ops, sa);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
 	sfc_log_init(sa, "entry");
-	sfc_efx_mcdi_fini(sa, &sa->mcdi);
+	sfc_efx_mcdi_fini(&sa->mcdi);
 }
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index b93b268e32..ef24a8bc67 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -32,8 +32,20 @@ enum sfc_efx_mcdi_state {
 	SFC_EFX_MCDI_NSTATES
 };
 
+typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name,
+					  size_t len, efsys_mem_t *esmp);
+
+typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
+
+struct sfc_efx_mcdi_ops {
+	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
+	sfc_efx_mcdi_dma_free_cb	*dma_free;
+};
+
 struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
+	const struct sfc_efx_mcdi_ops	*ops;
+	void				*ops_cookie;
 	efx_nic_t			*nic;
 	efsys_mem_t			mem;
 	enum sfc_efx_mcdi_state		state;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (10 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

MC reboot handling is driver specific.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  3 +++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 5077fcddd6..73dbd8194b 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -195,7 +195,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
 	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
 
-	sfc_schedule_restart(sa);
+	mcdi->ops->sched_restart(mcdi->ops_cookie);
 }
 
 #define SFC_MCDI_LOG_BUF_SIZE	128
@@ -285,7 +285,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
-	if (ops->dma_alloc == NULL || ops->dma_free == NULL)
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
+	    ops->sched_restart == NULL)
 		return EINVAL;
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
@@ -372,9 +373,19 @@ sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
 	sfc_dma_free(sa, esmp);
 }
 
+static sfc_efx_mcdi_sched_restart_cb sfc_mcdi_sched_restart;
+static void
+sfc_mcdi_sched_restart(void *cookie)
+{
+	struct sfc_adapter *sa = cookie;
+
+	sfc_schedule_restart(sa);
+}
+
 static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
 	.dma_alloc	= sfc_mcdi_dma_alloc,
 	.dma_free	= sfc_mcdi_dma_free,
+	.sched_restart	= sfc_mcdi_sched_restart,
 };
 
 int
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index ef24a8bc67..8f9b1991be 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -37,9 +37,12 @@ typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name,
 
 typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
 
+typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie);
+
 struct sfc_efx_mcdi_ops {
 	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
 	sfc_efx_mcdi_dma_free_cb	*dma_free;
+	sfc_efx_mcdi_sched_restart_cb	*sched_restart;
 };
 
 struct sfc_efx_mcdi {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (11 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Management event queue polling is required in the case of
MCDI proxy authentication (client driver code).

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 14 ++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 73dbd8194b..fa9160f6d3 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -70,7 +70,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
-	sfc_ev_mgmt_qpoll(sa);
+	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
 	if (mcdi->proxy_result != ETIMEDOUT)
 		return B_TRUE;
 
@@ -286,7 +286,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	int rc;
 
 	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
-	    ops->sched_restart == NULL)
+	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
 		return EINVAL;
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
@@ -382,10 +382,20 @@ sfc_mcdi_sched_restart(void *cookie)
 	sfc_schedule_restart(sa);
 }
 
+static sfc_efx_mcdi_mgmt_evq_poll_cb sfc_mcdi_mgmt_evq_poll;
+static void
+sfc_mcdi_mgmt_evq_poll(void *cookie)
+{
+	struct sfc_adapter *sa = cookie;
+
+	sfc_ev_mgmt_qpoll(sa);
+}
+
 static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
 	.dma_alloc	= sfc_mcdi_dma_alloc,
 	.dma_free	= sfc_mcdi_dma_free,
 	.sched_restart	= sfc_mcdi_sched_restart,
+	.mgmt_evq_poll	= sfc_mcdi_mgmt_evq_poll,
 };
 
 int
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 8f9b1991be..e3a637aeb7 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -39,10 +39,13 @@ typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
 
 typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie);
 
+typedef void (sfc_efx_mcdi_mgmt_evq_poll_cb)(void *cookie);
+
 struct sfc_efx_mcdi_ops {
 	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
 	sfc_efx_mcdi_dma_free_cb	*dma_free;
 	sfc_efx_mcdi_sched_restart_cb	*sched_restart;
+	sfc_efx_mcdi_mgmt_evq_poll_cb	*mgmt_evq_poll;
 };
 
 struct sfc_efx_mcdi {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (12 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

Now MCDI helpers interface is independent from network driver and
may be moved into common driver.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 47 +++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index fa9160f6d3..ff2bc14c5d 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -52,10 +52,8 @@
 	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
 
 static void
-sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
+sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
 	mcdi->state = SFC_EFX_MCDI_DEAD;
@@ -64,10 +62,8 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 }
 
 static inline boolean_t
-sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
+sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
 	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
@@ -78,9 +74,8 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 }
 
 static void
-sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
+sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	efx_nic_t *enp;
 	unsigned int delay_total;
 	unsigned int delay_us;
@@ -93,8 +88,9 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 	do {
 		boolean_t poll_completed;
 
-		poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) :
-					   efx_mcdi_request_poll(enp);
+		poll_completed = (proxy) ?
+				sfc_efx_mcdi_proxy_event_available(mcdi) :
+				efx_mcdi_request_poll(enp);
 		if (poll_completed)
 			return;
 
@@ -102,7 +98,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 			if (!proxy) {
 				aborted = efx_mcdi_request_abort(enp);
 				SFC_ASSERT(aborted);
-				sfc_efx_mcdi_timeout(sa);
+				sfc_efx_mcdi_timeout(mcdi);
 			}
 
 			return;
@@ -125,8 +121,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 static void
 sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	uint32_t proxy_handle;
 
 	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
@@ -139,7 +134,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-	sfc_efx_mcdi_poll(sa, B_FALSE);
+	sfc_efx_mcdi_poll(mcdi, B_FALSE);
 
 	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
 		/*
@@ -148,7 +143,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 		 * a non-zero proxy handle (should be the same as
 		 * the value obtained above) and operation status
 		 */
-		sfc_efx_mcdi_poll(sa, B_TRUE);
+		sfc_efx_mcdi_poll(mcdi, B_TRUE);
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
@@ -160,7 +155,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * request and poll for an ordinary MCDI response
 			 */
 			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-			sfc_efx_mcdi_poll(sa, B_FALSE);
+			sfc_efx_mcdi_poll(mcdi, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
 			sfc_efx_mcdi_err(mcdi,
@@ -175,10 +170,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 static void
 sfc_efx_mcdi_ev_cpl(void *arg)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi __rte_unused;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
-	mcdi = &sa->mcdi;
+	RTE_SET_USED(mcdi);
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	/* MCDI is polled, completions are not expected */
@@ -188,8 +182,7 @@ sfc_efx_mcdi_ev_cpl(void *arg)
 static void
 sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi  = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	sfc_efx_mcdi_warn(mcdi, "MC %s",
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
@@ -234,8 +227,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *header, size_t header_size,
 		void *data, size_t data_size)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	char buffer[SFC_MCDI_LOG_BUF_SIZE];
 	size_t pfxsize;
 	size_t start;
@@ -269,15 +261,14 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 static void
 sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	mcdi->proxy_handle = handle;
 	mcdi->proxy_result = result;
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
+sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
 		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
 		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
 {
@@ -308,7 +299,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 		goto fail_dma_alloc;
 
 	emtp = &mcdi->transport;
-	emtp->emt_context = sa;
+	emtp->emt_context = mcdi;
 	emtp->emt_dma_mem = &mcdi->mem;
 	emtp->emt_execute = sfc_efx_mcdi_execute;
 	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
@@ -409,7 +400,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       SFC_LOGTYPE_MCDI_STR,
 				       RTE_LOG_NOTICE);
 
-	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
+	return sfc_efx_mcdi_init(&sa->mcdi, logtype,
 				 sa->priv.shared->log_prefix, sa->nic,
 				 &sfc_mcdi_ops, sa);
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (13 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
@ 2020-09-08  9:14 ` Andrew Rybchenko
  2020-09-09 14:32 ` [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Ferruh Yigit
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
  16 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:14 UTC (permalink / raw)
  To: dev

These helper will be reused by other libefx consumers, e.g. vDPA
driver.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/Makefile               |   1 +
 drivers/common/sfc_efx/meson.build            |   1 +
 .../sfc_efx/rte_common_sfc_efx_version.map    |   9 +-
 drivers/common/sfc_efx/sfc_efx_mcdi.c         | 343 ++++++++++++++++++
 .../sfc_efx/sfc_efx_mcdi.h}                   |  12 +-
 drivers/net/sfc/sfc.h                         |   3 +-
 drivers/net/sfc/sfc_mcdi.c                    | 333 +----------------
 7 files changed, 360 insertions(+), 342 deletions(-)
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.c
 rename drivers/{net/sfc/sfc_mcdi.h => common/sfc_efx/sfc_efx_mcdi.h} (81%)

diff --git a/drivers/common/sfc_efx/Makefile b/drivers/common/sfc_efx/Makefile
index 0bd6a593e9..bcbb15e789 100644
--- a/drivers/common/sfc_efx/Makefile
+++ b/drivers/common/sfc_efx/Makefile
@@ -58,6 +58,7 @@ EXPORT_MAP := rte_common_sfc_efx_version.map
 #
 
 SRCS-y += sfc_efx.c
+SRCS-y += sfc_efx_mcdi.c
 
 VPATH += $(SRCDIR)/base
 
diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build
index 8fab4df792..b7a0763a34 100644
--- a/drivers/common/sfc_efx/meson.build
+++ b/drivers/common/sfc_efx/meson.build
@@ -34,6 +34,7 @@ objs = [base_objs]
 
 sources = files(
 	'sfc_efx.c',
+	'sfc_efx_mcdi.c',
 )
 
 includes += include_directories('base')
diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
index 0c719e8250..8c010c90ac 100644
--- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
+++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
@@ -47,13 +47,7 @@ DPDK_21 {
 	efx_mac_stats_update;
 	efx_mac_stats_upload;
 
-	efx_mcdi_fini;
-	efx_mcdi_get_proxy_handle;
-	efx_mcdi_init;
 	efx_mcdi_new_epoch;
-	efx_mcdi_request_abort;
-	efx_mcdi_request_poll;
-	efx_mcdi_request_start;
 
 	efx_nic_cfg_get;
 	efx_nic_create;
@@ -118,5 +112,8 @@ DPDK_21 {
 	efx_tx_qpush;
 	efx_txq_size;
 
+	sfc_efx_mcdi_init;
+	sfc_efx_mcdi_fini;
+
 	local: *;
 };
diff --git a/drivers/common/sfc_efx/sfc_efx_mcdi.c b/drivers/common/sfc_efx/sfc_efx_mcdi.c
new file mode 100644
index 0000000000..7eb565bbd6
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_mcdi.c
@@ -0,0 +1,343 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2016-2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#include <rte_cycles.h>
+
+#include "efx.h"
+#include "efx_mcdi.h"
+#include "efx_regs_mcdi.h"
+
+#include "sfc_efx_mcdi.h"
+#include "sfc_efx_debug.h"
+
+#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
+#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
+
+#define sfc_efx_mcdi_log(mcdi, level, ...) \
+	do {								\
+		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
+									\
+		rte_log(level, _mcdi->logtype,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_mcdi->log_prefix,			\
+				RTE_FMT_TAIL(__VA_ARGS__,)));		\
+	} while (0)
+
+#define sfc_efx_mcdi_crit(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
+
+#define sfc_efx_mcdi_err(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
+
+#define sfc_efx_mcdi_warn(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
+
+#define sfc_efx_mcdi_info(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
+
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
+
+static void
+sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
+{
+	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
+
+	sfc_efx_mcdi_crit(mcdi, "MCDI timeout handling is not implemented");
+	sfc_efx_mcdi_crit(mcdi, "NIC is unusable");
+	mcdi->state = SFC_EFX_MCDI_DEAD;
+}
+
+static inline boolean_t
+sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
+{
+	mcdi->proxy_handle = 0;
+	mcdi->proxy_result = ETIMEDOUT;
+	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
+	if (mcdi->proxy_result != ETIMEDOUT)
+		return B_TRUE;
+
+	return B_FALSE;
+}
+
+static void
+sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
+{
+	efx_nic_t *enp;
+	unsigned int delay_total;
+	unsigned int delay_us;
+	boolean_t aborted __rte_unused;
+
+	delay_total = 0;
+	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
+	enp = mcdi->nic;
+
+	do {
+		boolean_t poll_completed;
+
+		poll_completed = (proxy) ?
+				sfc_efx_mcdi_proxy_event_available(mcdi) :
+				efx_mcdi_request_poll(enp);
+		if (poll_completed)
+			return;
+
+		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
+			if (!proxy) {
+				aborted = efx_mcdi_request_abort(enp);
+				SFC_EFX_ASSERT(aborted);
+				sfc_efx_mcdi_timeout(mcdi);
+			}
+
+			return;
+		}
+
+		rte_delay_us(delay_us);
+
+		delay_total += delay_us;
+
+		/* Exponentially back off the poll frequency */
+		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
+				 UINT_MAX / 2);
+		delay_us *= 2;
+		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
+			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
+
+	} while (1);
+}
+
+static void
+sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+	uint32_t proxy_handle;
+
+	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
+		emrp->emr_rc = ENOEXEC;
+		return;
+	}
+
+	rte_spinlock_lock(&mcdi->lock);
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+
+	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
+	sfc_efx_mcdi_poll(mcdi, B_FALSE);
+
+	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
+		/*
+		 * Authorization is required for the MCDI request;
+		 * wait for an MCDI proxy response event to bring
+		 * a non-zero proxy handle (should be the same as
+		 * the value obtained above) and operation status
+		 */
+		sfc_efx_mcdi_poll(mcdi, B_TRUE);
+
+		if ((mcdi->proxy_handle != 0) &&
+		    (mcdi->proxy_handle != proxy_handle)) {
+			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
+			emrp->emr_rc = EFAULT;
+		} else if (mcdi->proxy_result == 0) {
+			/*
+			 * Authorization succeeded; re-issue the original
+			 * request and poll for an ordinary MCDI response
+			 */
+			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
+			sfc_efx_mcdi_poll(mcdi, B_FALSE);
+		} else {
+			emrp->emr_rc = mcdi->proxy_result;
+			sfc_efx_mcdi_err(mcdi,
+				"MCDI proxy authorization failed (handle=%08x, result=%d)",
+				proxy_handle, mcdi->proxy_result);
+		}
+	}
+
+	rte_spinlock_unlock(&mcdi->lock);
+}
+
+static void
+sfc_efx_mcdi_ev_cpl(void *arg)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	RTE_SET_USED(mcdi);
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+
+	/* MCDI is polled, completions are not expected */
+	SFC_EFX_ASSERT(0);
+}
+
+static void
+sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	sfc_efx_mcdi_warn(mcdi, "MC %s",
+	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
+	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
+
+	mcdi->ops->sched_restart(mcdi->ops_cookie);
+}
+
+#define SFC_MCDI_LOG_BUF_SIZE	128
+
+static size_t
+sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
+		char *buffer, void *data, size_t data_size,
+		size_t pfxsize, size_t position)
+{
+	uint32_t *words = data;
+	/* Space separator plus 2 characters per byte */
+	const size_t word_str_space = 1 + 2 * sizeof(*words);
+	size_t i;
+
+	for (i = 0; i < data_size; i += sizeof(*words)) {
+		if (position + word_str_space >=
+		    SFC_MCDI_LOG_BUF_SIZE) {
+			/* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash
+			 * at the end which is required by netlogdecode.
+			 */
+			buffer[position] = '\0';
+			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
+			/* Preserve prefix for the next log message */
+			position = pfxsize;
+		}
+		position += snprintf(buffer + position,
+				     SFC_MCDI_LOG_BUF_SIZE - position,
+				     " %08x", *words);
+		words++;
+	}
+	return position;
+}
+
+static void
+sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
+		void *header, size_t header_size,
+		void *data, size_t data_size)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+	char buffer[SFC_MCDI_LOG_BUF_SIZE];
+	size_t pfxsize;
+	size_t start;
+
+	/*
+	 * Unlike the other cases, MCDI logging implies more onerous work
+	 * needed to produce a message. If the dynamic log level prevents
+	 * the end result from being printed, the CPU time will be wasted.
+	 *
+	 * To avoid wasting time, the actual level is examined in advance.
+	 */
+	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
+		return;
+
+	/* The format including prefix added by sfc_efx_log_mcdi() is the
+	 * format consumed by the Solarflare netlogdecode tool.
+	 */
+	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
+			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
+			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
+				    pfxsize, pfxsize);
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
+				    pfxsize, start);
+	if (start != pfxsize) {
+		buffer[start] = '\0';
+		sfc_efx_log_mcdi(mcdi, "%s", buffer);
+	}
+}
+
+static void
+sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	mcdi->proxy_handle = handle;
+	mcdi->proxy_result = result;
+}
+
+int
+sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
+		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
+{
+	size_t max_msg_size;
+	efx_mcdi_transport_t *emtp;
+	int rc;
+
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
+	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
+		return EINVAL;
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
+
+	rte_spinlock_init(&mcdi->lock);
+
+	mcdi->ops = ops;
+	mcdi->ops_cookie = ops_cookie;
+	mcdi->nic = nic;
+
+	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
+
+	mcdi->logtype = logtype;
+	mcdi->log_prefix = log_prefix;
+
+	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
+	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
+	if (rc != 0)
+		goto fail_dma_alloc;
+
+	emtp = &mcdi->transport;
+	emtp->emt_context = mcdi;
+	emtp->emt_dma_mem = &mcdi->mem;
+	emtp->emt_execute = sfc_efx_mcdi_execute;
+	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
+	emtp->emt_exception = sfc_efx_mcdi_exception;
+	emtp->emt_logger = sfc_efx_mcdi_logger;
+	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
+
+	sfc_efx_mcdi_info(mcdi, "init MCDI");
+	rc = efx_mcdi_init(mcdi->nic, emtp);
+	if (rc != 0)
+		goto fail_mcdi_init;
+
+	return 0;
+
+fail_mcdi_init:
+	memset(emtp, 0, sizeof(*emtp));
+	ops->dma_free(ops_cookie, &mcdi->mem);
+
+fail_dma_alloc:
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
+	return rc;
+}
+
+void
+sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
+{
+	efx_mcdi_transport_t *emtp;
+
+	emtp = &mcdi->transport;
+
+	rte_spinlock_lock(&mcdi->lock);
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
+		       mcdi->state == SFC_EFX_MCDI_DEAD);
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
+
+	sfc_efx_mcdi_info(mcdi, "fini MCDI");
+	efx_mcdi_fini(mcdi->nic);
+	memset(emtp, 0, sizeof(*emtp));
+
+	rte_spinlock_unlock(&mcdi->lock);
+
+	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
+}
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/common/sfc_efx/sfc_efx_mcdi.h
similarity index 81%
rename from drivers/net/sfc/sfc_mcdi.h
rename to drivers/common/sfc_efx/sfc_efx_mcdi.h
index e3a637aeb7..836afacddc 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/common/sfc_efx/sfc_efx_mcdi.h
@@ -7,8 +7,8 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
-#ifndef _SFC_MCDI_H
-#define _SFC_MCDI_H
+#ifndef _SFC_EFX_MCDI_H
+#define _SFC_EFX_MCDI_H
 
 #include <stdint.h>
 
@@ -62,8 +62,14 @@ struct sfc_efx_mcdi {
 	const char			*log_prefix;
 };
 
+int sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
+		      uint32_t logtype, const char *log_prefix,
+		      efx_nic_t *nic,
+		      const struct sfc_efx_mcdi_ops *ops, void *ops_cookie);
+void sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi);
+
 #ifdef __cplusplus
 }
 #endif
 
-#endif  /* _SFC_MCDI_H */
+#endif  /* _SFC_EFX_MCDI_H */
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index b20fecb4f8..fa7c79b80b 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -21,10 +21,11 @@
 
 #include "efx.h"
 
+#include "sfc_efx_mcdi.h"
+
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_filter.h"
-#include "sfc_mcdi.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index ff2bc14c5d..644dd9c980 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -7,344 +7,13 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
-#include <rte_cycles.h>
+#include "sfc_efx_mcdi.h"
 
-#include "efx.h"
-#include "efx_mcdi.h"
-#include "efx_regs_mcdi.h"
-
-#include "sfc_mcdi.h"
 #include "sfc.h"
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
-#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
-#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
-#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
-
-#define sfc_efx_mcdi_log(mcdi, level, ...) \
-	do {								\
-		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
-									\
-		rte_log(level, _mcdi->logtype,				\
-			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
-				_mcdi->log_prefix,			\
-				RTE_FMT_TAIL(__VA_ARGS__,)));		\
-	} while (0)
-
-#define sfc_efx_mcdi_crit(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
-
-#define sfc_efx_mcdi_err(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
-
-#define sfc_efx_mcdi_warn(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
-
-#define sfc_efx_mcdi_info(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
-
-/** Level value used by MCDI log statements */
-#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
-#define sfc_efx_log_mcdi(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
-
-static void
-sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
-{
-	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
-
-	mcdi->state = SFC_EFX_MCDI_DEAD;
-	sfc_efx_mcdi_crit(mcdi,
-		"MCDI timeout handling is not implemented - NIC is unusable");
-}
-
-static inline boolean_t
-sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
-{
-	mcdi->proxy_handle = 0;
-	mcdi->proxy_result = ETIMEDOUT;
-	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
-	if (mcdi->proxy_result != ETIMEDOUT)
-		return B_TRUE;
-
-	return B_FALSE;
-}
-
-static void
-sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
-{
-	efx_nic_t *enp;
-	unsigned int delay_total;
-	unsigned int delay_us;
-	boolean_t aborted __rte_unused;
-
-	delay_total = 0;
-	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
-	enp = mcdi->nic;
-
-	do {
-		boolean_t poll_completed;
-
-		poll_completed = (proxy) ?
-				sfc_efx_mcdi_proxy_event_available(mcdi) :
-				efx_mcdi_request_poll(enp);
-		if (poll_completed)
-			return;
-
-		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
-			if (!proxy) {
-				aborted = efx_mcdi_request_abort(enp);
-				SFC_ASSERT(aborted);
-				sfc_efx_mcdi_timeout(mcdi);
-			}
-
-			return;
-		}
-
-		rte_delay_us(delay_us);
-
-		delay_total += delay_us;
-
-		/* Exponentially back off the poll frequency */
-		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
-				 UINT_MAX / 2);
-		delay_us *= 2;
-		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
-			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
-
-	} while (1);
-}
-
-static void
-sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-	uint32_t proxy_handle;
-
-	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
-		emrp->emr_rc = ENOEXEC;
-		return;
-	}
-
-	rte_spinlock_lock(&mcdi->lock);
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
-
-	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-	sfc_efx_mcdi_poll(mcdi, B_FALSE);
-
-	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
-		/*
-		 * Authorization is required for the MCDI request;
-		 * wait for an MCDI proxy response event to bring
-		 * a non-zero proxy handle (should be the same as
-		 * the value obtained above) and operation status
-		 */
-		sfc_efx_mcdi_poll(mcdi, B_TRUE);
-
-		if ((mcdi->proxy_handle != 0) &&
-		    (mcdi->proxy_handle != proxy_handle)) {
-			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
-			emrp->emr_rc = EFAULT;
-		} else if (mcdi->proxy_result == 0) {
-			/*
-			 * Authorization succeeded; re-issue the original
-			 * request and poll for an ordinary MCDI response
-			 */
-			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-			sfc_efx_mcdi_poll(mcdi, B_FALSE);
-		} else {
-			emrp->emr_rc = mcdi->proxy_result;
-			sfc_efx_mcdi_err(mcdi,
-				"MCDI proxy authorization failed (handle=%08x, result=%d)",
-				proxy_handle, mcdi->proxy_result);
-		}
-	}
-
-	rte_spinlock_unlock(&mcdi->lock);
-}
-
-static void
-sfc_efx_mcdi_ev_cpl(void *arg)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	RTE_SET_USED(mcdi);
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
-
-	/* MCDI is polled, completions are not expected */
-	SFC_ASSERT(0);
-}
-
-static void
-sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	sfc_efx_mcdi_warn(mcdi, "MC %s",
-	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
-	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
-
-	mcdi->ops->sched_restart(mcdi->ops_cookie);
-}
-
-#define SFC_MCDI_LOG_BUF_SIZE	128
-
-static size_t
-sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
-		char *buffer, void *data, size_t data_size,
-		size_t pfxsize, size_t position)
-{
-	uint32_t *words = data;
-	/* Space separator plus 2 characters per byte */
-	const size_t word_str_space = 1 + 2 * sizeof(*words);
-	size_t i;
-
-	for (i = 0; i < data_size; i += sizeof(*words)) {
-		if (position + word_str_space >=
-		    SFC_MCDI_LOG_BUF_SIZE) {
-			/* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash
-			 * at the end which is required by netlogdecode.
-			 */
-			buffer[position] = '\0';
-			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
-			/* Preserve prefix for the next log message */
-			position = pfxsize;
-		}
-		position += snprintf(buffer + position,
-				     SFC_MCDI_LOG_BUF_SIZE - position,
-				     " %08x", *words);
-		words++;
-	}
-	return position;
-}
-
-static void
-sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
-		void *header, size_t header_size,
-		void *data, size_t data_size)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-	char buffer[SFC_MCDI_LOG_BUF_SIZE];
-	size_t pfxsize;
-	size_t start;
-
-	/*
-	 * Unlike the other cases, MCDI logging implies more onerous work
-	 * needed to produce a message. If the dynamic log level prevents
-	 * the end result from being printed, the CPU time will be wasted.
-	 *
-	 * To avoid wasting time, the actual level is examined in advance.
-	 */
-	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
-		return;
-
-	/* The format including prefix added by sfc_efx_log_mcdi() is the
-	 * format consumed by the Solarflare netlogdecode tool.
-	 */
-	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
-			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
-			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
-				    pfxsize, pfxsize);
-	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
-				    pfxsize, start);
-	if (start != pfxsize) {
-		buffer[start] = '\0';
-		sfc_efx_log_mcdi(mcdi, "%s", buffer);
-	}
-}
-
-static void
-sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	mcdi->proxy_handle = handle;
-	mcdi->proxy_result = result;
-}
-
-static int
-sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
-		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
-{
-	size_t max_msg_size;
-	efx_mcdi_transport_t *emtp;
-	int rc;
-
-	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
-	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
-		return EINVAL;
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
-
-	rte_spinlock_init(&mcdi->lock);
-
-	mcdi->ops = ops;
-	mcdi->ops_cookie = ops_cookie;
-	mcdi->nic = nic;
-
-	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
-
-	mcdi->logtype = logtype;
-	mcdi->log_prefix = log_prefix;
-
-	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
-	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
-	if (rc != 0)
-		goto fail_dma_alloc;
-
-	emtp = &mcdi->transport;
-	emtp->emt_context = mcdi;
-	emtp->emt_dma_mem = &mcdi->mem;
-	emtp->emt_execute = sfc_efx_mcdi_execute;
-	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
-	emtp->emt_exception = sfc_efx_mcdi_exception;
-	emtp->emt_logger = sfc_efx_mcdi_logger;
-	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
-
-	sfc_efx_mcdi_info(mcdi, "init MCDI");
-	rc = efx_mcdi_init(mcdi->nic, emtp);
-	if (rc != 0)
-		goto fail_mcdi_init;
-
-	return 0;
-
-fail_mcdi_init:
-	memset(emtp, 0, sizeof(*emtp));
-	ops->dma_free(ops_cookie, &mcdi->mem);
-
-fail_dma_alloc:
-	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
-	return rc;
-}
-
-static void
-sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
-{
-	efx_mcdi_transport_t *emtp;
-
-	emtp = &mcdi->transport;
-
-	rte_spinlock_lock(&mcdi->lock);
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
-		   mcdi->state == SFC_EFX_MCDI_DEAD);
-	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
-
-	sfc_efx_mcdi_info(mcdi, "fini MCDI");
-	efx_mcdi_fini(mcdi->nic);
-	memset(emtp, 0, sizeof(*emtp));
-
-	rte_spinlock_unlock(&mcdi->lock);
-
-	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
-}
-
 static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
 static int
 sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
@ 2020-09-08  9:26   ` Andrew Rybchenko
  0 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-08  9:26 UTC (permalink / raw)
  To: dev; +Cc: Steve Yang, stable

On 9/8/20 12:14 PM, Andrew Rybchenko wrote:
> From: Steve Yang <stevex.yang@intel.com>
>
> When receiving the unsupported AQ messages, it's taken as an
> error. It's not appropriate and triggers too much unnecessary print.
>
> Fixes: 22b123a36d07 ("net/avf: initialize PMD")
> Cc: stable@dpdk.org
>
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> Acked-by: Beilei Xing <beilei.xing@intel.com>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

I apologize, my bad on patch queue formatting. I've marked it
as rejected in patchwork since it is already in next-net.


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (14 preceding siblings ...)
  2020-09-08  9:14 ` [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
@ 2020-09-09 14:32 ` Ferruh Yigit
  2020-09-17  6:21   ` Andrew Rybchenko
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
  16 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2020-09-09 14:32 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: Thomas Monjalon, David Marchand

On 9/8/2020 10:14 AM, Andrew Rybchenko wrote:
> Network and vDPA drivers share libefx. So, libefx should be moved
> to common drivers.
> 
> DPDK adaptation of the MCDI interface may be shared as well.
> 
> The new common driver name is sfc_efx since it a new home of
> libefx base driver. sfc_ prefix is used to make it clear that
> it is related to net/sfc (and vdpa/sfc in the future).
> 
> In theory, right now all exported libefx functions should be marked
> as internal, but it requires corresponding markup in base driver
> which sources should have no DPDK specifics since shared by many
> drivers. So, it is unclear what to do and how to solve it.
>

Can a osdep.h can be added, like some other drivers do?
In that header a macro can be expanded to '__rte_internal' for DPDK, and empty
for others...

> 
> The patch series makes these functions a part of DPDK_21 ABI to
> pass build checks. checkpatches.sh does not like it.
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: David Marchand <david.marchand@redhat.com>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> Andrew Rybchenko (14):
>   net/sfc: include header with debug helpers directly
>   net/sfc: introduce common driver library
>   net/sfc: add dedicated header file with MCDI interface
>   net/sfc: move MCDI helper interface to dedicated namespace
>   net/sfc: make MCDI logging helper macros local
>   net/sfc: start to make MCDI helpers interface shareable
>   net/sfc: use own logging helper macros
>   net/sfc: avoid usage of NIC pointer from adapter context
>   net/sfc: avoid panic in the case of MCDI timeout
>   net/sfc: add MCDI callbacks to allocate/free DMA memory
>   net/sfc: add MCDI callback to schedule restart
>   net/sfc: add MCDI callback to poll management event queue
>   net/sfc: use MCDI control structure as libefx ops context
>   net/sfc: move MCDI helpers to common driver
> 
<...>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library
  2020-09-09 14:32 ` [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Ferruh Yigit
@ 2020-09-17  6:21   ` Andrew Rybchenko
  0 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:21 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: Thomas Monjalon, David Marchand

On 9/9/20 5:32 PM, Ferruh Yigit wrote:
> On 9/8/2020 10:14 AM, Andrew Rybchenko wrote:
>> Network and vDPA drivers share libefx. So, libefx should be moved
>> to common drivers.
>>
>> DPDK adaptation of the MCDI interface may be shared as well.
>>
>> The new common driver name is sfc_efx since it a new home of
>> libefx base driver. sfc_ prefix is used to make it clear that
>> it is related to net/sfc (and vdpa/sfc in the future).
>>
>> In theory, right now all exported libefx functions should be marked
>> as internal, but it requires corresponding markup in base driver
>> which sources should have no DPDK specifics since shared by many
>> drivers. So, it is unclear what to do and how to solve it.
>>
> Can a osdep.h can be added, like some other drivers do?
> In that header a macro can be expanded to '__rte_internal' for DPDK, and empty
> for others...

Thanks Ferruh, we have discussed the idea and will go this way.
I'll send v2 patches today.


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library
  2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
                   ` (15 preceding siblings ...)
  2020-09-09 14:32 ` [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Ferruh Yigit
@ 2020-09-17  6:34 ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers Andrew Rybchenko
                     ` (17 more replies)
  16 siblings, 18 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, David Marchand, Ferruh Yigit

Network and vDPA drivers share libefx. So, libefx should be moved
to common drivers.

DPDK adaptation of the MCDI interface may be shared as well.

The new common driver name is sfc_efx since it a new home of
libefx base driver. sfc_ prefix is used to make it clear that
it is related to net/sfc (and vdpa/sfc in the future).

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: David Marchand <david.marchand@redhat.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>

v2:
 - add patches to introduce LIBEFX_API and LIBEFX_INTERNAL
   global functions decorators
 - use LIBEFX_API for __rte_internal markup

Andrew Rybchenko (17):
  net/sfc/base: add missing extern storage-class specifiers
  net/sfc/base: decorate libefx API functions
  net/sfc/base: decorate libefx internal extern functions
  net/sfc: include header with debug helpers directly
  net/sfc: introduce common driver library
  net/sfc: add dedicated header file with MCDI interface
  net/sfc: move MCDI helper interface to dedicated namespace
  net/sfc: make MCDI logging helper macros local
  net/sfc: start to make MCDI helpers interface shareable
  net/sfc: use own logging helper macros
  net/sfc: avoid usage of NIC pointer from adapter context
  net/sfc: avoid panic in the case of MCDI timeout
  net/sfc: add MCDI callbacks to allocate/free DMA memory
  net/sfc: add MCDI callback to schedule restart
  net/sfc: add MCDI callback to poll management event queue
  net/sfc: use MCDI control structure as libefx ops context
  net/sfc: move MCDI helpers to common driver

 MAINTAINERS                                   |   1 +
 drivers/common/meson.build                    |   2 +-
 .../{net/sfc => common/sfc_efx}/base/README   |   0
 .../sfc => common/sfc_efx}/base/ef10_ev.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_evb.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_filter.c |   0
 .../sfc_efx}/base/ef10_firmware_ids.h         |   0
 .../sfc => common/sfc_efx}/base/ef10_image.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_impl.h   | 250 +++++++++++--
 .../sfc => common/sfc_efx}/base/ef10_intr.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_mac.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_mcdi.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_nic.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_nvram.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_phy.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_proxy.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_rx.c     |   0
 .../sfc_efx}/base/ef10_signed_image_layout.h  |   0
 .../sfc_efx}/base/ef10_tlv_layout.h           |   0
 .../sfc => common/sfc_efx}/base/ef10_tx.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_vpd.c    |   0
 .../{net/sfc => common/sfc_efx}/base/efx.h    | 269 +++++++++++++-
 .../sfc => common/sfc_efx}/base/efx_annote.h  |   0
 .../sfc => common/sfc_efx}/base/efx_bootcfg.c |   0
 .../sfc => common/sfc_efx}/base/efx_check.h   |  13 +
 .../sfc => common/sfc_efx}/base/efx_crc32.c   |   0
 .../{net/sfc => common/sfc_efx}/base/efx_ev.c |   0
 .../sfc => common/sfc_efx}/base/efx_evb.c     |   0
 .../sfc => common/sfc_efx}/base/efx_filter.c  |   0
 .../sfc => common/sfc_efx}/base/efx_hash.c    |   0
 .../sfc => common/sfc_efx}/base/efx_impl.h    |  44 ++-
 .../sfc => common/sfc_efx}/base/efx_intr.c    |   0
 .../sfc => common/sfc_efx}/base/efx_lic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mac.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.c    |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.h    |  29 ++
 .../sfc => common/sfc_efx}/base/efx_mon.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nvram.c   |   0
 .../sfc => common/sfc_efx}/base/efx_phy.c     |   0
 .../sfc => common/sfc_efx}/base/efx_phy_ids.h |   0
 .../sfc => common/sfc_efx}/base/efx_port.c    |   0
 .../sfc => common/sfc_efx}/base/efx_proxy.c   |   0
 .../sfc => common/sfc_efx}/base/efx_regs.h    |   0
 .../sfc_efx}/base/efx_regs_ef10.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi_aoe.h         |   0
 .../sfc_efx}/base/efx_regs_mcdi_strs.h        |   0
 .../sfc_efx}/base/efx_regs_pci.h              |   0
 .../{net/sfc => common/sfc_efx}/base/efx_rx.c |   0
 .../sfc => common/sfc_efx}/base/efx_sram.c    |   0
 .../sfc => common/sfc_efx}/base/efx_tunnel.c  |   0
 .../{net/sfc => common/sfc_efx}/base/efx_tx.c |   0
 .../sfc => common/sfc_efx}/base/efx_types.h   |   0
 .../sfc => common/sfc_efx}/base/efx_vpd.c     |   0
 .../sfc => common/sfc_efx}/base/hunt_impl.h   |   1 +
 .../sfc => common/sfc_efx}/base/hunt_nic.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.h    |   9 +-
 .../sfc_efx}/base/medford2_impl.h             |   1 +
 .../sfc_efx}/base/medford2_nic.c              |   0
 .../sfc_efx}/base/medford_impl.h              |   1 +
 .../sfc => common/sfc_efx}/base/medford_nic.c |   0
 .../sfc => common/sfc_efx}/base/meson.build   |   0
 .../sfc => common/sfc_efx}/base/siena_flash.h |   0
 .../sfc => common/sfc_efx}/base/siena_impl.h  |  60 +++
 .../sfc => common/sfc_efx}/base/siena_mac.c   |   0
 .../sfc => common/sfc_efx}/base/siena_mcdi.c  |   0
 .../sfc => common/sfc_efx}/base/siena_nic.c   |   0
 .../sfc => common/sfc_efx}/base/siena_nvram.c |   0
 .../sfc => common/sfc_efx}/base/siena_phy.c   |   0
 .../sfc => common/sfc_efx}/base/siena_sram.c  |   0
 .../sfc => common/sfc_efx}/base/siena_vpd.c   |   0
 drivers/{net/sfc => common/sfc_efx}/efsys.h   |  63 ++--
 drivers/common/sfc_efx/meson.build            |  40 ++
 .../sfc_efx/rte_common_sfc_efx_version.map    | 185 ++++++++++
 drivers/common/sfc_efx/sfc_efx.c              |  23 ++
 drivers/common/sfc_efx/sfc_efx_debug.h        |  29 ++
 drivers/common/sfc_efx/sfc_efx_log.h          |  22 ++
 drivers/common/sfc_efx/sfc_efx_mcdi.c         | 343 ++++++++++++++++++
 drivers/common/sfc_efx/sfc_efx_mcdi.h         |  77 ++++
 drivers/net/sfc/meson.build                   |   6 +-
 drivers/net/sfc/sfc.c                         |   1 +
 drivers/net/sfc/sfc.h                         |  26 +-
 drivers/net/sfc/sfc_dp_tx.h                   |   1 +
 drivers/net/sfc/sfc_ef10.h                    |   2 +
 drivers/net/sfc/sfc_ef10_essb_rx.c            |   1 +
 drivers/net/sfc/sfc_ef10_rx.c                 |   1 +
 drivers/net/sfc/sfc_ef10_rx_ev.h              |   2 +
 drivers/net/sfc/sfc_ef10_tx.c                 |   1 +
 drivers/net/sfc/sfc_ethdev.c                  |  13 +
 drivers/net/sfc/sfc_filter.c                  |   1 +
 drivers/net/sfc/sfc_flow.c                    |   1 +
 drivers/net/sfc/sfc_log.h                     |  21 +-
 drivers/net/sfc/sfc_mcdi.c                    | 295 ++-------------
 drivers/net/sfc/sfc_port.c                    |   1 +
 96 files changed, 1452 insertions(+), 383 deletions(-)
 rename drivers/{net/sfc => common/sfc_efx}/base/README (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_firmware_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_image.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_impl.h (89%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_signed_image_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tlv_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx.h (96%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_annote.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_bootcfg.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_check.h (97%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_crc32.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_hash.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_impl.h (98%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_lic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.h (96%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_port.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_ef10.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_aoe.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_strs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_pci.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tunnel.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_types.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_impl.h (98%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.h (89%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_impl.h (97%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_impl.h (97%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/meson.build (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_flash.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_impl.h (90%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/efsys.h (93%)
 create mode 100644 drivers/common/sfc_efx/meson.build
 create mode 100644 drivers/common/sfc_efx/rte_common_sfc_efx_version.map
 create mode 100644 drivers/common/sfc_efx/sfc_efx.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_debug.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_log.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 02/17] net/sfc/base: decorate libefx API functions Andrew Rybchenko
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

libefx coding standard requires it and the specifier is
used for almost all functions in the header file.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Reviewed-by: Richard Houldsworth <rhouldsw@xilinx.com>
---
 drivers/net/sfc/base/ef10_impl.h | 56 ++++++++++++++++----------------
 drivers/net/sfc/base/efx.h       | 18 +++++-----
 drivers/net/sfc/base/efx_impl.h  | 18 +++++-----
 drivers/net/sfc/base/mcdi_mon.h  |  4 +--
 4 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 0530f62baa..1f17fc2f69 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -91,15 +91,15 @@ extern "C" {
 
 /* EV */
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_ev_init(
 	__in		efx_nic_t *enp);
 
-			void
+extern			void
 ef10_ev_fini(
 	__in		efx_nic_t *enp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_ev_qcreate(
 	__in		efx_nic_t *enp,
 	__in		unsigned int index,
@@ -110,85 +110,85 @@ ef10_ev_qcreate(
 	__in		uint32_t flags,
 	__in		efx_evq_t *eep);
 
-			void
+extern			void
 ef10_ev_qdestroy(
 	__in		efx_evq_t *eep);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_ev_qprime(
 	__in		efx_evq_t *eep,
 	__in		unsigned int count);
 
-			void
+extern			void
 ef10_ev_qpost(
 	__in	efx_evq_t *eep,
 	__in	uint16_t data);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_ev_qmoderate(
 	__in		efx_evq_t *eep,
 	__in		unsigned int us);
 
 #if EFSYS_OPT_QSTATS
-			void
+extern			void
 ef10_ev_qstats_update(
 	__in				efx_evq_t *eep,
 	__inout_ecount(EV_NQSTATS)	efsys_stat_t *stat);
 #endif /* EFSYS_OPT_QSTATS */
 
-		void
+extern			void
 ef10_ev_rxlabel_init(
 	__in		efx_evq_t *eep,
 	__in		efx_rxq_t *erp,
 	__in		unsigned int label,
 	__in		efx_rxq_type_t type);
 
-		void
+extern			void
 ef10_ev_rxlabel_fini(
 	__in		efx_evq_t *eep,
 	__in		unsigned int label);
 
 /* INTR */
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_intr_init(
 	__in		efx_nic_t *enp,
 	__in		efx_intr_type_t type,
 	__in		efsys_mem_t *esmp);
 
-			void
+extern			void
 ef10_intr_enable(
 	__in		efx_nic_t *enp);
 
-			void
+extern			void
 ef10_intr_disable(
 	__in		efx_nic_t *enp);
 
-			void
+extern			void
 ef10_intr_disable_unlocked(
 	__in		efx_nic_t *enp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_intr_trigger(
 	__in		efx_nic_t *enp,
 	__in		unsigned int level);
 
-			void
+extern			void
 ef10_intr_status_line(
 	__in		efx_nic_t *enp,
 	__out		boolean_t *fatalp,
 	__out		uint32_t *qmaskp);
 
-			void
+extern			void
 ef10_intr_status_message(
 	__in		efx_nic_t *enp,
 	__in		unsigned int message,
 	__out		boolean_t *fatalp);
 
-			void
+extern			void
 ef10_intr_fatal(
 	__in		efx_nic_t *enp);
-			void
+extern			void
 ef10_intr_fini(
 	__in		efx_nic_t *enp);
 
@@ -1134,25 +1134,25 @@ typedef struct ef10_filter_table_s {
 	uint32_t		eft_encap_filter_count;
 } ef10_filter_table_t;
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_filter_init(
 	__in		efx_nic_t *enp);
 
-			void
+extern			void
 ef10_filter_fini(
 	__in		efx_nic_t *enp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_filter_restore(
 	__in		efx_nic_t *enp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_filter_add(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec,
 	__in		enum efx_filter_replacement_policy_e policy);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_filter_delete(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec);
@@ -1394,26 +1394,26 @@ ef10_proxy_auth_privilege_modify(
 	__in		uint32_t add_privileges_mask,
 	__in		uint32_t remove_privileges_mask);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_set_privilege_mask(
 	__in		efx_nic_t *enp,
 	__in		uint32_t vf_index,
 	__in		uint32_t mask,
 	__in		uint32_t value);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_complete_request(
 	__in		efx_nic_t *enp,
 	__in		uint32_t fn_index,
 	__in		uint32_t proxy_result,
 	__in		uint32_t handle);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_exec_cmd(
 	__in		efx_nic_t *enp,
 	__inout		efx_proxy_cmd_params_t *paramsp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_get_privilege_mask(
 	__in		efx_nic_t *enp,
 	__in		uint32_t pf_index,
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 07cd0bb398..f723ff2540 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -269,7 +269,7 @@ extern	__checkReturn	efx_rc_t
 efx_mcdi_reboot(
 	__in		efx_nic_t *enp);
 
-			void
+extern			void
 efx_mcdi_new_epoch(
 	__in		efx_nic_t *enp);
 
@@ -2346,7 +2346,7 @@ efx_rx_fini(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_RX_SCATTER
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_rx_scatter_enable(
 	__in		efx_nic_t *enp,
 	__in		unsigned int buf_size);
@@ -3244,7 +3244,7 @@ efx_lic_write_key(
 	__in			uint32_t length,
 	__out			uint32_t *lengthp);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_lic_delete_key(
 	__in			efx_nic_t *enp,
 	__in_bcount(buffer_size)
@@ -3511,38 +3511,38 @@ efx_proxy_auth_configure(
 	__in		efx_nic_t *enp,
 	__in		efx_proxy_auth_config_t *configp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_destroy(
 	__in		efx_nic_t *enp,
 	__in		uint32_t handled_privileges);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_complete_request(
 	__in		efx_nic_t *enp,
 	__in		uint32_t fn_index,
 	__in		uint32_t proxy_result,
 	__in		uint32_t handle);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_exec_cmd(
 	__in		efx_nic_t *enp,
 	__inout		efx_proxy_cmd_params_t *paramsp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_set_privilege_mask(
 	__in		efx_nic_t *enp,
 	__in		uint32_t vf_index,
 	__in		uint32_t mask,
 	__in		uint32_t value);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_privilege_mask_get(
 	__in		efx_nic_t *enp,
 	__in		uint32_t pf_index,
 	__in		uint32_t vf_index,
 	__out		uint32_t *maskp);
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 efx_proxy_auth_privilege_modify(
 	__in		efx_nic_t *enp,
 	__in		uint32_t pf_index,
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index c4718dba70..70176760be 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -566,14 +566,14 @@ typedef struct efx_vpd_ops_s {
 
 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_partitions(
 	__in			efx_nic_t *enp,
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size,
 	__out			unsigned int *npartnp);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_metadata(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
@@ -582,18 +582,18 @@ efx_mcdi_nvram_metadata(
 	__out_bcount_opt(size)	char *descp,
 	__in			size_t size);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_info(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			efx_nvram_info_t *eni);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_update_start(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_read(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
@@ -602,14 +602,14 @@ efx_mcdi_nvram_read(
 	__in			size_t size,
 	__in			uint32_t mode);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_erase(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__in			uint32_t offset,
 	__in			size_t size);
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_write(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
@@ -620,7 +620,7 @@ efx_mcdi_nvram_write(
 #define	EFX_NVRAM_UPDATE_FLAGS_BACKGROUND	0x00000001
 #define	EFX_NVRAM_UPDATE_FLAGS_POLL		0x00000002
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_update_finish(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
@@ -630,7 +630,7 @@ efx_mcdi_nvram_update_finish(
 
 #if EFSYS_OPT_DIAG
 
-	__checkReturn		efx_rc_t
+extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_test(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn);
diff --git a/drivers/net/sfc/base/mcdi_mon.h b/drivers/net/sfc/base/mcdi_mon.h
index d7fbf07c36..c79f55c35f 100644
--- a/drivers/net/sfc/base/mcdi_mon.h
+++ b/drivers/net/sfc/base/mcdi_mon.h
@@ -17,11 +17,11 @@ extern "C" {
 
 #if EFSYS_OPT_MON_STATS
 
-	__checkReturn	efx_rc_t
+extern	__checkReturn	efx_rc_t
 mcdi_mon_cfg_build(
     __in		efx_nic_t *enp);
 
-			void
+extern			void
 mcdi_mon_cfg_free(
 	__in		efx_nic_t *enp);
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 02/17] net/sfc/base: decorate libefx API functions
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 03/17] net/sfc/base: decorate libefx internal extern functions Andrew Rybchenko
                     ` (15 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

The decorators will be used in the future to mark libefx API
functions as __rte_internal.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Reviewed-by: Richard Houldsworth <rhouldsw@xilinx.com>
---
 drivers/net/sfc/base/efx.h       | 251 +++++++++++++++++++++++++++++++
 drivers/net/sfc/base/efx_check.h |   9 ++
 drivers/net/sfc/base/efx_mcdi.h  |   1 +
 drivers/net/sfc/efsys.h          |   3 +
 4 files changed, 264 insertions(+)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index f723ff2540..c1b4876314 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -58,6 +58,7 @@ typedef enum efx_family_e {
 	EFX_FAMILY_NTYPES
 } efx_family_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_family(
 	__in		uint16_t venid,
@@ -120,6 +121,7 @@ enum {
 };
 
 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */
+LIBEFX_API
 extern	__checkReturn		uint32_t
 efx_crc32_calculate(
 	__in			uint32_t crc_init,
@@ -135,6 +137,7 @@ typedef struct efx_rxq_s	efx_rxq_t;
 
 typedef struct efx_nic_s	efx_nic_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_create(
 	__in		efx_family_t family,
@@ -155,43 +158,52 @@ typedef enum efx_fw_variant_e {
 	EFX_FW_VARIANT_DONT_CARE = 0xffffffff
 } efx_fw_variant_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_probe(
 	__in		efx_nic_t *enp,
 	__in		efx_fw_variant_t efv);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_reset(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	boolean_t
 efx_nic_hw_unavailable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_nic_set_hw_unavailable(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_register_test(
 	__in		efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_API
 extern		void
 efx_nic_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern		void
 efx_nic_unprobe(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern		void
 efx_nic_destroy(
 	__in	efx_nic_t *enp);
@@ -207,12 +219,14 @@ typedef enum efx_pcie_link_performance_e {
 	EFX_PCIE_LINK_PERFORMANCE_OPTIMAL
 } efx_pcie_link_performance_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_calculate_pcie_link_bandwidth(
 	__in		uint32_t pcie_link_width,
 	__in		uint32_t pcie_link_gen,
 	__out		uint32_t *bandwidth_mbpsp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_check_pcie_link_speed(
 	__in		efx_nic_t *enp,
@@ -260,39 +274,47 @@ typedef struct efx_mcdi_transport_s {
 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
 } efx_mcdi_transport_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mcdi_init(
 	__in		efx_nic_t *enp,
 	__in		const efx_mcdi_transport_t *mtp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mcdi_reboot(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_mcdi_new_epoch(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_mcdi_get_timeout(
 	__in		efx_nic_t *enp,
 	__in		efx_mcdi_req_t *emrp,
 	__out		uint32_t *usec_timeoutp);
 
+LIBEFX_API
 extern			void
 efx_mcdi_request_start(
 	__in		efx_nic_t *enp,
 	__in		efx_mcdi_req_t *emrp,
 	__in		boolean_t ev_cpl);
 
+LIBEFX_API
 extern	__checkReturn	boolean_t
 efx_mcdi_request_poll(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	boolean_t
 efx_mcdi_request_abort(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_mcdi_fini(
 	__in		efx_nic_t *enp);
@@ -312,47 +334,56 @@ typedef enum efx_intr_type_e {
 
 #define	EFX_INTR_SIZE	(sizeof (efx_oword_t))
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_intr_init(
 	__in		efx_nic_t *enp,
 	__in		efx_intr_type_t type,
 	__in_opt	efsys_mem_t *esmp);
 
+LIBEFX_API
 extern			void
 efx_intr_enable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_intr_disable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_intr_disable_unlocked(
 	__in		efx_nic_t *enp);
 
 #define	EFX_INTR_NEVQS	32
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_intr_trigger(
 	__in		efx_nic_t *enp,
 	__in		unsigned int level);
 
+LIBEFX_API
 extern			void
 efx_intr_status_line(
 	__in		efx_nic_t *enp,
 	__out		boolean_t *fatalp,
 	__out		uint32_t *maskp);
 
+LIBEFX_API
 extern			void
 efx_intr_status_message(
 	__in		efx_nic_t *enp,
 	__in		unsigned int message,
 	__out		boolean_t *fatalp);
 
+LIBEFX_API
 extern			void
 efx_intr_fatal(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_intr_fini(
 	__in		efx_nic_t *enp);
@@ -521,21 +552,25 @@ typedef enum efx_link_mode_e {
 #define	EFX_MAC_PDU_MIN	60
 #define	EFX_MAC_PDU_MAX	EFX_MAC_PDU(EFX_MAC_SDU_MAX)
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_pdu_get(
 	__in		efx_nic_t *enp,
 	__out		size_t *pdu);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_pdu_set(
 	__in		efx_nic_t *enp,
 	__in		size_t pdu);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_addr_set(
 	__in		efx_nic_t *enp,
 	__in		uint8_t *addr);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_filter_set(
 	__in				efx_nic_t *enp,
@@ -544,33 +579,39 @@ efx_mac_filter_set(
 	__in				boolean_t all_mulcst,
 	__in				boolean_t brdcst);
 
+LIBEFX_API
 extern					void
 efx_mac_filter_get_all_ucast_mcast(
 	__in				efx_nic_t *enp,
 	__out				boolean_t *all_unicst,
 	__out				boolean_t *all_mulcst);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_multicast_list_set(
 	__in				efx_nic_t *enp,
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				int count);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_filter_default_rxq_set(
 	__in		efx_nic_t *enp,
 	__in		efx_rxq_t *erp,
 	__in		boolean_t using_rss);
 
+LIBEFX_API
 extern			void
 efx_mac_filter_default_rxq_clear(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_drain(
 	__in		efx_nic_t *enp,
 	__in		boolean_t enabled);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_up(
 	__in		efx_nic_t *enp,
@@ -579,12 +620,14 @@ efx_mac_up(
 #define	EFX_FCNTL_RESPOND	0x00000001
 #define	EFX_FCNTL_GENERATE	0x00000002
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_fcntl_set(
 	__in		efx_nic_t *enp,
 	__in		unsigned int fcntl,
 	__in		boolean_t autoneg);
 
+LIBEFX_API
 extern			void
 efx_mac_fcntl_get(
 	__in		efx_nic_t *enp,
@@ -596,6 +639,7 @@ efx_mac_fcntl_get(
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern	__checkReturn			const char *
 efx_mac_stat_name(
 	__in				efx_nic_t *enp,
@@ -617,6 +661,7 @@ efx_mac_stat_name(
  * returned. EFX_MAC_STATS_MASK_NPAGES multiplied by size of the page
  * (which is sizeof (uint32_t)) is sufficient.
  */
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_stats_get_mask(
 	__in				efx_nic_t *enp,
@@ -628,6 +673,7 @@ efx_mac_stats_get_mask(
 	    (1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1))))
 
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_stats_clear(
 	__in				efx_nic_t *enp);
@@ -645,11 +691,13 @@ efx_mac_stats_clear(
  * Thus, drivers should zero this buffer before use, so that not-understood
  * statistics read back as zero.
  */
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_stats_upload(
 	__in				efx_nic_t *enp,
 	__in				efsys_mem_t *esmp);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_stats_periodic(
 	__in				efx_nic_t *enp,
@@ -657,6 +705,7 @@ efx_mac_stats_periodic(
 	__in				uint16_t period_ms,
 	__in				boolean_t events);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mac_stats_update(
 	__in				efx_nic_t *enp,
@@ -678,12 +727,14 @@ typedef enum efx_mon_type_e {
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern		const char *
 efx_mon_name(
 	__in	efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_NAMES */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mon_init(
 	__in		efx_nic_t *enp);
@@ -824,11 +875,13 @@ typedef enum efx_mon_stat_portmask_e {
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern					const char *
 efx_mon_stat_name(
 	__in				efx_nic_t *enp,
 	__in				efx_mon_stat_t id);
 
+LIBEFX_API
 extern					const char *
 efx_mon_stat_description(
 	__in				efx_nic_t *enp,
@@ -836,27 +889,32 @@ efx_mon_stat_description(
 
 #endif	/* EFSYS_OPT_NAMES */
 
+LIBEFX_API
 extern	__checkReturn			boolean_t
 efx_mon_mcdi_to_efx_stat(
 	__in				int mcdi_index,
 	__out				efx_mon_stat_t *statp);
 
+LIBEFX_API
 extern	__checkReturn			boolean_t
 efx_mon_get_stat_unit(
 	__in				efx_mon_stat_t stat,
 	__out				efx_mon_stat_unit_t *unitp);
 
+LIBEFX_API
 extern	__checkReturn			boolean_t
 efx_mon_get_stat_portmap(
 	__in				efx_mon_stat_t stat,
 	__out				efx_mon_stat_portmask_t *maskp);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mon_stats_update(
 	__in				efx_nic_t *enp,
 	__in				efsys_mem_t *esmp,
 	__inout_ecount(EFX_MON_NSTATS)	efx_mon_stat_value_t *values);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mon_limits_update(
 	__in				efx_nic_t *enp,
@@ -864,12 +922,14 @@ efx_mon_limits_update(
 
 #endif	/* EFSYS_OPT_MON_STATS */
 
+LIBEFX_API
 extern		void
 efx_mon_fini(
 	__in	efx_nic_t *enp);
 
 /* PHY */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_verify(
 	__in		efx_nic_t *enp);
@@ -884,6 +944,7 @@ typedef enum efx_phy_led_mode_e {
 	EFX_PHY_LED_NMODES
 } efx_phy_led_mode_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_led_set(
 	__in	efx_nic_t *enp,
@@ -891,6 +952,7 @@ efx_phy_led_set(
 
 #endif	/* EFSYS_OPT_PHY_LED_CONTROL */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_port_init(
 	__in		efx_nic_t *enp);
@@ -947,11 +1009,13 @@ typedef enum efx_loopback_kind_e {
 	EFX_LOOPBACK_NKINDS
 } efx_loopback_kind_t;
 
+LIBEFX_API
 extern			void
 efx_loopback_mask(
 	__in	efx_loopback_kind_t loopback_kind,
 	__out	efx_qword_t *maskp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_port_loopback_set(
 	__in	efx_nic_t *enp,
@@ -960,6 +1024,7 @@ efx_port_loopback_set(
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern	__checkReturn	const char *
 efx_loopback_type_name(
 	__in		efx_nic_t *enp,
@@ -969,11 +1034,13 @@ efx_loopback_type_name(
 
 #endif	/* EFSYS_OPT_LOOPBACK */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_port_poll(
 	__in		efx_nic_t *enp,
 	__out_opt	efx_link_mode_t	*link_modep);
 
+LIBEFX_API
 extern		void
 efx_port_fini(
 	__in	efx_nic_t *enp);
@@ -1009,22 +1076,26 @@ typedef enum efx_phy_cap_type_e {
 #define	EFX_PHY_CAP_DEFAULT	0x00000001
 #define	EFX_PHY_CAP_PERM	0x00000002
 
+LIBEFX_API
 extern		void
 efx_phy_adv_cap_get(
 	__in		efx_nic_t *enp,
 	__in		uint32_t flag,
 	__out		uint32_t *maskp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_adv_cap_set(
 	__in		efx_nic_t *enp,
 	__in		uint32_t mask);
 
+LIBEFX_API
 extern			void
 efx_phy_lp_cap_get(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *maskp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_oui_get(
 	__in		efx_nic_t *enp,
@@ -1048,6 +1119,7 @@ typedef enum efx_phy_media_type_e {
  * the module, then this will be the media type of the module.
  * Otherwise it will be the media type of the port.
  */
+LIBEFX_API
 extern			void
 efx_phy_media_type_get(
 	__in		efx_nic_t *enp,
@@ -1080,6 +1152,7 @@ efx_phy_media_type_get(
 #define	EFX_PHY_MEDIA_INFO_MAX_OFFSET		0x100
 
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_phy_module_get_info(
 	__in			efx_nic_t *enp,
@@ -1145,6 +1218,7 @@ typedef enum efx_phy_stat_e {
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern					const char *
 efx_phy_stat_name(
 	__in				efx_nic_t *enp,
@@ -1154,6 +1228,7 @@ efx_phy_stat_name(
 
 #define	EFX_PHY_STATS_SIZE 0x100
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_phy_stats_update(
 	__in				efx_nic_t *enp,
@@ -1217,15 +1292,18 @@ typedef enum efx_bist_value_e {
 	EFX_BIST_NVALUES,
 } efx_bist_value_t;
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_bist_enable_offline(
 	__in			efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_bist_start(
 	__in			efx_nic_t *enp,
 	__in			efx_bist_type_t type);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_bist_poll(
 	__in			efx_nic_t *enp,
@@ -1235,6 +1313,7 @@ efx_bist_poll(
 	__out_ecount_opt(count)	unsigned long *valuesp,
 	__in			size_t count);
 
+LIBEFX_API
 extern				void
 efx_bist_stop(
 	__in			efx_nic_t *enp,
@@ -1446,6 +1525,7 @@ typedef struct efx_nic_cfg_s {
 
 #define	EFX_PCI_VF_PARENT(_encp)	((_encp)->enc_pf)
 
+LIBEFX_API
 extern			const efx_nic_cfg_t *
 efx_nic_cfg_get(
 	__in		const efx_nic_t *enp);
@@ -1470,6 +1550,7 @@ typedef struct efx_nic_fw_info_s {
 	uint16_t	enfi_tx_dpcpu_fw_id;
 } efx_nic_fw_info_t;
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nic_get_fw_version(
 	__in			efx_nic_t *enp,
@@ -1491,6 +1572,7 @@ typedef struct efx_drv_limits_s {
 	uint32_t	edl_max_pio_alloc_count;
 } efx_drv_limits_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_set_drv_limits(
 	__inout		efx_nic_t *enp,
@@ -1503,6 +1585,7 @@ efx_nic_set_drv_limits(
  * should be advertised. It is valid to set the version string
  * only before efx_nic_probe() is called.
  */
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_set_drv_version(
 	__inout			efx_nic_t *enp,
@@ -1514,6 +1597,7 @@ typedef enum efx_nic_region_e {
 	EFX_REGION_PIO_WRITE_VI,	/* Memory BAR WC mapping */
 } efx_nic_region_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_get_bar_region(
 	__in		efx_nic_t *enp,
@@ -1521,6 +1605,7 @@ efx_nic_get_bar_region(
 	__out		uint32_t *offsetp,
 	__out		size_t *sizep);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_get_vi_pool(
 	__in		efx_nic_t *enp,
@@ -1550,33 +1635,39 @@ typedef struct efx_vpd_value_s {
 
 #define	EFX_VPD_KEYWORD(x, y) ((x) | ((y) << 8))
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_init(
 	__in			efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_size(
 	__in			efx_nic_t *enp,
 	__out			size_t *sizep);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_read(
 	__in			efx_nic_t *enp,
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_verify(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_reinit(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_get(
 	__in			efx_nic_t *enp,
@@ -1584,6 +1675,7 @@ efx_vpd_get(
 	__in			size_t size,
 	__inout			efx_vpd_value_t *evvp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_set(
 	__in			efx_nic_t *enp,
@@ -1591,6 +1683,7 @@ efx_vpd_set(
 	__in			size_t size,
 	__in			efx_vpd_value_t *evvp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_next(
 	__in			efx_nic_t *enp,
@@ -1599,12 +1692,14 @@ efx_vpd_next(
 	__out			efx_vpd_value_t *evvp,
 	__inout			unsigned int *contp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_vpd_write(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern				void
 efx_vpd_fini(
 	__in			efx_nic_t *enp);
@@ -1648,42 +1743,49 @@ typedef struct efx_nvram_info_s {
 
 #define	EFX_NVRAM_FLAG_READ_ONLY	(1 << 0)
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_init(
 	__in			efx_nic_t *enp);
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_test(
 	__in			efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_size(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out			size_t *sizep);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_info(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out			efx_nvram_info_t *enip);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_rw_start(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out_opt		size_t *pref_chunkp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_rw_finish(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out_opt		uint32_t *verify_resultp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_get_version(
 	__in			efx_nic_t *enp,
@@ -1691,6 +1793,7 @@ efx_nvram_get_version(
 	__out			uint32_t *subtypep,
 	__out_ecount(4)		uint16_t version[4]);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_read_chunk(
 	__in			efx_nic_t *enp,
@@ -1699,6 +1802,7 @@ efx_nvram_read_chunk(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_read_backup(
 	__in			efx_nic_t *enp,
@@ -1707,12 +1811,14 @@ efx_nvram_read_backup(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_set_version(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__in_ecount(4)		uint16_t version[4]);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_validate(
 	__in			efx_nic_t *enp,
@@ -1720,11 +1826,13 @@ efx_nvram_validate(
 	__in_bcount(partn_size)	caddr_t partn_data,
 	__in			size_t partn_size);
 
+LIBEFX_API
 extern	 __checkReturn		efx_rc_t
 efx_nvram_erase(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_nvram_write_chunk(
 	__in			efx_nic_t *enp,
@@ -1733,6 +1841,7 @@ efx_nvram_write_chunk(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_API
 extern				void
 efx_nvram_fini(
 	__in			efx_nic_t *enp);
@@ -1742,6 +1851,7 @@ efx_nvram_fini(
 #if EFSYS_OPT_BOOTCFG
 
 /* Report size and offset of bootcfg sector in NVRAM partition. */
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_bootcfg_sector_info(
 	__in			efx_nic_t *enp,
@@ -1754,6 +1864,7 @@ efx_bootcfg_sector_info(
  * Copy bootcfg sector data to a target buffer which may differ in size.
  * Optionally corrects format errors in source buffer.
  */
+LIBEFX_API
 extern				efx_rc_t
 efx_bootcfg_copy_sector(
 	__in			efx_nic_t *enp,
@@ -1764,12 +1875,14 @@ efx_bootcfg_copy_sector(
 	__in			size_t data_size,
 	__in			boolean_t handle_format_errors);
 
+LIBEFX_API
 extern				efx_rc_t
 efx_bootcfg_read(
 	__in			efx_nic_t *enp,
 	__out_bcount(size)	uint8_t *data,
 	__in			size_t size);
 
+LIBEFX_API
 extern				efx_rc_t
 efx_bootcfg_write(
 	__in			efx_nic_t *enp,
@@ -1807,17 +1920,20 @@ efx_bootcfg_write(
 #define	EFX_DHCP_ENCAP_OPT(encapsulator, encapsulated) \
   (uint16_t)(((encapsulator) << 8) | (encapsulated))
 
+LIBEFX_API
 extern	__checkReturn		uint8_t
 efx_dhcp_csum(
 	__in_bcount(size)	uint8_t const *data,
 	__in			size_t size);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_dhcp_verify(
 	__in_bcount(size)	uint8_t const *data,
 	__in			size_t size,
 	__out_opt		size_t *usedp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_dhcp_find_tag(
 	__in_bcount(buffer_length)	uint8_t *bufferp,
@@ -1826,6 +1942,7 @@ efx_dhcp_find_tag(
 	__deref_out			uint8_t **valuepp,
 	__out				size_t *value_lengthp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_dhcp_find_end(
 	__in_bcount(buffer_length)	uint8_t *bufferp,
@@ -1833,12 +1950,14 @@ efx_dhcp_find_end(
 	__deref_out			uint8_t **endpp);
 
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_dhcp_delete_tag(
 	__inout_bcount(buffer_length)	uint8_t *bufferp,
 	__in				size_t buffer_length,
 	__in				uint16_t opt);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_dhcp_add_tag(
 	__inout_bcount(buffer_length)	uint8_t *bufferp,
@@ -1847,6 +1966,7 @@ efx_dhcp_add_tag(
 	__in_bcount_opt(value_length)	uint8_t *valuep,
 	__in				size_t value_length);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_dhcp_update_tag(
 	__inout_bcount(buffer_length)	uint8_t *bufferp,
@@ -1931,12 +2051,14 @@ typedef struct efx_image_info_s {
 	efx_image_header_t *	eii_headerp;
 } efx_image_info_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_check_reflash_image(
 	__in		void			*bufferp,
 	__in		uint32_t		buffer_size,
 	__out		efx_image_info_t	*infop);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_build_signed_image_write_buffer(
 	__out_bcount(buffer_size)
@@ -1965,6 +2087,7 @@ typedef			void
 	__in		boolean_t negate,
 	__out		efx_qword_t *eqp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_sram_test(
 	__in		efx_nic_t *enp,
@@ -1972,6 +2095,7 @@ efx_sram_test(
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_sram_buf_tbl_set(
 	__in		efx_nic_t *enp,
@@ -1979,6 +2103,7 @@ efx_sram_buf_tbl_set(
 	__in		efsys_mem_t *esmp,
 	__in		size_t n);
 
+LIBEFX_API
 extern		void
 efx_sram_buf_tbl_clear(
 	__in	efx_nic_t *enp,
@@ -2042,19 +2167,23 @@ typedef enum efx_ev_qstat_e {
 
 #endif	/* EFSYS_OPT_QSTATS */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_ev_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern		void
 efx_ev_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	size_t
 efx_evq_size(
 	__in	const efx_nic_t *enp,
 	__in	unsigned int ndescs);
 
+LIBEFX_API
 extern	__checkReturn	unsigned int
 efx_evq_nbufs(
 	__in	const efx_nic_t *enp,
@@ -2079,6 +2208,7 @@ efx_evq_nbufs(
  */
 #define	EFX_EVQ_FLAGS_NO_CONT_EV	(0x10)
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_ev_qcreate(
 	__in		efx_nic_t *enp,
@@ -2090,6 +2220,7 @@ efx_ev_qcreate(
 	__in		uint32_t flags,
 	__deref_out	efx_evq_t **eepp);
 
+LIBEFX_API
 extern		void
 efx_ev_qpost(
 	__in		efx_evq_t *eep,
@@ -2276,6 +2407,7 @@ typedef struct efx_ev_callbacks_s {
 #endif	/* EFSYS_OPT_MAC_STATS */
 } efx_ev_callbacks_t;
 
+LIBEFX_API
 extern	__checkReturn	boolean_t
 efx_ev_qpending(
 	__in		efx_evq_t *eep,
@@ -2283,6 +2415,7 @@ efx_ev_qpending(
 
 #if EFSYS_OPT_EV_PREFETCH
 
+LIBEFX_API
 extern			void
 efx_ev_qprefetch(
 	__in		efx_evq_t *eep,
@@ -2290,6 +2423,7 @@ efx_ev_qprefetch(
 
 #endif	/* EFSYS_OPT_EV_PREFETCH */
 
+LIBEFX_API
 extern			void
 efx_ev_qpoll(
 	__in		efx_evq_t *eep,
@@ -2297,17 +2431,20 @@ efx_ev_qpoll(
 	__in		const efx_ev_callbacks_t *eecp,
 	__in_opt	void *arg);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_ev_usecs_to_ticks(
 	__in		efx_nic_t *enp,
 	__in		unsigned int usecs,
 	__out		unsigned int *ticksp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_ev_qmoderate(
 	__in		efx_evq_t *eep,
 	__in		unsigned int us);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_ev_qprime(
 	__in		efx_evq_t *eep,
@@ -2317,6 +2454,7 @@ efx_ev_qprime(
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern		const char *
 efx_ev_qstat_name(
 	__in	efx_nic_t *enp,
@@ -2324,6 +2462,7 @@ efx_ev_qstat_name(
 
 #endif	/* EFSYS_OPT_NAMES */
 
+LIBEFX_API
 extern					void
 efx_ev_qstats_update(
 	__in				efx_evq_t *eep,
@@ -2331,21 +2470,25 @@ efx_ev_qstats_update(
 
 #endif	/* EFSYS_OPT_QSTATS */
 
+LIBEFX_API
 extern		void
 efx_ev_qdestroy(
 	__in	efx_evq_t *eep);
 
 /* RX */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_init(
 	__inout		efx_nic_t *enp);
 
+LIBEFX_API
 extern		void
 efx_rx_fini(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_RX_SCATTER
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scatter_enable(
 	__in		efx_nic_t *enp,
@@ -2485,6 +2628,7 @@ typedef enum efx_rx_scale_context_type_e {
  */
 #define	EFX_RX_HASH_NFLAGS	(EFX_RX_NCLASSES * EFX_RX_CLASS_HASH_NTUPLES)
 
+LIBEFX_API
 extern	__checkReturn				efx_rc_t
 efx_rx_scale_hash_flags_get(
 	__in					efx_nic_t *enp,
@@ -2493,17 +2637,20 @@ efx_rx_scale_hash_flags_get(
 	__in					unsigned int max_nflags,
 	__out					unsigned int *nflagsp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_hash_default_support_get(
 	__in		efx_nic_t *enp,
 	__out		efx_rx_hash_support_t *supportp);
 
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_default_support_get(
 	__in		efx_nic_t *enp,
 	__out		efx_rx_scale_context_type_t *typep);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_context_alloc(
 	__in		efx_nic_t *enp,
@@ -2511,11 +2658,13 @@ efx_rx_scale_context_alloc(
 	__in		uint32_t num_queues,
 	__out		uint32_t *rss_contextp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_context_free(
 	__in		efx_nic_t *enp,
 	__in		uint32_t rss_context);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_mode_set(
 	__in	efx_nic_t *enp,
@@ -2524,6 +2673,7 @@ efx_rx_scale_mode_set(
 	__in	efx_rx_hash_type_t type,
 	__in	boolean_t insert);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_tbl_set(
 	__in		efx_nic_t *enp,
@@ -2531,6 +2681,7 @@ efx_rx_scale_tbl_set(
 	__in_ecount(n)	unsigned int *table,
 	__in		size_t n);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_scale_key_set(
 	__in		efx_nic_t *enp,
@@ -2538,6 +2689,7 @@ efx_rx_scale_key_set(
 	__in_ecount(n)	uint8_t *key,
 	__in		size_t n);
 
+LIBEFX_API
 extern	__checkReturn	uint32_t
 efx_pseudo_hdr_hash_get(
 	__in		efx_rxq_t *erp,
@@ -2546,17 +2698,20 @@ efx_pseudo_hdr_hash_get(
 
 #endif	/* EFSYS_OPT_RX_SCALE */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_pseudo_hdr_pkt_length_get(
 	__in		efx_rxq_t *erp,
 	__in		uint8_t *buffer,
 	__out		uint16_t *pkt_lengthp);
 
+LIBEFX_API
 extern	__checkReturn	size_t
 efx_rxq_size(
 	__in	const efx_nic_t *enp,
 	__in	unsigned int ndescs);
 
+LIBEFX_API
 extern	__checkReturn	unsigned int
 efx_rxq_nbufs(
 	__in	const efx_nic_t *enp,
@@ -2587,6 +2742,7 @@ typedef enum efx_rxq_type_e {
  */
 #define	EFX_RXQ_FLAG_INNER_CLASSES	0x2
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_qcreate(
 	__in		efx_nic_t *enp,
@@ -2609,6 +2765,7 @@ efx_rx_qcreate(
 #define	EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K	(128U * 1024)
 #define	EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K	(64U * 1024)
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_qcreate_packed_stream(
 	__in		efx_nic_t *enp,
@@ -2627,6 +2784,7 @@ efx_rx_qcreate_packed_stream(
 /* Maximum head-of-line block timeout in nanoseconds */
 #define	EFX_RXQ_ES_SUPER_BUFFER_HOL_BLOCK_MAX	(400U * 1000 * 1000)
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_qcreate_es_super_buffer(
 	__in		efx_nic_t *enp,
@@ -2654,6 +2812,7 @@ typedef struct efx_desc_s {
 	efx_qword_t ed_eq;
 } efx_desc_t;
 
+LIBEFX_API
 extern				void
 efx_rx_qpost(
 	__in			efx_rxq_t *erp,
@@ -2663,6 +2822,7 @@ efx_rx_qpost(
 	__in			unsigned int completed,
 	__in			unsigned int added);
 
+LIBEFX_API
 extern		void
 efx_rx_qpush(
 	__in	efx_rxq_t *erp,
@@ -2671,10 +2831,12 @@ efx_rx_qpush(
 
 #if EFSYS_OPT_RX_PACKED_STREAM
 
+LIBEFX_API
 extern			void
 efx_rx_qpush_ps_credits(
 	__in		efx_rxq_t *erp);
 
+LIBEFX_API
 extern	__checkReturn	uint8_t *
 efx_rx_qps_packet_info(
 	__in		efx_rxq_t *erp,
@@ -2686,14 +2848,17 @@ efx_rx_qps_packet_info(
 	__out		uint32_t *timestamp);
 #endif
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_rx_qflush(
 	__in	efx_rxq_t *erp);
 
+LIBEFX_API
 extern		void
 efx_rx_qenable(
 	__in	efx_rxq_t *erp);
 
+LIBEFX_API
 extern		void
 efx_rx_qdestroy(
 	__in	efx_rxq_t *erp);
@@ -2715,19 +2880,23 @@ typedef enum efx_tx_qstat_e {
 
 #endif	/* EFSYS_OPT_QSTATS */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern		void
 efx_tx_fini(
 	__in	efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	size_t
 efx_txq_size(
 	__in	const efx_nic_t *enp,
 	__in	unsigned int ndescs);
 
+LIBEFX_API
 extern	__checkReturn	unsigned int
 efx_txq_nbufs(
 	__in	const efx_nic_t *enp,
@@ -2741,6 +2910,7 @@ efx_txq_nbufs(
 #define	EFX_TXQ_CKSUM_INNER_IPV4	0x0008
 #define	EFX_TXQ_CKSUM_INNER_TCPUDP	0x0010
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qcreate(
 	__in		efx_nic_t *enp,
@@ -2754,6 +2924,7 @@ efx_tx_qcreate(
 	__deref_out	efx_txq_t **etpp,
 	__out		unsigned int *addedp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_tx_qpost(
 	__in			efx_txq_t *etp,
@@ -2762,33 +2933,40 @@ efx_tx_qpost(
 	__in			unsigned int completed,
 	__inout			unsigned int *addedp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qpace(
 	__in		efx_txq_t *etp,
 	__in		unsigned int ns);
 
+LIBEFX_API
 extern			void
 efx_tx_qpush(
 	__in		efx_txq_t *etp,
 	__in		unsigned int added,
 	__in		unsigned int pushed);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qflush(
 	__in		efx_txq_t *etp);
 
+LIBEFX_API
 extern			void
 efx_tx_qenable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qpio_enable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_API
 extern			void
 efx_tx_qpio_disable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qpio_write(
 	__in			efx_txq_t *etp,
@@ -2796,6 +2974,7 @@ efx_tx_qpio_write(
 	__in			size_t buf_length,
 	__in			size_t pio_buf_offset);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qpio_post(
 	__in			efx_txq_t *etp,
@@ -2803,6 +2982,7 @@ efx_tx_qpio_post(
 	__in			unsigned int completed,
 	__inout			unsigned int *addedp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tx_qdesc_post(
 	__in		efx_txq_t *etp,
@@ -2811,6 +2991,7 @@ efx_tx_qdesc_post(
 	__in		unsigned int completed,
 	__inout		unsigned int *addedp);
 
+LIBEFX_API
 extern	void
 efx_tx_qdesc_dma_create(
 	__in	efx_txq_t *etp,
@@ -2819,6 +3000,7 @@ efx_tx_qdesc_dma_create(
 	__in	boolean_t eop,
 	__out	efx_desc_t *edp);
 
+LIBEFX_API
 extern	void
 efx_tx_qdesc_tso_create(
 	__in	efx_txq_t *etp,
@@ -2833,6 +3015,7 @@ efx_tx_qdesc_tso_create(
 /* Maximum number of DMA segments per TSO packet (not superframe) */
 #define	EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX	24
 
+LIBEFX_API
 extern	void
 efx_tx_qdesc_tso2_create(
 	__in			efx_txq_t *etp,
@@ -2843,12 +3026,14 @@ efx_tx_qdesc_tso2_create(
 	__out_ecount(count)	efx_desc_t *edp,
 	__in			int count);
 
+LIBEFX_API
 extern	void
 efx_tx_qdesc_vlantci_create(
 	__in	efx_txq_t *etp,
 	__in	uint16_t tci,
 	__out	efx_desc_t *edp);
 
+LIBEFX_API
 extern	void
 efx_tx_qdesc_checksum_create(
 	__in	efx_txq_t *etp,
@@ -2859,6 +3044,7 @@ efx_tx_qdesc_checksum_create(
 
 #if EFSYS_OPT_NAMES
 
+LIBEFX_API
 extern		const char *
 efx_tx_qstat_name(
 	__in	efx_nic_t *etp,
@@ -2866,6 +3052,7 @@ efx_tx_qstat_name(
 
 #endif	/* EFSYS_OPT_NAMES */
 
+LIBEFX_API
 extern					void
 efx_tx_qstats_update(
 	__in				efx_txq_t *etp,
@@ -2873,6 +3060,7 @@ efx_tx_qstats_update(
 
 #endif	/* EFSYS_OPT_QSTATS */
 
+LIBEFX_API
 extern		void
 efx_tx_qdestroy(
 	__in	efx_txq_t *etp);
@@ -3004,28 +3192,34 @@ typedef struct efx_filter_spec_s {
 #define	EFX_FILTER_SPEC_RX_DMAQ_ID_DROP		0xfff
 #define	EFX_FILTER_SPEC_VID_UNSPEC		0xffff
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_filter_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_insert(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_remove(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_restore(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_supported_filters(
 	__in				efx_nic_t *enp,
@@ -3033,6 +3227,7 @@ efx_filter_supported_filters(
 	__in				size_t buffer_length,
 	__out				size_t *list_lengthp);
 
+LIBEFX_API
 extern			void
 efx_filter_spec_init_rx(
 	__out		efx_filter_spec_t *spec,
@@ -3040,11 +3235,13 @@ efx_filter_spec_init_rx(
 	__in		efx_filter_flags_t flags,
 	__in		efx_rxq_t *erp);
 
+LIBEFX_API
 extern			void
 efx_filter_spec_init_tx(
 	__out		efx_filter_spec_t *spec,
 	__in		efx_txq_t *etp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_ipv4_local(
 	__inout		efx_filter_spec_t *spec,
@@ -3052,6 +3249,7 @@ efx_filter_spec_set_ipv4_local(
 	__in		uint32_t host,
 	__in		uint16_t port);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_ipv4_full(
 	__inout		efx_filter_spec_t *spec,
@@ -3061,21 +3259,25 @@ efx_filter_spec_set_ipv4_full(
 	__in		uint32_t rhost,
 	__in		uint16_t rport);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_eth_local(
 	__inout		efx_filter_spec_t *spec,
 	__in		uint16_t vid,
 	__in		const uint8_t *addr);
 
+LIBEFX_API
 extern			void
 efx_filter_spec_set_ether_type(
 	__inout		efx_filter_spec_t *spec,
 	__in		uint16_t ether_type);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_uc_def(
 	__inout		efx_filter_spec_t *spec);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_mc_def(
 	__inout		efx_filter_spec_t *spec);
@@ -3086,12 +3288,14 @@ typedef enum efx_filter_inner_frame_match_e {
 	EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_UCAST_DST
 } efx_filter_inner_frame_match_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_encap_type(
 	__inout		efx_filter_spec_t *spec,
 	__in		efx_tunnel_protocol_t encap_type,
 	__in		efx_filter_inner_frame_match_t inner_frame_match);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_vxlan(
 	__inout		efx_filter_spec_t *spec,
@@ -3099,6 +3303,7 @@ efx_filter_spec_set_vxlan(
 	__in		const uint8_t *inner_addr,
 	__in		const uint8_t *outer_addr);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_geneve(
 	__inout		efx_filter_spec_t *spec,
@@ -3106,6 +3311,7 @@ efx_filter_spec_set_geneve(
 	__in		const uint8_t *inner_addr,
 	__in		const uint8_t *outer_addr);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_nvgre(
 	__inout		efx_filter_spec_t *spec,
@@ -3114,6 +3320,7 @@ efx_filter_spec_set_nvgre(
 	__in		const uint8_t *outer_addr);
 
 #if EFSYS_OPT_RX_SCALE
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_filter_spec_set_rss_context(
 	__inout		efx_filter_spec_t *spec,
@@ -3123,12 +3330,14 @@ efx_filter_spec_set_rss_context(
 
 /* HASH */
 
+LIBEFX_API
 extern	__checkReturn		uint32_t
 efx_hash_dwords(
 	__in_ecount(count)	uint32_t const *input,
 	__in			size_t count,
 	__in			uint32_t init);
 
+LIBEFX_API
 extern	__checkReturn		uint32_t
 efx_hash_bytes(
 	__in_ecount(length)	uint8_t const *input,
@@ -3151,33 +3360,40 @@ typedef struct efx_key_stats_s {
 	uint32_t	eks_licensed_features_hi;
 } efx_key_stats_t;
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_init(
 	__in			efx_nic_t *enp);
 
+LIBEFX_API
 extern				void
 efx_lic_fini(
 	__in			efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	boolean_t
 efx_lic_check_support(
 	__in			efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_lic_update_licenses(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_lic_get_key_stats(
 	__in		efx_nic_t *enp,
 	__out		efx_key_stats_t *ksp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_lic_app_state(
 	__in		efx_nic_t *enp,
 	__in		uint64_t app_id,
 	__out		boolean_t *licensedp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_lic_get_id(
 	__in		efx_nic_t *enp,
@@ -3187,6 +3403,7 @@ efx_lic_get_id(
 	__out_opt	uint8_t *bufferp);
 
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_find_start(
 	__in			efx_nic_t *enp,
@@ -3195,6 +3412,7 @@ efx_lic_find_start(
 	__in			size_t buffer_size,
 	__out			uint32_t *startp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_find_end(
 	__in			efx_nic_t *enp,
@@ -3204,6 +3422,7 @@ efx_lic_find_end(
 	__in			uint32_t offset,
 	__out			uint32_t *endp);
 
+LIBEFX_API
 extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 efx_lic_find_key(
 	__in			efx_nic_t *enp,
@@ -3214,12 +3433,14 @@ efx_lic_find_key(
 	__out			uint32_t *startp,
 	__out			uint32_t *lengthp);
 
+LIBEFX_API
 extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 efx_lic_validate_key(
 	__in			efx_nic_t *enp,
 	__in_bcount(length)	caddr_t keyp,
 	__in			uint32_t length);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_read_key(
 	__in			efx_nic_t *enp,
@@ -3233,6 +3454,7 @@ efx_lic_read_key(
 	__in			size_t key_max_size,
 	__out			uint32_t *lengthp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_write_key(
 	__in			efx_nic_t *enp,
@@ -3244,6 +3466,7 @@ efx_lic_write_key(
 	__in			uint32_t length,
 	__out			uint32_t *lengthp);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_delete_key(
 	__in			efx_nic_t *enp,
@@ -3255,6 +3478,7 @@ efx_lic_delete_key(
 	__in			uint32_t end,
 	__out			uint32_t *deltap);
 
+LIBEFX_API
 extern	__checkReturn		efx_rc_t
 efx_lic_create_partition(
 	__in			efx_nic_t *enp,
@@ -3275,10 +3499,12 @@ efx_lic_finish_partition(
 
 #if EFSYS_OPT_TUNNEL
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tunnel_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_tunnel_fini(
 	__in		efx_nic_t *enp);
@@ -3290,18 +3516,21 @@ efx_tunnel_fini(
  * The UDP port/protocol list is global.
  */
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tunnel_config_udp_add(
 	__in		efx_nic_t *enp,
 	__in		uint16_t port /* host/cpu-endian */,
 	__in		efx_tunnel_protocol_t protocol);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tunnel_config_udp_remove(
 	__in		efx_nic_t *enp,
 	__in		uint16_t port /* host/cpu-endian */,
 	__in		efx_tunnel_protocol_t protocol);
 
+LIBEFX_API
 extern			void
 efx_tunnel_config_clear(
 	__in		efx_nic_t *enp);
@@ -3312,6 +3541,7 @@ efx_tunnel_config_clear(
  * EAGAIN is returned if hardware will be reset (datapath and managment CPU
  * reboot).
  */
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_tunnel_reconfigure(
 	__in		efx_nic_t *enp);
@@ -3339,11 +3569,13 @@ typedef enum efx_nic_fw_subvariant_e {
 	EFX_NIC_FW_SUBVARIANT_NTYPES
 } efx_nic_fw_subvariant_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_get_fw_subvariant(
 	__in		efx_nic_t *enp,
 	__out		efx_nic_fw_subvariant_t *subvariantp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_nic_set_fw_subvariant(
 	__in		efx_nic_t *enp,
@@ -3357,6 +3589,7 @@ typedef enum efx_phy_fec_type_e {
 	EFX_PHY_FEC_RS
 } efx_phy_fec_type_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_fec_type_get(
 	__in		efx_nic_t *enp,
@@ -3371,6 +3604,7 @@ typedef struct efx_phy_link_state_s {
 	efx_link_mode_t		epls_link_mode;
 } efx_phy_link_state_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_phy_link_state_get(
 	__in		efx_nic_t *enp,
@@ -3424,14 +3658,17 @@ typedef struct efx_vport_config_s {
 
 typedef	struct	efx_vswitch_s	efx_vswitch_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_evb_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_evb_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_evb_vswitch_create(
 	__in				efx_nic_t *enp,
@@ -3439,11 +3676,13 @@ efx_evb_vswitch_create(
 	__inout_ecount(num_vports)	efx_vport_config_t *vport_configp,
 	__deref_out			efx_vswitch_t **evpp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_evb_vswitch_destroy(
 	__in				efx_nic_t *enp,
 	__in				efx_vswitch_t *evp);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_evb_vport_mac_set(
 	__in				efx_nic_t *enp,
@@ -3451,6 +3690,7 @@ efx_evb_vport_mac_set(
 	__in				efx_vport_id_t vport_id,
 	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_evb_vport_vlan_set(
 	__in		efx_nic_t *enp,
@@ -3458,6 +3698,7 @@ efx_evb_vport_vlan_set(
 	__in		efx_vport_id_t vport_id,
 	__in		uint16_t vid);
 
+LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_evb_vport_reset(
 	__in				efx_nic_t *enp,
@@ -3467,6 +3708,7 @@ efx_evb_vport_reset(
 	__in				uint16_t vid,
 	__out				boolean_t *is_fn_resetp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_evb_vport_stats(
 	__in		efx_nic_t *enp,
@@ -3498,24 +3740,29 @@ typedef struct efx_proxy_cmd_params_s {
 	size_t		*response_size_actualp;
 } efx_proxy_cmd_params_t;
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern			void
 efx_proxy_auth_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_configure(
 	__in		efx_nic_t *enp,
 	__in		efx_proxy_auth_config_t *configp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_destroy(
 	__in		efx_nic_t *enp,
 	__in		uint32_t handled_privileges);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_complete_request(
 	__in		efx_nic_t *enp,
@@ -3523,11 +3770,13 @@ efx_proxy_auth_complete_request(
 	__in		uint32_t proxy_result,
 	__in		uint32_t handle);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_exec_cmd(
 	__in		efx_nic_t *enp,
 	__inout		efx_proxy_cmd_params_t *paramsp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_set_privilege_mask(
 	__in		efx_nic_t *enp,
@@ -3535,6 +3784,7 @@ efx_proxy_auth_set_privilege_mask(
 	__in		uint32_t mask,
 	__in		uint32_t value);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_privilege_mask_get(
 	__in		efx_nic_t *enp,
@@ -3542,6 +3792,7 @@ efx_proxy_auth_privilege_mask_get(
 	__in		uint32_t vf_index,
 	__out		uint32_t *maskp);
 
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_proxy_auth_privilege_modify(
 	__in		efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 5965247569..41300fd9b1 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -9,6 +9,15 @@
 
 #include "efsys.h"
 
+/*
+ * LIBEFX_* defines may be used to put API functions into dedicated code
+ * section if required by driver development framework and conventions.
+ */
+
+#ifndef LIBEFX_API
+# error "LIBEFX_API must be defined"
+#endif
+
 /*
  * Check that the efsys.h header in client code has a valid combination of
  * EFSYS_OPT_xxx options.
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/net/sfc/base/efx_mcdi.h
index d199060a41..42c84eb7d6 100644
--- a/drivers/net/sfc/base/efx_mcdi.h
+++ b/drivers/net/sfc/base/efx_mcdi.h
@@ -74,6 +74,7 @@ efx_mcdi_ev_cpl(
 	__in		int errcode);
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH
+LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_proxy_handle(
 	__in		efx_nic_t *enp,
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index c94e6c0b93..cc132d83bb 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -32,6 +32,9 @@
 extern "C" {
 #endif
 
+/* No specific decorations required since all functions are local now */
+#define LIBEFX_API
+
 #define EFSYS_HAS_UINT64 1
 #define EFSYS_USE_UINT64 1
 #define EFSYS_HAS_SSE2_M128 1
-- 
2.17.1



^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 03/17] net/sfc/base: decorate libefx internal extern functions
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 02/17] net/sfc/base: decorate libefx API functions Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 04/17] net/sfc: include header with debug helpers directly Andrew Rybchenko
                     ` (14 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

The decorator may be used in the future to instruct linker
to put it into dedicated sections or hide.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Reviewed-by: Mark Spender <mspender@xilinx.com>
Reviewed-by: Richard Houldsworth <rhouldsw@xilinx.com>
---
 drivers/net/sfc/base/ef10_impl.h     | 194 +++++++++++++++++++++++++++
 drivers/net/sfc/base/efx_check.h     |   4 +
 drivers/net/sfc/base/efx_impl.h      |  26 ++++
 drivers/net/sfc/base/efx_mcdi.h      |  28 ++++
 drivers/net/sfc/base/hunt_impl.h     |   1 +
 drivers/net/sfc/base/mcdi_mon.h      |   5 +
 drivers/net/sfc/base/medford2_impl.h |   1 +
 drivers/net/sfc/base/medford_impl.h  |   1 +
 drivers/net/sfc/base/siena_impl.h    |  60 +++++++++
 drivers/net/sfc/efsys.h              |   1 +
 10 files changed, 321 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 1f17fc2f69..da0ec7fab5 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -91,14 +91,17 @@ extern "C" {
 
 /* EV */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_ev_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_ev_qcreate(
 	__in		efx_nic_t *enp,
@@ -110,32 +113,38 @@ ef10_ev_qcreate(
 	__in		uint32_t flags,
 	__in		efx_evq_t *eep);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_qdestroy(
 	__in		efx_evq_t *eep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_ev_qprime(
 	__in		efx_evq_t *eep,
 	__in		unsigned int count);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_qpost(
 	__in	efx_evq_t *eep,
 	__in	uint16_t data);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_ev_qmoderate(
 	__in		efx_evq_t *eep,
 	__in		unsigned int us);
 
 #if EFSYS_OPT_QSTATS
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_qstats_update(
 	__in				efx_evq_t *eep,
 	__inout_ecount(EV_NQSTATS)	efsys_stat_t *stat);
 #endif /* EFSYS_OPT_QSTATS */
 
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_rxlabel_init(
 	__in		efx_evq_t *eep,
@@ -143,6 +152,7 @@ ef10_ev_rxlabel_init(
 	__in		unsigned int label,
 	__in		efx_rxq_type_t type);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_ev_rxlabel_fini(
 	__in		efx_evq_t *eep,
@@ -150,74 +160,90 @@ ef10_ev_rxlabel_fini(
 
 /* INTR */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_intr_init(
 	__in		efx_nic_t *enp,
 	__in		efx_intr_type_t type,
 	__in		efsys_mem_t *esmp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_enable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_disable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_disable_unlocked(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_intr_trigger(
 	__in		efx_nic_t *enp,
 	__in		unsigned int level);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_status_line(
 	__in		efx_nic_t *enp,
 	__out		boolean_t *fatalp,
 	__out		uint32_t *qmaskp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_status_message(
 	__in		efx_nic_t *enp,
 	__in		unsigned int message,
 	__out		boolean_t *fatalp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_fatal(
 	__in		efx_nic_t *enp);
+
+LIBEFX_INTERNAL
 extern			void
 ef10_intr_fini(
 	__in		efx_nic_t *enp);
 
 /* NIC */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_vadaptor_alloc(
 	__in		efx_nic_t *enp,
 	__in		uint32_t port_id);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_vadaptor_free(
 	__in		efx_nic_t *enp,
 	__in		uint32_t port_id);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_probe(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_set_drv_limits(
 	__inout		efx_nic_t *enp,
 	__in		efx_drv_limits_t *edlp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_get_vi_pool(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *vi_countp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_get_bar_region(
 	__in		efx_nic_t *enp,
@@ -225,34 +251,41 @@ ef10_nic_get_bar_region(
 	__out		uint32_t *offsetp,
 	__out		size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_reset(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	boolean_t
 ef10_nic_hw_unavailable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_nic_set_hw_unavailable(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_register_test(
 	__in		efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_INTERNAL
 extern			void
 ef10_nic_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_nic_unprobe(
 	__in		efx_nic_t *enp);
@@ -260,49 +293,59 @@ ef10_nic_unprobe(
 
 /* MAC */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_poll(
 	__in		efx_nic_t *enp,
 	__out		efx_link_mode_t *link_modep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_up(
 	__in		efx_nic_t *enp,
 	__out		boolean_t *mac_upp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_addr_set(
 	__in	efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_pdu_set(
 	__in	efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_pdu_get(
 	__in	efx_nic_t *enp,
 	__out	size_t *pdu);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_reconfigure(
 	__in	efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_multicast_list_set(
 	__in				efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_filter_default_rxq_set(
 	__in		efx_nic_t *enp,
 	__in		efx_rxq_t *erp,
 	__in		boolean_t using_rss);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_mac_filter_default_rxq_clear(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_LOOPBACK
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mac_loopback_set(
 	__in		efx_nic_t *enp,
@@ -313,12 +356,14 @@ ef10_mac_loopback_set(
 
 #if EFSYS_OPT_MAC_STATS
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 ef10_mac_stats_get_mask(
 	__in				efx_nic_t *enp,
 	__inout_bcount(mask_size)	uint32_t *maskp,
 	__in				size_t mask_size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 ef10_mac_stats_update(
 	__in				efx_nic_t *enp,
@@ -333,15 +378,18 @@ ef10_mac_stats_update(
 
 #if EFSYS_OPT_MCDI
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mcdi_init(
 	__in		efx_nic_t *enp,
 	__in		const efx_mcdi_transport_t *mtp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_mcdi_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_mcdi_send_request(
 	__in			efx_nic_t *enp,
@@ -350,10 +398,12 @@ ef10_mcdi_send_request(
 	__in_bcount(sdu_len)	void *sdup,
 	__in			size_t sdu_len);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	boolean_t
 ef10_mcdi_poll_response(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_mcdi_read_response(
 	__in			efx_nic_t *enp,
@@ -361,16 +411,19 @@ ef10_mcdi_read_response(
 	__in			size_t offset,
 	__in			size_t length);
 
+LIBEFX_INTERNAL
 extern			efx_rc_t
 ef10_mcdi_poll_reboot(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_mcdi_feature_supported(
 	__in		efx_nic_t *enp,
 	__in		efx_mcdi_feature_id_t id,
 	__out		boolean_t *supportedp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_mcdi_get_timeout(
 	__in		efx_nic_t *enp,
@@ -383,6 +436,7 @@ ef10_mcdi_get_timeout(
 
 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buf_read_tlv(
 	__in				efx_nic_t *enp,
@@ -392,6 +446,7 @@ ef10_nvram_buf_read_tlv(
 	__deref_out_bcount_opt(*sizep)	caddr_t *datap,
 	__out				size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buf_write_tlv(
 	__inout_bcount(partn_size)	caddr_t partn_data,
@@ -401,6 +456,7 @@ ef10_nvram_buf_write_tlv(
 	__in				size_t tag_size,
 	__out				size_t *total_lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_read_tlv(
 	__in				efx_nic_t *enp,
@@ -409,6 +465,7 @@ ef10_nvram_partn_read_tlv(
 	__deref_out_bcount_opt(*sizep)	caddr_t *datap,
 	__out				size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_write_tlv(
 	__in			efx_nic_t *enp,
@@ -417,6 +474,7 @@ ef10_nvram_partn_write_tlv(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_write_segment_tlv(
 	__in			efx_nic_t *enp,
@@ -426,11 +484,13 @@ ef10_nvram_partn_write_segment_tlv(
 	__in			size_t size,
 	__in			boolean_t all_segments);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_lock(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_unlock(
 	__in			efx_nic_t *enp,
@@ -443,36 +503,42 @@ ef10_nvram_partn_unlock(
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_test(
 	__in			efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_type_to_partn(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out			uint32_t *partnp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_size(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_info(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			efx_nvram_info_t * enip);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_rw_start(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			size_t *chunk_sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_read_mode(
 	__in			efx_nic_t *enp,
@@ -482,6 +548,7 @@ ef10_nvram_partn_read_mode(
 	__in			size_t size,
 	__in			uint32_t mode);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_read(
 	__in			efx_nic_t *enp,
@@ -490,6 +557,7 @@ ef10_nvram_partn_read(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_read_backup(
 	__in			efx_nic_t *enp,
@@ -498,6 +566,7 @@ ef10_nvram_partn_read_backup(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_erase(
 	__in			efx_nic_t *enp,
@@ -505,6 +574,7 @@ ef10_nvram_partn_erase(
 	__in			unsigned int offset,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_write(
 	__in			efx_nic_t *enp,
@@ -513,12 +583,14 @@ ef10_nvram_partn_write(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_rw_finish(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out_opt		uint32_t *verify_resultp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_get_version(
 	__in			efx_nic_t *enp,
@@ -526,12 +598,14 @@ ef10_nvram_partn_get_version(
 	__out			uint32_t *subtypep,
 	__out_ecount(4)		uint16_t version[4]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_partn_set_version(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__in_ecount(4)		uint16_t version[4]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_validate(
 	__in			uint32_t partn,
@@ -539,12 +613,14 @@ ef10_nvram_buffer_validate(
 				caddr_t bufferp,
 	__in			size_t buffer_size);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_nvram_buffer_init(
 	__out_bcount(buffer_size)
 				caddr_t bufferp,
 	__in			size_t buffer_size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_create(
 	__in			uint32_t partn_type,
@@ -552,6 +628,7 @@ ef10_nvram_buffer_create(
 				caddr_t bufferp,
 	__in			size_t buffer_size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_find_item_start(
 	__in_bcount(buffer_size)
@@ -559,6 +636,7 @@ ef10_nvram_buffer_find_item_start(
 	__in			size_t buffer_size,
 	__out			uint32_t *startp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_find_end(
 	__in_bcount(buffer_size)
@@ -567,6 +645,7 @@ ef10_nvram_buffer_find_end(
 	__in			uint32_t offset,
 	__out			uint32_t *endp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 ef10_nvram_buffer_find_item(
 	__in_bcount(buffer_size)
@@ -576,6 +655,7 @@ ef10_nvram_buffer_find_item(
 	__out			uint32_t *startp,
 	__out			uint32_t *lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_peek_item(
 	__in_bcount(buffer_size)
@@ -586,6 +666,7 @@ ef10_nvram_buffer_peek_item(
 	__out			uint32_t *lengthp,
 	__out			uint32_t *value_offsetp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_get_item(
 	__in_bcount(buffer_size)
@@ -599,6 +680,7 @@ ef10_nvram_buffer_get_item(
 	__in			size_t value_max_size,
 	__out			uint32_t *lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_insert_item(
 	__in_bcount(buffer_size)
@@ -610,6 +692,7 @@ ef10_nvram_buffer_insert_item(
 	__in			uint32_t length,
 	__out			uint32_t *lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_modify_item(
 	__in_bcount(buffer_size)
@@ -621,6 +704,7 @@ ef10_nvram_buffer_modify_item(
 	__in			uint32_t length,
 	__out			uint32_t *lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_delete_item(
 	__in_bcount(buffer_size)
@@ -630,6 +714,7 @@ ef10_nvram_buffer_delete_item(
 	__in			uint32_t length,
 	__in			uint32_t end);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_nvram_buffer_finish(
 	__in_bcount(buffer_size)
@@ -649,35 +734,42 @@ typedef struct ef10_link_state_s {
 	boolean_t		els_mac_up;
 } ef10_link_state_t;
 
+LIBEFX_INTERNAL
 extern			void
 ef10_phy_link_ev(
 	__in		efx_nic_t *enp,
 	__in		efx_qword_t *eqp,
 	__out		efx_link_mode_t *link_modep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_get_link(
 	__in		efx_nic_t *enp,
 	__out		ef10_link_state_t *elsp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_power(
 	__in		efx_nic_t *enp,
 	__in		boolean_t on);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_reconfigure(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_verify(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_oui_get(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *ouip);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_phy_link_state_get(
 	__in		efx_nic_t *enp,
@@ -685,6 +777,7 @@ ef10_phy_link_state_get(
 
 #if EFSYS_OPT_PHY_STATS
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 ef10_phy_stats_update(
 	__in				efx_nic_t *enp,
@@ -695,15 +788,18 @@ ef10_phy_stats_update(
 
 #if EFSYS_OPT_BIST
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_bist_enable_offline(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_bist_start(
 	__in			efx_nic_t *enp,
 	__in			efx_bist_type_t type);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_bist_poll(
 	__in			efx_nic_t *enp,
@@ -715,6 +811,7 @@ ef10_bist_poll(
 	unsigned long	*valuesp,
 	__in			size_t count);
 
+LIBEFX_INTERNAL
 extern				void
 ef10_bist_stop(
 	__in			efx_nic_t *enp,
@@ -724,14 +821,17 @@ ef10_bist_stop(
 
 /* TX */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_tx_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qcreate(
 	__in		efx_nic_t *enp,
@@ -745,10 +845,12 @@ ef10_tx_qcreate(
 	__in		efx_txq_t *etp,
 	__out		unsigned int *addedp);
 
+LIBEFX_INTERNAL
 extern		void
 ef10_tx_qdestroy(
 	__in		efx_txq_t *etp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_tx_qpost(
 	__in			efx_txq_t *etp,
@@ -757,6 +859,7 @@ ef10_tx_qpost(
 	__in			unsigned int completed,
 	__inout			unsigned int *addedp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_tx_qpush(
 	__in		efx_txq_t *etp,
@@ -764,10 +867,12 @@ ef10_tx_qpush(
 	__in		unsigned int pushed);
 
 #if EFSYS_OPT_RX_PACKED_STREAM
+LIBEFX_INTERNAL
 extern			void
 ef10_rx_qpush_ps_credits(
 	__in		efx_rxq_t *erp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	uint8_t *
 ef10_rx_qps_packet_info(
 	__in		efx_rxq_t *erp,
@@ -779,27 +884,33 @@ ef10_rx_qps_packet_info(
 	__out		uint32_t *timestamp);
 #endif
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qpace(
 	__in		efx_txq_t *etp,
 	__in		unsigned int ns);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qflush(
 	__in		efx_txq_t *etp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_tx_qenable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qpio_enable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_tx_qpio_disable(
 	__in		efx_txq_t *etp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qpio_write(
 	__in			efx_txq_t *etp,
@@ -807,6 +918,7 @@ ef10_tx_qpio_write(
 	__in			size_t buf_length,
 	__in			size_t pio_buf_offset);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qpio_post(
 	__in			efx_txq_t *etp,
@@ -814,6 +926,7 @@ ef10_tx_qpio_post(
 	__in			unsigned int completed,
 	__inout			unsigned int *addedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_tx_qdesc_post(
 	__in		efx_txq_t *etp,
@@ -822,6 +935,7 @@ ef10_tx_qdesc_post(
 	__in		unsigned int completed,
 	__inout		unsigned int *addedp);
 
+LIBEFX_INTERNAL
 extern	void
 ef10_tx_qdesc_dma_create(
 	__in	efx_txq_t *etp,
@@ -830,6 +944,7 @@ ef10_tx_qdesc_dma_create(
 	__in	boolean_t eop,
 	__out	efx_desc_t *edp);
 
+LIBEFX_INTERNAL
 extern	void
 ef10_tx_qdesc_tso_create(
 	__in	efx_txq_t *etp,
@@ -838,6 +953,7 @@ ef10_tx_qdesc_tso_create(
 	__in	uint8_t	 tcp_flags,
 	__out	efx_desc_t *edp);
 
+LIBEFX_INTERNAL
 extern	void
 ef10_tx_qdesc_tso2_create(
 	__in			efx_txq_t *etp,
@@ -848,12 +964,14 @@ ef10_tx_qdesc_tso2_create(
 	__out_ecount(count)	efx_desc_t *edp,
 	__in			int count);
 
+LIBEFX_INTERNAL
 extern	void
 ef10_tx_qdesc_vlantci_create(
 	__in	efx_txq_t *etp,
 	__in	uint16_t vlan_tci,
 	__out	efx_desc_t *edp);
 
+LIBEFX_INTERNAL
 extern	void
 ef10_tx_qdesc_checksum_create(
 	__in	efx_txq_t *etp,
@@ -862,6 +980,7 @@ ef10_tx_qdesc_checksum_create(
 
 #if EFSYS_OPT_QSTATS
 
+LIBEFX_INTERNAL
 extern			void
 ef10_tx_qstats_update(
 	__in				efx_txq_t *etp,
@@ -873,6 +992,7 @@ typedef uint32_t	efx_piobuf_handle_t;
 
 #define	EFX_PIOBUF_HANDLE_INVALID	((efx_piobuf_handle_t)-1)
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_pio_alloc(
 	__inout		efx_nic_t *enp,
@@ -882,18 +1002,21 @@ ef10_nic_pio_alloc(
 	__out		uint32_t *offsetp,
 	__out		size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_pio_free(
 	__inout		efx_nic_t *enp,
 	__in		uint32_t bufnum,
 	__in		uint32_t blknum);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_pio_link(
 	__inout		efx_nic_t *enp,
 	__in		uint32_t vi_index,
 	__in		efx_piobuf_handle_t handle);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_pio_unlink(
 	__inout		efx_nic_t *enp,
@@ -904,33 +1027,39 @@ ef10_nic_pio_unlink(
 
 #if EFSYS_OPT_VPD
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_init(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_size(
 	__in			efx_nic_t *enp,
 	__out			size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_read(
 	__in			efx_nic_t *enp,
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_verify(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_reinit(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_get(
 	__in			efx_nic_t *enp,
@@ -938,6 +1067,7 @@ ef10_vpd_get(
 	__in			size_t size,
 	__inout			efx_vpd_value_t *evvp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_set(
 	__in			efx_nic_t *enp,
@@ -945,6 +1075,7 @@ ef10_vpd_set(
 	__in			size_t size,
 	__in			efx_vpd_value_t *evvp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_vpd_next(
 	__in			efx_nic_t *enp,
@@ -953,12 +1084,14 @@ ef10_vpd_next(
 	__out			efx_vpd_value_t *evvp,
 	__inout			unsigned int *contp);
 
+LIBEFX_INTERNAL
 extern __checkReturn		efx_rc_t
 ef10_vpd_write(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern				void
 ef10_vpd_fini(
 	__in			efx_nic_t *enp);
@@ -968,11 +1101,13 @@ ef10_vpd_fini(
 
 /* RX */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_init(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_RX_SCATTER
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scatter_enable(
 	__in		efx_nic_t *enp,
@@ -982,6 +1117,7 @@ ef10_rx_scatter_enable(
 
 #if EFSYS_OPT_RX_SCALE
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scale_context_alloc(
 	__in		efx_nic_t *enp,
@@ -989,11 +1125,13 @@ ef10_rx_scale_context_alloc(
 	__in		uint32_t num_queues,
 	__out		uint32_t *rss_contextp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scale_context_free(
 	__in		efx_nic_t *enp,
 	__in		uint32_t rss_context);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scale_mode_set(
 	__in		efx_nic_t *enp,
@@ -1002,6 +1140,7 @@ ef10_rx_scale_mode_set(
 	__in		efx_rx_hash_type_t type,
 	__in		boolean_t insert);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scale_key_set(
 	__in		efx_nic_t *enp,
@@ -1009,6 +1148,7 @@ ef10_rx_scale_key_set(
 	__in_ecount(n)	uint8_t *key,
 	__in		size_t n);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_scale_tbl_set(
 	__in		efx_nic_t *enp,
@@ -1016,6 +1156,7 @@ ef10_rx_scale_tbl_set(
 	__in_ecount(n)	unsigned int *table,
 	__in		size_t n);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	uint32_t
 ef10_rx_prefix_hash(
 	__in		efx_nic_t *enp,
@@ -1024,12 +1165,14 @@ ef10_rx_prefix_hash(
 
 #endif /* EFSYS_OPT_RX_SCALE */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_prefix_pktlen(
 	__in		efx_nic_t *enp,
 	__in		uint8_t *buffer,
 	__out		uint16_t *lengthp);
 
+LIBEFX_INTERNAL
 extern				void
 ef10_rx_qpost(
 	__in			efx_rxq_t *erp,
@@ -1039,22 +1182,26 @@ ef10_rx_qpost(
 	__in			unsigned int completed,
 	__in			unsigned int added);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_rx_qpush(
 	__in		efx_rxq_t *erp,
 	__in		unsigned int added,
 	__inout		unsigned int *pushedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_qflush(
 	__in		efx_rxq_t *erp);
 
+LIBEFX_INTERNAL
 extern		void
 ef10_rx_qenable(
 	__in		efx_rxq_t *erp);
 
 union efx_rxq_type_data_u;
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_rx_qcreate(
 	__in		efx_nic_t *enp,
@@ -1069,10 +1216,12 @@ ef10_rx_qcreate(
 	__in		efx_evq_t *eep,
 	__in		efx_rxq_t *erp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_rx_qdestroy(
 	__in		efx_rxq_t *erp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_rx_fini(
 	__in		efx_nic_t *enp);
@@ -1134,29 +1283,35 @@ typedef struct ef10_filter_table_s {
 	uint32_t		eft_encap_filter_count;
 } ef10_filter_table_t;
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_filter_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_restore(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_add(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec,
 	__in		enum efx_filter_replacement_policy_e policy);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_delete(
 	__in		efx_nic_t *enp,
 	__inout		efx_filter_spec_t *spec);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_supported_filters(
 	__in				efx_nic_t *enp,
@@ -1164,6 +1319,7 @@ ef10_filter_supported_filters(
 	__in				size_t buffer_length,
 	__out				size_t *list_lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_filter_reconfigure(
 	__in				efx_nic_t *enp,
@@ -1175,18 +1331,21 @@ ef10_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
 extern		void
 ef10_filter_get_default_rxq(
 	__in		efx_nic_t *enp,
 	__out		efx_rxq_t **erpp,
 	__out		boolean_t *using_rss);
 
+LIBEFX_INTERNAL
 extern		void
 ef10_filter_default_rxq_set(
 	__in		efx_nic_t *enp,
 	__in		efx_rxq_t *erp,
 	__in		boolean_t using_rss);
 
+LIBEFX_INTERNAL
 extern		void
 ef10_filter_default_rxq_clear(
 	__in		efx_nic_t *enp);
@@ -1194,12 +1353,14 @@ ef10_filter_default_rxq_clear(
 
 #endif /* EFSYS_OPT_FILTER */
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 efx_mcdi_get_function_info(
 	__in				efx_nic_t *enp,
 	__out				uint32_t *pfp,
 	__out_opt			uint32_t *vfp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_privilege_mask(
 	__in			efx_nic_t *enp,
@@ -1207,11 +1368,13 @@ efx_mcdi_privilege_mask(
 	__in			uint32_t vf,
 	__out			uint32_t *maskp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_port_assignment(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *portp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_port_modes(
 	__in		efx_nic_t *enp,
@@ -1219,21 +1382,25 @@ efx_mcdi_get_port_modes(
 	__out_opt	uint32_t *current_modep,
 	__out_opt	uint32_t *default_modep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_nic_get_port_mode_bandwidth(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *bandwidth_mbpsp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_mac_address_pf(
 	__in			efx_nic_t *enp,
 	__out_ecount_opt(6)	uint8_t mac_addrp[6]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_mac_address_vf(
 	__in			efx_nic_t *enp,
 	__out_ecount_opt(6)	uint8_t mac_addrp[6]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_clock(
 	__in		efx_nic_t *enp,
@@ -1241,11 +1408,13 @@ efx_mcdi_get_clock(
 	__out		uint32_t *dpcpu_freqp);
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_rxdp_config(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *end_paddingp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_vector_cfg(
 	__in		efx_nic_t *enp,
@@ -1253,6 +1422,7 @@ efx_mcdi_get_vector_cfg(
 	__out_opt	uint32_t *pf_nvecp,
 	__out_opt	uint32_t *vf_nvecp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_get_privilege_mask(
 	__in			efx_nic_t *enp,
@@ -1260,12 +1430,14 @@ ef10_get_privilege_mask(
 
 #if EFSYS_OPT_FW_SUBVARIANT_AWARE
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_nic_global(
 	__in		efx_nic_t *enp,
 	__in		uint32_t key,
 	__out		uint32_t *valuep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_set_nic_global(
 	__in		efx_nic_t *enp,
@@ -1275,25 +1447,30 @@ efx_mcdi_set_nic_global(
 #endif	/* EFSYS_OPT_FW_SUBVARIANT_AWARE */
 
 #if EFSYS_OPT_EVB
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_evb_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vswitch_alloc(
 	__in		efx_nic_t *enp,
 	__out		efx_vswitch_id_t *vswitch_idp);
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vswitch_free(
 	__in		efx_nic_t *enp,
 	__in		efx_vswitch_id_t vswitch_id);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_alloc(
 	__in		efx_nic_t *enp,
@@ -1304,12 +1481,14 @@ ef10_evb_vport_alloc(
 	__out		efx_vport_id_t *vport_idp);
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_free(
 	__in		efx_nic_t *enp,
 	__in		efx_vswitch_id_t vswitch_id,
 	__in		efx_vport_id_t vport_id);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_mac_addr_add(
 	__in		efx_nic_t *enp,
@@ -1317,6 +1496,7 @@ ef10_evb_vport_mac_addr_add(
 	__in		efx_vport_id_t vport_id,
 	__in_ecount(6)	uint8_t *addrp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_mac_addr_del(
 	__in		efx_nic_t *enp,
@@ -1324,6 +1504,7 @@ ef10_evb_vport_mac_addr_del(
 	__in		efx_vport_id_t vport_id,
 	__in_ecount(6)	uint8_t *addrp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vadaptor_alloc(
 	__in		efx_nic_t *enp,
@@ -1331,12 +1512,14 @@ ef10_evb_vadaptor_alloc(
 	__in		efx_vport_id_t vport_id);
 
 
+LIBEFX_INTERNAL
 extern __checkReturn	efx_rc_t
 ef10_evb_vadaptor_free(
 	__in		efx_nic_t *enp,
 	__in		efx_vswitch_id_t vswitch_id,
 	__in		efx_vport_id_t vport_id);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_assign(
 	__in		efx_nic_t *enp,
@@ -1344,6 +1527,7 @@ ef10_evb_vport_assign(
 	__in		efx_vport_id_t vport_id,
 	__in		uint32_t vf_index);
 
+LIBEFX_INTERNAL
 extern	__checkReturn				efx_rc_t
 ef10_evb_vport_reconfigure(
 	__in					efx_nic_t *enp,
@@ -1353,6 +1537,7 @@ ef10_evb_vport_reconfigure(
 	__in_bcount_opt(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
 	__out_opt				boolean_t *fn_resetp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_evb_vport_stats(
 	__in		efx_nic_t *enp,
@@ -1363,14 +1548,17 @@ ef10_evb_vport_stats(
 #endif  /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_init(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 ef10_proxy_auth_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 ef10_proxy_auth_mc_config(
 	__in			efx_nic_t *enp,
@@ -1381,10 +1569,12 @@ ef10_proxy_auth_mc_config(
 	__in_ecount(op_count)	uint32_t *op_listp,
 	__in			size_t op_count);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_disable(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_privilege_modify(
 	__in		efx_nic_t *enp,
@@ -1394,6 +1584,7 @@ ef10_proxy_auth_privilege_modify(
 	__in		uint32_t add_privileges_mask,
 	__in		uint32_t remove_privileges_mask);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_set_privilege_mask(
 	__in		efx_nic_t *enp,
@@ -1401,6 +1592,7 @@ ef10_proxy_auth_set_privilege_mask(
 	__in		uint32_t mask,
 	__in		uint32_t value);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_complete_request(
 	__in		efx_nic_t *enp,
@@ -1408,11 +1600,13 @@ ef10_proxy_auth_complete_request(
 	__in		uint32_t proxy_result,
 	__in		uint32_t handle);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_exec_cmd(
 	__in		efx_nic_t *enp,
 	__inout		efx_proxy_cmd_params_t *paramsp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 ef10_proxy_auth_get_privilege_mask(
 	__in		efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 41300fd9b1..5a04a69e5f 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -18,6 +18,10 @@
 # error "LIBEFX_API must be defined"
 #endif
 
+#ifndef LIBEFX_INTERNAL
+# error "LIBEFX_INTERNAL must be defined"
+#endif
+
 /*
  * Check that the efsys.h header in client code has a valid combination of
  * EFSYS_OPT_xxx options.
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 70176760be..7d6a31d298 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -279,6 +279,7 @@ typedef struct efx_filter_ops_s {
 				   uint8_t const *, uint32_t);
 } efx_filter_ops_t;
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_filter_reconfigure(
 	__in				efx_nic_t *enp,
@@ -464,6 +465,7 @@ typedef struct efx_filter_s {
 
 #if EFSYS_OPT_SIENA
 
+LIBEFX_INTERNAL
 extern			void
 siena_filter_tbl_clear(
 	__in		efx_nic_t *enp,
@@ -566,6 +568,7 @@ typedef struct efx_vpd_ops_s {
 
 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_partitions(
 	__in			efx_nic_t *enp,
@@ -573,6 +576,7 @@ efx_mcdi_nvram_partitions(
 	__in			size_t size,
 	__out			unsigned int *npartnp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_metadata(
 	__in			efx_nic_t *enp,
@@ -582,17 +586,20 @@ efx_mcdi_nvram_metadata(
 	__out_bcount_opt(size)	char *descp,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_info(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			efx_nvram_info_t *eni);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_update_start(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_read(
 	__in			efx_nic_t *enp,
@@ -602,6 +609,7 @@ efx_mcdi_nvram_read(
 	__in			size_t size,
 	__in			uint32_t mode);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_erase(
 	__in			efx_nic_t *enp,
@@ -609,6 +617,7 @@ efx_mcdi_nvram_erase(
 	__in			uint32_t offset,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_write(
 	__in			efx_nic_t *enp,
@@ -620,6 +629,7 @@ efx_mcdi_nvram_write(
 #define	EFX_NVRAM_UPDATE_FLAGS_BACKGROUND	0x00000001
 #define	EFX_NVRAM_UPDATE_FLAGS_POLL		0x00000002
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_update_finish(
 	__in			efx_nic_t *enp,
@@ -630,6 +640,7 @@ efx_mcdi_nvram_update_finish(
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_nvram_test(
 	__in			efx_nic_t *enp,
@@ -713,6 +724,7 @@ typedef struct efx_evb_ops_s {
 						efx_vport_id_t, efsys_mem_t *);
 } efx_evb_ops_t;
 
+LIBEFX_INTERNAL
 extern __checkReturn	boolean_t
 efx_is_zero_eth_addr(
 	__in_bcount(EFX_MAC_ADDR_LEN)	const uint8_t *addrp);
@@ -1286,10 +1298,12 @@ struct efx_txq_s {
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mac_select(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	void
 efx_mac_multicast_hash_compute(
 	__in_ecount(6*count)		uint8_t const *addrs,
@@ -1297,10 +1311,12 @@ efx_mac_multicast_hash_compute(
 	__out				efx_oword_t *hash_low,
 	__out				efx_oword_t *hash_high);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_phy_probe(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 efx_phy_unprobe(
 	__in		efx_nic_t *enp);
@@ -1309,24 +1325,28 @@ efx_phy_unprobe(
 
 /* VPD utility functions */
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_vpd_hunk_length(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size,
 	__out			size_t *lengthp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_vpd_hunk_verify(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size,
 	__out_opt		boolean_t *cksummedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_vpd_hunk_reinit(
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size,
 	__in			boolean_t wantpid);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_vpd_hunk_get(
 	__in_bcount(size)	caddr_t data,
@@ -1336,6 +1356,7 @@ efx_vpd_hunk_get(
 	__out			unsigned int *payloadp,
 	__out			uint8_t *paylenp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 efx_vpd_hunk_next(
 	__in_bcount(size)		caddr_t data,
@@ -1346,6 +1367,7 @@ efx_vpd_hunk_next(
 	__out_opt			uint8_t *paylenp,
 	__inout				unsigned int *contp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_vpd_hunk_set(
 	__in_bcount(size)	caddr_t data,
@@ -1356,6 +1378,7 @@ efx_vpd_hunk_set(
 
 #if EFSYS_OPT_MCDI
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_set_workaround(
 	__in			efx_nic_t *enp,
@@ -1363,6 +1386,7 @@ efx_mcdi_set_workaround(
 	__in			boolean_t enabled,
 	__out_opt		uint32_t *flagsp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_get_workarounds(
 	__in			efx_nic_t *enp,
@@ -1391,6 +1415,7 @@ typedef enum efx_stats_action_e {
 	EFX_STATS_DISABLE,
 } efx_stats_action_t;
 
+LIBEFX_INTERNAL
 extern					efx_rc_t
 efx_mac_stats_mask_add_ranges(
 	__inout_bcount(mask_size)	uint32_t *maskp,
@@ -1398,6 +1423,7 @@ efx_mac_stats_mask_add_ranges(
 	__in_ecount(rng_count)		const struct efx_mac_stats_range *rngp,
 	__in				unsigned int rng_count);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_mac_stats(
 	__in		efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/net/sfc/base/efx_mcdi.h
index 42c84eb7d6..97ac8bf496 100644
--- a/drivers/net/sfc/base/efx_mcdi.h
+++ b/drivers/net/sfc/base/efx_mcdi.h
@@ -56,16 +56,19 @@ typedef struct efx_mcdi_iface_s {
 	uint32_t		emi_mc_reboot_status;
 } efx_mcdi_iface_t;
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_execute(
 	__in		efx_nic_t *enp,
 	__inout		efx_mcdi_req_t *emrp);
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_execute_quiet(
 	__in		efx_nic_t *enp,
 	__inout		efx_mcdi_req_t *emrp);
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_ev_cpl(
 	__in		efx_nic_t *enp,
@@ -81,6 +84,7 @@ efx_mcdi_get_proxy_handle(
 	__in		efx_mcdi_req_t *emrp,
 	__out		uint32_t *handlep);
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_ev_proxy_response(
 	__in		efx_nic_t *enp,
@@ -89,21 +93,25 @@ efx_mcdi_ev_proxy_response(
 #endif
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_ev_proxy_request(
 	__in		efx_nic_t *enp,
 	__in		unsigned int index);
 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_ev_death(
 	__in		efx_nic_t *enp,
 	__in		int rc);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_request_errcode(
 	__in		unsigned int err);
 
+LIBEFX_INTERNAL
 extern			void
 efx_mcdi_raise_exception(
 	__in		efx_nic_t *enp,
@@ -116,6 +124,7 @@ typedef enum efx_mcdi_boot_e {
 	EFX_MCDI_BOOT_ROM,
 } efx_mcdi_boot_t;
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_version(
 	__in			efx_nic_t *enp,
@@ -123,6 +132,7 @@ efx_mcdi_version(
 	__out_opt		uint32_t *buildp,
 	__out_opt		efx_mcdi_boot_t *statusp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_capabilities(
 	__in		efx_nic_t *enp,
@@ -132,19 +142,23 @@ efx_mcdi_get_capabilities(
 	__out_opt	uint32_t *flags2p,
 	__out_opt	uint32_t *tso2ncp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_read_assertion(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_exit_assertion_handler(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_drv_attach(
 	__in			efx_nic_t *enp,
 	__in			boolean_t attach);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_get_board_cfg(
 	__in			efx_nic_t *enp,
@@ -152,25 +166,30 @@ efx_mcdi_get_board_cfg(
 	__out_opt		efx_dword_t *capabilitiesp,
 	__out_ecount_opt(6)	uint8_t mac_addrp[6]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_get_phy_cfg(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_firmware_update_supported(
 	__in			efx_nic_t *enp,
 	__out			boolean_t *supportedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_macaddr_change_supported(
 	__in			efx_nic_t *enp,
 	__out			boolean_t *supportedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_link_control_supported(
 	__in			efx_nic_t *enp,
 	__out			boolean_t *supportedp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_mac_spoofing_supported(
 	__in			efx_nic_t *enp,
@@ -179,16 +198,19 @@ efx_mcdi_mac_spoofing_supported(
 
 #if EFSYS_OPT_BIST
 #if EFX_OPTS_EF10()
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_bist_enable_offline(
 	__in			efx_nic_t *enp);
 #endif /* EFX_OPTS_EF10() */
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_bist_start(
 	__in			efx_nic_t *enp,
 	__in			efx_bist_type_t type);
 #endif /* EFSYS_OPT_BIST */
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 efx_mcdi_get_resource_limits(
 	__in			efx_nic_t *enp,
@@ -196,19 +218,23 @@ efx_mcdi_get_resource_limits(
 	__out_opt		uint32_t *nrxqp,
 	__out_opt		uint32_t *ntxqp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_log_ctrl(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_mac_stats_clear(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_mac_stats_upload(
 	__in		efx_nic_t *enp,
 	__in		efsys_mem_t *esmp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_mac_stats_periodic(
 	__in		efx_nic_t *enp,
@@ -218,11 +244,13 @@ efx_mcdi_mac_stats_periodic(
 
 
 #if EFSYS_OPT_LOOPBACK
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_get_loopback_modes(
 	__in		efx_nic_t *enp);
 #endif /* EFSYS_OPT_LOOPBACK */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 efx_mcdi_phy_module_get_info(
 	__in			efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/hunt_impl.h b/drivers/net/sfc/base/hunt_impl.h
index 546c5d9d0a..4f193935a7 100644
--- a/drivers/net/sfc/base/hunt_impl.h
+++ b/drivers/net/sfc/base/hunt_impl.h
@@ -43,6 +43,7 @@ extern "C" {
 
 /* NIC */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 hunt_board_cfg(
 	__in		efx_nic_t *enp);
diff --git a/drivers/net/sfc/base/mcdi_mon.h b/drivers/net/sfc/base/mcdi_mon.h
index c79f55c35f..4cdf9d6f5f 100644
--- a/drivers/net/sfc/base/mcdi_mon.h
+++ b/drivers/net/sfc/base/mcdi_mon.h
@@ -17,15 +17,18 @@ extern "C" {
 
 #if EFSYS_OPT_MON_STATS
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 mcdi_mon_cfg_build(
     __in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 mcdi_mon_cfg_free(
 	__in		efx_nic_t *enp);
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 mcdi_mon_ev(
 	__in				efx_nic_t *enp,
@@ -33,12 +36,14 @@ mcdi_mon_ev(
 	__out				efx_mon_stat_t *idp,
 	__out				efx_mon_stat_value_t *valuep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 mcdi_mon_stats_update(
 	__in				efx_nic_t *enp,
 	__in				efsys_mem_t *esmp,
 	__inout_ecount(EFX_MON_NSTATS)	efx_mon_stat_value_t *values);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 mcdi_mon_limits_update(
 	__in				efx_nic_t *enp,
diff --git a/drivers/net/sfc/base/medford2_impl.h b/drivers/net/sfc/base/medford2_impl.h
index 61a11829f2..ea93b51690 100644
--- a/drivers/net/sfc/base/medford2_impl.h
+++ b/drivers/net/sfc/base/medford2_impl.h
@@ -27,6 +27,7 @@ extern "C" {
 #define	MEDFORD2_MIN_PIO_ALLOC_SIZE	(MEDFORD2_PIOBUF_SIZE / 32)
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 medford2_board_cfg(
 	__in		efx_nic_t *enp);
diff --git a/drivers/net/sfc/base/medford_impl.h b/drivers/net/sfc/base/medford_impl.h
index 21e5652fbf..f1a3bb1bf6 100644
--- a/drivers/net/sfc/base/medford_impl.h
+++ b/drivers/net/sfc/base/medford_impl.h
@@ -27,6 +27,7 @@ extern "C" {
 #define	MEDFORD_MIN_PIO_ALLOC_SIZE	(MEDFORD_PIOBUF_SIZE / 32)
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 medford_board_cfg(
 	__in		efx_nic_t *enp);
diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/net/sfc/base/siena_impl.h
index 83f60d164c..eb3b76369b 100644
--- a/drivers/net/sfc/base/siena_impl.h
+++ b/drivers/net/sfc/base/siena_impl.h
@@ -40,20 +40,24 @@ extern "C" {
 #define	SIENA_NVRAM_CHUNK 0x80
 
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_nic_probe(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_nic_reset(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_nic_init(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	efx_sram_pattern_fn_t	__efx_sram_pattern_fns[];
 
 typedef struct siena_register_set_s {
@@ -63,28 +67,33 @@ typedef struct siena_register_set_s {
 	efx_oword_t		mask;
 } siena_register_set_t;
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_nic_register_test(
 	__in		efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_INTERNAL
 extern			void
 siena_nic_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 siena_nic_unprobe(
 	__in		efx_nic_t *enp);
 
 #define	SIENA_SRAM_ROWS	0x12000
 
+LIBEFX_INTERNAL
 extern			void
 siena_sram_init(
 	__in		efx_nic_t *enp);
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_sram_test(
 	__in		efx_nic_t *enp,
@@ -94,11 +103,13 @@ siena_sram_test(
 
 #if EFSYS_OPT_MCDI
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mcdi_init(
 	__in		efx_nic_t *enp,
 	__in		const efx_mcdi_transport_t *mtp);
 
+LIBEFX_INTERNAL
 extern			void
 siena_mcdi_send_request(
 	__in			efx_nic_t *enp,
@@ -107,10 +118,12 @@ siena_mcdi_send_request(
 	__in_bcount(sdu_len)	void *sdup,
 	__in			size_t sdu_len);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	boolean_t
 siena_mcdi_poll_response(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 siena_mcdi_read_response(
 	__in			efx_nic_t *enp,
@@ -118,20 +131,24 @@ siena_mcdi_read_response(
 	__in			size_t offset,
 	__in			size_t length);
 
+LIBEFX_INTERNAL
 extern			efx_rc_t
 siena_mcdi_poll_reboot(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern			void
 siena_mcdi_fini(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mcdi_feature_supported(
 	__in		efx_nic_t *enp,
 	__in		efx_mcdi_feature_id_t id,
 	__out		boolean_t *supportedp);
 
+LIBEFX_INTERNAL
 extern			void
 siena_mcdi_get_timeout(
 	__in		efx_nic_t *enp,
@@ -142,17 +159,20 @@ siena_mcdi_get_timeout(
 
 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_lock(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_unlock(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out_opt		uint32_t *verify_resultp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_get_dynamic_cfg(
 	__in			efx_nic_t *enp,
@@ -167,42 +187,49 @@ siena_nvram_get_dynamic_cfg(
 
 #if EFSYS_OPT_DIAG
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_test(
 	__in			efx_nic_t *enp);
 
 #endif	/* EFSYS_OPT_DIAG */
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_get_subtype(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			uint32_t *subtypep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_type_to_partn(
 	__in			efx_nic_t *enp,
 	__in			efx_nvram_type_t type,
 	__out			uint32_t *partnp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_size(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_info(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			efx_nvram_info_t * enip);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_rw_start(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out			size_t *chunk_sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_read(
 	__in			efx_nic_t *enp,
@@ -211,6 +238,7 @@ siena_nvram_partn_read(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_erase(
 	__in			efx_nic_t *enp,
@@ -218,6 +246,7 @@ siena_nvram_partn_erase(
 	__in			unsigned int offset,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_write(
 	__in			efx_nic_t *enp,
@@ -226,12 +255,14 @@ siena_nvram_partn_write(
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_rw_finish(
 	__in			efx_nic_t *enp,
 	__in			uint32_t partn,
 	__out_opt		uint32_t *verify_resultp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_get_version(
 	__in			efx_nic_t *enp,
@@ -239,6 +270,7 @@ siena_nvram_partn_get_version(
 	__out			uint32_t *subtypep,
 	__out_ecount(4)		uint16_t version[4]);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_nvram_partn_set_version(
 	__in			efx_nic_t *enp,
@@ -249,33 +281,39 @@ siena_nvram_partn_set_version(
 
 #if EFSYS_OPT_VPD
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_init(
 	__in			efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_size(
 	__in			efx_nic_t *enp,
 	__out			size_t *sizep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_read(
 	__in			efx_nic_t *enp,
 	__out_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_verify(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_reinit(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_get(
 	__in			efx_nic_t *enp,
@@ -283,6 +321,7 @@ siena_vpd_get(
 	__in			size_t size,
 	__inout			efx_vpd_value_t *evvp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_set(
 	__in			efx_nic_t *enp,
@@ -290,6 +329,7 @@ siena_vpd_set(
 	__in			size_t size,
 	__in			efx_vpd_value_t *evvp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_vpd_next(
 	__in			efx_nic_t *enp,
@@ -298,12 +338,14 @@ siena_vpd_next(
 	__out			efx_vpd_value_t *evvp,
 	__inout			unsigned int *contp);
 
+LIBEFX_INTERNAL
 extern __checkReturn		efx_rc_t
 siena_vpd_write(
 	__in			efx_nic_t *enp,
 	__in_bcount(size)	caddr_t data,
 	__in			size_t size);
 
+LIBEFX_INTERNAL
 extern				void
 siena_vpd_fini(
 	__in			efx_nic_t *enp);
@@ -321,30 +363,36 @@ typedef struct siena_link_state_s {
 	boolean_t		sls_mac_up;
 } siena_link_state_t;
 
+LIBEFX_INTERNAL
 extern			void
 siena_phy_link_ev(
 	__in		efx_nic_t *enp,
 	__in		efx_qword_t *eqp,
 	__out		efx_link_mode_t *link_modep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_phy_get_link(
 	__in		efx_nic_t *enp,
 	__out		siena_link_state_t *slsp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_phy_power(
 	__in		efx_nic_t *enp,
 	__in		boolean_t on);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_phy_reconfigure(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_phy_verify(
 	__in		efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_phy_oui_get(
 	__in		efx_nic_t *enp,
@@ -352,6 +400,7 @@ siena_phy_oui_get(
 
 #if EFSYS_OPT_PHY_STATS
 
+LIBEFX_INTERNAL
 extern						void
 siena_phy_decode_stats(
 	__in					efx_nic_t *enp,
@@ -360,6 +409,7 @@ siena_phy_decode_stats(
 	__out_opt				uint64_t *smaskp,
 	__inout_ecount_opt(EFX_PHY_NSTATS)	uint32_t *stat);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 siena_phy_stats_update(
 	__in				efx_nic_t *enp,
@@ -370,11 +420,13 @@ siena_phy_stats_update(
 
 #if EFSYS_OPT_BIST
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_phy_bist_start(
 	__in			efx_nic_t *enp,
 	__in			efx_bist_type_t type);
 
+LIBEFX_INTERNAL
 extern	__checkReturn		efx_rc_t
 siena_phy_bist_poll(
 	__in			efx_nic_t *enp,
@@ -386,6 +438,7 @@ siena_phy_bist_poll(
 	unsigned long	*valuesp,
 	__in			size_t count);
 
+LIBEFX_INTERNAL
 extern				void
 siena_phy_bist_stop(
 	__in			efx_nic_t *enp,
@@ -393,20 +446,24 @@ siena_phy_bist_stop(
 
 #endif	/* EFSYS_OPT_BIST */
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mac_poll(
 	__in		efx_nic_t *enp,
 	__out		efx_link_mode_t *link_modep);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mac_up(
 	__in		efx_nic_t *enp,
 	__out		boolean_t *mac_upp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mac_reconfigure(
 	__in	efx_nic_t *enp);
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mac_pdu_get(
 	__in	efx_nic_t *enp,
@@ -414,6 +471,7 @@ siena_mac_pdu_get(
 
 #if EFSYS_OPT_LOOPBACK
 
+LIBEFX_INTERNAL
 extern	__checkReturn	efx_rc_t
 siena_mac_loopback_set(
 	__in		efx_nic_t *enp,
@@ -424,12 +482,14 @@ siena_mac_loopback_set(
 
 #if EFSYS_OPT_MAC_STATS
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 siena_mac_stats_get_mask(
 	__in				efx_nic_t *enp,
 	__inout_bcount(mask_size)	uint32_t *maskp,
 	__in				size_t mask_size);
 
+LIBEFX_INTERNAL
 extern	__checkReturn			efx_rc_t
 siena_mac_stats_update(
 	__in				efx_nic_t *enp,
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index cc132d83bb..dee06e5ae3 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -34,6 +34,7 @@ extern "C" {
 
 /* No specific decorations required since all functions are local now */
 #define LIBEFX_API
+#define LIBEFX_INTERNAL
 
 #define EFSYS_HAS_UINT64 1
 #define EFSYS_USE_UINT64 1
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 04/17] net/sfc: include header with debug helpers directly
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 03/17] net/sfc/base: decorate libefx internal extern functions Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 05/17] net/sfc: introduce common driver library Andrew Rybchenko
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Avoid build failures on further restructuring.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.c              | 1 +
 drivers/net/sfc/sfc.h              | 1 +
 drivers/net/sfc/sfc_dp_tx.h        | 1 +
 drivers/net/sfc/sfc_ef10.h         | 2 ++
 drivers/net/sfc/sfc_ef10_essb_rx.c | 1 +
 drivers/net/sfc/sfc_ef10_rx.c      | 1 +
 drivers/net/sfc/sfc_ef10_rx_ev.h   | 2 ++
 drivers/net/sfc/sfc_ef10_tx.c      | 1 +
 drivers/net/sfc/sfc_filter.c       | 1 +
 drivers/net/sfc/sfc_flow.c         | 1 +
 drivers/net/sfc/sfc_mcdi.c         | 1 +
 drivers/net/sfc/sfc_port.c         | 1 +
 12 files changed, 14 insertions(+)

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index c19d81cc88..03ea5dc128 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -16,6 +16,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index cf95ebaf90..cdff9be3ec 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -21,6 +21,7 @@
 
 #include "efx.h"
 
+#include "sfc_debug.h"
 #include "sfc_filter.h"
 
 #ifdef __cplusplus
diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index dcad4fe585..77ae166885 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -12,6 +12,7 @@
 
 #include <rte_ethdev_driver.h>
 
+#include "sfc_debug.h"
 #include "sfc_dp.h"
 #include "sfc_debug.h"
 #include "sfc_tso.h"
diff --git a/drivers/net/sfc/sfc_ef10.h b/drivers/net/sfc/sfc_ef10.h
index f138e8d9b0..07c322f7a6 100644
--- a/drivers/net/sfc/sfc_ef10.h
+++ b/drivers/net/sfc/sfc_ef10.h
@@ -10,6 +10,8 @@
 #ifndef _SFC_EF10_H
 #define _SFC_EF10_H
 
+#include "sfc_debug.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c
index 13b2b824e3..8238cc830d 100644
--- a/drivers/net/sfc/sfc_ef10_essb_rx.c
+++ b/drivers/net/sfc/sfc_ef10_essb_rx.c
@@ -18,6 +18,7 @@
 #include "efx_types.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_tweak.h"
 #include "sfc_dp_rx.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c
index 42e205e1bd..8c6ebaa2fa 100644
--- a/drivers/net/sfc/sfc_ef10_rx.c
+++ b/drivers/net/sfc/sfc_ef10_rx.c
@@ -21,6 +21,7 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_tweak.h"
 #include "sfc_dp_rx.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_ef10_rx_ev.h b/drivers/net/sfc/sfc_ef10_rx_ev.h
index a9896eae56..d15d24f4c1 100644
--- a/drivers/net/sfc/sfc_ef10_rx_ev.h
+++ b/drivers/net/sfc/sfc_ef10_rx_ev.h
@@ -16,6 +16,8 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c
index b91c8068b1..4d7da427cb 100644
--- a/drivers/net/sfc/sfc_ef10_tx.c
+++ b/drivers/net/sfc/sfc_ef10_tx.c
@@ -19,6 +19,7 @@
 #include "efx_regs.h"
 #include "efx_regs_ef10.h"
 
+#include "sfc_debug.h"
 #include "sfc_dp_tx.h"
 #include "sfc_tweak.h"
 #include "sfc_kvargs.h"
diff --git a/drivers/net/sfc/sfc_filter.c b/drivers/net/sfc/sfc_filter.c
index 7f4f7c47a5..05a9799230 100644
--- a/drivers/net/sfc/sfc_filter.c
+++ b/drivers/net/sfc/sfc_filter.c
@@ -12,6 +12,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 
 boolean_t
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index c8e6fb8bce..1a3c0d618b 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -18,6 +18,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_rx.h"
 #include "sfc_filter.h"
 #include "sfc_flow.h"
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 872e4e76b1..ec62ba95ff 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -14,6 +14,7 @@
 #include "efx_regs_mcdi.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 32a0894a55..4de13267d5 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -10,6 +10,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_kvargs.h"
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 05/17] net/sfc: introduce common driver library
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 04/17] net/sfc: include header with debug helpers directly Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 06/17] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
                     ` (12 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Move libefx (base driver) into common driver.

Prepare to add vDPA driver which will use the common driver as well.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 MAINTAINERS                                   |   1 +
 drivers/common/meson.build                    |   2 +-
 .../{net/sfc => common/sfc_efx}/base/README   |   0
 .../sfc => common/sfc_efx}/base/ef10_ev.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_evb.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_filter.c |   0
 .../sfc_efx}/base/ef10_firmware_ids.h         |   0
 .../sfc => common/sfc_efx}/base/ef10_image.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_impl.h   |   0
 .../sfc => common/sfc_efx}/base/ef10_intr.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_mac.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_mcdi.c   |   0
 .../sfc => common/sfc_efx}/base/ef10_nic.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_nvram.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_phy.c    |   0
 .../sfc => common/sfc_efx}/base/ef10_proxy.c  |   0
 .../sfc => common/sfc_efx}/base/ef10_rx.c     |   0
 .../sfc_efx}/base/ef10_signed_image_layout.h  |   0
 .../sfc_efx}/base/ef10_tlv_layout.h           |   0
 .../sfc => common/sfc_efx}/base/ef10_tx.c     |   0
 .../sfc => common/sfc_efx}/base/ef10_vpd.c    |   0
 .../{net/sfc => common/sfc_efx}/base/efx.h    |   0
 .../sfc => common/sfc_efx}/base/efx_annote.h  |   0
 .../sfc => common/sfc_efx}/base/efx_bootcfg.c |   0
 .../sfc => common/sfc_efx}/base/efx_check.h   |   0
 .../sfc => common/sfc_efx}/base/efx_crc32.c   |   0
 .../{net/sfc => common/sfc_efx}/base/efx_ev.c |   0
 .../sfc => common/sfc_efx}/base/efx_evb.c     |   0
 .../sfc => common/sfc_efx}/base/efx_filter.c  |   0
 .../sfc => common/sfc_efx}/base/efx_hash.c    |   0
 .../sfc => common/sfc_efx}/base/efx_impl.h    |   0
 .../sfc => common/sfc_efx}/base/efx_intr.c    |   0
 .../sfc => common/sfc_efx}/base/efx_lic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mac.c     |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.c    |   0
 .../sfc => common/sfc_efx}/base/efx_mcdi.h    |   0
 .../sfc => common/sfc_efx}/base/efx_mon.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nic.c     |   0
 .../sfc => common/sfc_efx}/base/efx_nvram.c   |   0
 .../sfc => common/sfc_efx}/base/efx_phy.c     |   0
 .../sfc => common/sfc_efx}/base/efx_phy_ids.h |   0
 .../sfc => common/sfc_efx}/base/efx_port.c    |   0
 .../sfc => common/sfc_efx}/base/efx_proxy.c   |   0
 .../sfc => common/sfc_efx}/base/efx_regs.h    |   0
 .../sfc_efx}/base/efx_regs_ef10.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi.h             |   0
 .../sfc_efx}/base/efx_regs_mcdi_aoe.h         |   0
 .../sfc_efx}/base/efx_regs_mcdi_strs.h        |   0
 .../sfc_efx}/base/efx_regs_pci.h              |   0
 .../{net/sfc => common/sfc_efx}/base/efx_rx.c |   0
 .../sfc => common/sfc_efx}/base/efx_sram.c    |   0
 .../sfc => common/sfc_efx}/base/efx_tunnel.c  |   0
 .../{net/sfc => common/sfc_efx}/base/efx_tx.c |   0
 .../sfc => common/sfc_efx}/base/efx_types.h   |   0
 .../sfc => common/sfc_efx}/base/efx_vpd.c     |   0
 .../sfc => common/sfc_efx}/base/hunt_impl.h   |   0
 .../sfc => common/sfc_efx}/base/hunt_nic.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.c    |   0
 .../sfc => common/sfc_efx}/base/mcdi_mon.h    |   0
 .../sfc_efx}/base/medford2_impl.h             |   0
 .../sfc_efx}/base/medford2_nic.c              |   0
 .../sfc_efx}/base/medford_impl.h              |   0
 .../sfc => common/sfc_efx}/base/medford_nic.c |   0
 .../sfc => common/sfc_efx}/base/meson.build   |   0
 .../sfc => common/sfc_efx}/base/siena_flash.h |   0
 .../sfc => common/sfc_efx}/base/siena_impl.h  |   0
 .../sfc => common/sfc_efx}/base/siena_mac.c   |   0
 .../sfc => common/sfc_efx}/base/siena_mcdi.c  |   0
 .../sfc => common/sfc_efx}/base/siena_nic.c   |   0
 .../sfc => common/sfc_efx}/base/siena_nvram.c |   0
 .../sfc => common/sfc_efx}/base/siena_phy.c   |   0
 .../sfc => common/sfc_efx}/base/siena_sram.c  |   0
 .../sfc => common/sfc_efx}/base/siena_vpd.c   |   0
 drivers/{net/sfc => common/sfc_efx}/efsys.h   |  63 +++---
 drivers/common/sfc_efx/meson.build            |  39 ++++
 .../sfc_efx/rte_common_sfc_efx_version.map    | 182 ++++++++++++++++++
 drivers/common/sfc_efx/sfc_efx.c              |  23 +++
 drivers/common/sfc_efx/sfc_efx_debug.h        |  29 +++
 drivers/common/sfc_efx/sfc_efx_log.h          |  22 +++
 drivers/net/sfc/meson.build                   |   6 +-
 80 files changed, 330 insertions(+), 37 deletions(-)
 rename drivers/{net/sfc => common/sfc_efx}/base/README (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_firmware_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_image.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_signed_image_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tlv_layout.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/ef10_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_annote.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_bootcfg.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_check.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_crc32.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_ev.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_evb.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_filter.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_hash.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_intr.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_lic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy_ids.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_port.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_proxy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_ef10.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_aoe.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_strs.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_pci.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_rx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tunnel.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_tx.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_types.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/efx_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/hunt_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford2_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/medford_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/meson.build (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_flash.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_impl.h (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mac.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_mcdi.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nic.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_nvram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_phy.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_sram.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/base/siena_vpd.c (100%)
 rename drivers/{net/sfc => common/sfc_efx}/efsys.h (93%)
 create mode 100644 drivers/common/sfc_efx/meson.build
 create mode 100644 drivers/common/sfc_efx/rte_common_sfc_efx_version.map
 create mode 100644 drivers/common/sfc_efx/sfc_efx.c
 create mode 100644 drivers/common/sfc_efx/sfc_efx_debug.h
 create mode 100644 drivers/common/sfc_efx/sfc_efx_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 9db8d69f19..2f6344b057 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -854,6 +854,7 @@ F: doc/guides/nics/features/qede*.ini
 
 Solarflare sfc_efx
 M: Andrew Rybchenko <arybchenko@solarflare.com>
+F: drivers/common/sfc_efx/
 F: drivers/net/sfc/
 F: doc/guides/nics/sfc_efx.rst
 F: doc/guides/nics/features/sfc_efx.ini
diff --git a/drivers/common/meson.build b/drivers/common/meson.build
index 9ed4c04ba5..7ac1ca73a2 100644
--- a/drivers/common/meson.build
+++ b/drivers/common/meson.build
@@ -6,6 +6,6 @@ if is_windows
 endif
 
 std_deps = ['eal']
-drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat']
+drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat', 'sfc_efx']
 config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
 driver_name_fmt = 'rte_common_@0@'
diff --git a/drivers/net/sfc/base/README b/drivers/common/sfc_efx/base/README
similarity index 100%
rename from drivers/net/sfc/base/README
rename to drivers/common/sfc_efx/base/README
diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/common/sfc_efx/base/ef10_ev.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_ev.c
rename to drivers/common/sfc_efx/base/ef10_ev.c
diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/common/sfc_efx/base/ef10_evb.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_evb.c
rename to drivers/common/sfc_efx/base/ef10_evb.c
diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_filter.c
rename to drivers/common/sfc_efx/base/ef10_filter.c
diff --git a/drivers/net/sfc/base/ef10_firmware_ids.h b/drivers/common/sfc_efx/base/ef10_firmware_ids.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_firmware_ids.h
rename to drivers/common/sfc_efx/base/ef10_firmware_ids.h
diff --git a/drivers/net/sfc/base/ef10_image.c b/drivers/common/sfc_efx/base/ef10_image.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_image.c
rename to drivers/common/sfc_efx/base/ef10_image.c
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_impl.h
rename to drivers/common/sfc_efx/base/ef10_impl.h
diff --git a/drivers/net/sfc/base/ef10_intr.c b/drivers/common/sfc_efx/base/ef10_intr.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_intr.c
rename to drivers/common/sfc_efx/base/ef10_intr.c
diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/common/sfc_efx/base/ef10_mac.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_mac.c
rename to drivers/common/sfc_efx/base/ef10_mac.c
diff --git a/drivers/net/sfc/base/ef10_mcdi.c b/drivers/common/sfc_efx/base/ef10_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_mcdi.c
rename to drivers/common/sfc_efx/base/ef10_mcdi.c
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_nic.c
rename to drivers/common/sfc_efx/base/ef10_nic.c
diff --git a/drivers/net/sfc/base/ef10_nvram.c b/drivers/common/sfc_efx/base/ef10_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_nvram.c
rename to drivers/common/sfc_efx/base/ef10_nvram.c
diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/common/sfc_efx/base/ef10_phy.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_phy.c
rename to drivers/common/sfc_efx/base/ef10_phy.c
diff --git a/drivers/net/sfc/base/ef10_proxy.c b/drivers/common/sfc_efx/base/ef10_proxy.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_proxy.c
rename to drivers/common/sfc_efx/base/ef10_proxy.c
diff --git a/drivers/net/sfc/base/ef10_rx.c b/drivers/common/sfc_efx/base/ef10_rx.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_rx.c
rename to drivers/common/sfc_efx/base/ef10_rx.c
diff --git a/drivers/net/sfc/base/ef10_signed_image_layout.h b/drivers/common/sfc_efx/base/ef10_signed_image_layout.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_signed_image_layout.h
rename to drivers/common/sfc_efx/base/ef10_signed_image_layout.h
diff --git a/drivers/net/sfc/base/ef10_tlv_layout.h b/drivers/common/sfc_efx/base/ef10_tlv_layout.h
similarity index 100%
rename from drivers/net/sfc/base/ef10_tlv_layout.h
rename to drivers/common/sfc_efx/base/ef10_tlv_layout.h
diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/common/sfc_efx/base/ef10_tx.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_tx.c
rename to drivers/common/sfc_efx/base/ef10_tx.c
diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/common/sfc_efx/base/ef10_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/ef10_vpd.c
rename to drivers/common/sfc_efx/base/ef10_vpd.c
diff --git a/drivers/net/sfc/base/efx.h b/drivers/common/sfc_efx/base/efx.h
similarity index 100%
rename from drivers/net/sfc/base/efx.h
rename to drivers/common/sfc_efx/base/efx.h
diff --git a/drivers/net/sfc/base/efx_annote.h b/drivers/common/sfc_efx/base/efx_annote.h
similarity index 100%
rename from drivers/net/sfc/base/efx_annote.h
rename to drivers/common/sfc_efx/base/efx_annote.h
diff --git a/drivers/net/sfc/base/efx_bootcfg.c b/drivers/common/sfc_efx/base/efx_bootcfg.c
similarity index 100%
rename from drivers/net/sfc/base/efx_bootcfg.c
rename to drivers/common/sfc_efx/base/efx_bootcfg.c
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/common/sfc_efx/base/efx_check.h
similarity index 100%
rename from drivers/net/sfc/base/efx_check.h
rename to drivers/common/sfc_efx/base/efx_check.h
diff --git a/drivers/net/sfc/base/efx_crc32.c b/drivers/common/sfc_efx/base/efx_crc32.c
similarity index 100%
rename from drivers/net/sfc/base/efx_crc32.c
rename to drivers/common/sfc_efx/base/efx_crc32.c
diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/common/sfc_efx/base/efx_ev.c
similarity index 100%
rename from drivers/net/sfc/base/efx_ev.c
rename to drivers/common/sfc_efx/base/efx_ev.c
diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/common/sfc_efx/base/efx_evb.c
similarity index 100%
rename from drivers/net/sfc/base/efx_evb.c
rename to drivers/common/sfc_efx/base/efx_evb.c
diff --git a/drivers/net/sfc/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
similarity index 100%
rename from drivers/net/sfc/base/efx_filter.c
rename to drivers/common/sfc_efx/base/efx_filter.c
diff --git a/drivers/net/sfc/base/efx_hash.c b/drivers/common/sfc_efx/base/efx_hash.c
similarity index 100%
rename from drivers/net/sfc/base/efx_hash.c
rename to drivers/common/sfc_efx/base/efx_hash.c
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
similarity index 100%
rename from drivers/net/sfc/base/efx_impl.h
rename to drivers/common/sfc_efx/base/efx_impl.h
diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/common/sfc_efx/base/efx_intr.c
similarity index 100%
rename from drivers/net/sfc/base/efx_intr.c
rename to drivers/common/sfc_efx/base/efx_intr.c
diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/common/sfc_efx/base/efx_lic.c
similarity index 100%
rename from drivers/net/sfc/base/efx_lic.c
rename to drivers/common/sfc_efx/base/efx_lic.c
diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mac.c
rename to drivers/common/sfc_efx/base/efx_mac.c
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mcdi.c
rename to drivers/common/sfc_efx/base/efx_mcdi.c
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/common/sfc_efx/base/efx_mcdi.h
similarity index 100%
rename from drivers/net/sfc/base/efx_mcdi.h
rename to drivers/common/sfc_efx/base/efx_mcdi.h
diff --git a/drivers/net/sfc/base/efx_mon.c b/drivers/common/sfc_efx/base/efx_mon.c
similarity index 100%
rename from drivers/net/sfc/base/efx_mon.c
rename to drivers/common/sfc_efx/base/efx_mon.c
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/common/sfc_efx/base/efx_nic.c
similarity index 100%
rename from drivers/net/sfc/base/efx_nic.c
rename to drivers/common/sfc_efx/base/efx_nic.c
diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/common/sfc_efx/base/efx_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/efx_nvram.c
rename to drivers/common/sfc_efx/base/efx_nvram.c
diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/common/sfc_efx/base/efx_phy.c
similarity index 100%
rename from drivers/net/sfc/base/efx_phy.c
rename to drivers/common/sfc_efx/base/efx_phy.c
diff --git a/drivers/net/sfc/base/efx_phy_ids.h b/drivers/common/sfc_efx/base/efx_phy_ids.h
similarity index 100%
rename from drivers/net/sfc/base/efx_phy_ids.h
rename to drivers/common/sfc_efx/base/efx_phy_ids.h
diff --git a/drivers/net/sfc/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
similarity index 100%
rename from drivers/net/sfc/base/efx_port.c
rename to drivers/common/sfc_efx/base/efx_port.c
diff --git a/drivers/net/sfc/base/efx_proxy.c b/drivers/common/sfc_efx/base/efx_proxy.c
similarity index 100%
rename from drivers/net/sfc/base/efx_proxy.c
rename to drivers/common/sfc_efx/base/efx_proxy.c
diff --git a/drivers/net/sfc/base/efx_regs.h b/drivers/common/sfc_efx/base/efx_regs.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs.h
rename to drivers/common/sfc_efx/base/efx_regs.h
diff --git a/drivers/net/sfc/base/efx_regs_ef10.h b/drivers/common/sfc_efx/base/efx_regs_ef10.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_ef10.h
rename to drivers/common/sfc_efx/base/efx_regs_ef10.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi.h b/drivers/common/sfc_efx/base/efx_regs_mcdi.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi_aoe.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi_aoe.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h
diff --git a/drivers/net/sfc/base/efx_regs_mcdi_strs.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_mcdi_strs.h
rename to drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h
diff --git a/drivers/net/sfc/base/efx_regs_pci.h b/drivers/common/sfc_efx/base/efx_regs_pci.h
similarity index 100%
rename from drivers/net/sfc/base/efx_regs_pci.h
rename to drivers/common/sfc_efx/base/efx_regs_pci.h
diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
similarity index 100%
rename from drivers/net/sfc/base/efx_rx.c
rename to drivers/common/sfc_efx/base/efx_rx.c
diff --git a/drivers/net/sfc/base/efx_sram.c b/drivers/common/sfc_efx/base/efx_sram.c
similarity index 100%
rename from drivers/net/sfc/base/efx_sram.c
rename to drivers/common/sfc_efx/base/efx_sram.c
diff --git a/drivers/net/sfc/base/efx_tunnel.c b/drivers/common/sfc_efx/base/efx_tunnel.c
similarity index 100%
rename from drivers/net/sfc/base/efx_tunnel.c
rename to drivers/common/sfc_efx/base/efx_tunnel.c
diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/common/sfc_efx/base/efx_tx.c
similarity index 100%
rename from drivers/net/sfc/base/efx_tx.c
rename to drivers/common/sfc_efx/base/efx_tx.c
diff --git a/drivers/net/sfc/base/efx_types.h b/drivers/common/sfc_efx/base/efx_types.h
similarity index 100%
rename from drivers/net/sfc/base/efx_types.h
rename to drivers/common/sfc_efx/base/efx_types.h
diff --git a/drivers/net/sfc/base/efx_vpd.c b/drivers/common/sfc_efx/base/efx_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/efx_vpd.c
rename to drivers/common/sfc_efx/base/efx_vpd.c
diff --git a/drivers/net/sfc/base/hunt_impl.h b/drivers/common/sfc_efx/base/hunt_impl.h
similarity index 100%
rename from drivers/net/sfc/base/hunt_impl.h
rename to drivers/common/sfc_efx/base/hunt_impl.h
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/common/sfc_efx/base/hunt_nic.c
similarity index 100%
rename from drivers/net/sfc/base/hunt_nic.c
rename to drivers/common/sfc_efx/base/hunt_nic.c
diff --git a/drivers/net/sfc/base/mcdi_mon.c b/drivers/common/sfc_efx/base/mcdi_mon.c
similarity index 100%
rename from drivers/net/sfc/base/mcdi_mon.c
rename to drivers/common/sfc_efx/base/mcdi_mon.c
diff --git a/drivers/net/sfc/base/mcdi_mon.h b/drivers/common/sfc_efx/base/mcdi_mon.h
similarity index 100%
rename from drivers/net/sfc/base/mcdi_mon.h
rename to drivers/common/sfc_efx/base/mcdi_mon.h
diff --git a/drivers/net/sfc/base/medford2_impl.h b/drivers/common/sfc_efx/base/medford2_impl.h
similarity index 100%
rename from drivers/net/sfc/base/medford2_impl.h
rename to drivers/common/sfc_efx/base/medford2_impl.h
diff --git a/drivers/net/sfc/base/medford2_nic.c b/drivers/common/sfc_efx/base/medford2_nic.c
similarity index 100%
rename from drivers/net/sfc/base/medford2_nic.c
rename to drivers/common/sfc_efx/base/medford2_nic.c
diff --git a/drivers/net/sfc/base/medford_impl.h b/drivers/common/sfc_efx/base/medford_impl.h
similarity index 100%
rename from drivers/net/sfc/base/medford_impl.h
rename to drivers/common/sfc_efx/base/medford_impl.h
diff --git a/drivers/net/sfc/base/medford_nic.c b/drivers/common/sfc_efx/base/medford_nic.c
similarity index 100%
rename from drivers/net/sfc/base/medford_nic.c
rename to drivers/common/sfc_efx/base/medford_nic.c
diff --git a/drivers/net/sfc/base/meson.build b/drivers/common/sfc_efx/base/meson.build
similarity index 100%
rename from drivers/net/sfc/base/meson.build
rename to drivers/common/sfc_efx/base/meson.build
diff --git a/drivers/net/sfc/base/siena_flash.h b/drivers/common/sfc_efx/base/siena_flash.h
similarity index 100%
rename from drivers/net/sfc/base/siena_flash.h
rename to drivers/common/sfc_efx/base/siena_flash.h
diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/common/sfc_efx/base/siena_impl.h
similarity index 100%
rename from drivers/net/sfc/base/siena_impl.h
rename to drivers/common/sfc_efx/base/siena_impl.h
diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/common/sfc_efx/base/siena_mac.c
similarity index 100%
rename from drivers/net/sfc/base/siena_mac.c
rename to drivers/common/sfc_efx/base/siena_mac.c
diff --git a/drivers/net/sfc/base/siena_mcdi.c b/drivers/common/sfc_efx/base/siena_mcdi.c
similarity index 100%
rename from drivers/net/sfc/base/siena_mcdi.c
rename to drivers/common/sfc_efx/base/siena_mcdi.c
diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
similarity index 100%
rename from drivers/net/sfc/base/siena_nic.c
rename to drivers/common/sfc_efx/base/siena_nic.c
diff --git a/drivers/net/sfc/base/siena_nvram.c b/drivers/common/sfc_efx/base/siena_nvram.c
similarity index 100%
rename from drivers/net/sfc/base/siena_nvram.c
rename to drivers/common/sfc_efx/base/siena_nvram.c
diff --git a/drivers/net/sfc/base/siena_phy.c b/drivers/common/sfc_efx/base/siena_phy.c
similarity index 100%
rename from drivers/net/sfc/base/siena_phy.c
rename to drivers/common/sfc_efx/base/siena_phy.c
diff --git a/drivers/net/sfc/base/siena_sram.c b/drivers/common/sfc_efx/base/siena_sram.c
similarity index 100%
rename from drivers/net/sfc/base/siena_sram.c
rename to drivers/common/sfc_efx/base/siena_sram.c
diff --git a/drivers/net/sfc/base/siena_vpd.c b/drivers/common/sfc_efx/base/siena_vpd.c
similarity index 100%
rename from drivers/net/sfc/base/siena_vpd.c
rename to drivers/common/sfc_efx/base/siena_vpd.c
diff --git a/drivers/net/sfc/efsys.h b/drivers/common/sfc_efx/efsys.h
similarity index 93%
rename from drivers/net/sfc/efsys.h
rename to drivers/common/sfc_efx/efsys.h
index dee06e5ae3..46b08f9789 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/common/sfc_efx/efsys.h
@@ -25,15 +25,16 @@
 #include <rte_log.h>
 #include <rte_io.h>
 
-#include "sfc_debug.h"
-#include "sfc_log.h"
+#include "sfc_efx_debug.h"
+#include "sfc_efx_log.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* No specific decorations required since all functions are local now */
-#define LIBEFX_API
+#define LIBEFX_API		__rte_internal
+
+/* No specific decorations required since functions are local by default */
 #define LIBEFX_INTERNAL
 
 #define EFSYS_HAS_UINT64 1
@@ -228,8 +229,8 @@ typedef struct efsys_mem_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		_addr = (volatile uint32_t *)(_base + (_offset));	\
 		(_edp)->ed_u32[0] = _addr[0];				\
@@ -246,8 +247,8 @@ typedef struct efsys_mem_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		_addr = (volatile uint64_t *)(_base + (_offset));	\
 		(_eqp)->eq_u64[0] = _addr[0];				\
@@ -265,8 +266,8 @@ typedef struct efsys_mem_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_addr = (volatile __m128i *)(_base + (_offset));	\
 		(_eop)->eo_u128[0] = _addr[0];				\
@@ -287,8 +288,8 @@ typedef struct efsys_mem_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		EFSYS_PROBE2(mem_writed, unsigned int, (_offset),	\
 					 uint32_t, (_edp)->ed_u32[0]);	\
@@ -305,8 +306,8 @@ typedef struct efsys_mem_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		EFSYS_PROBE3(mem_writeq, unsigned int, (_offset),	\
 					 uint32_t, (_eqp)->eq_u32[1],	\
@@ -324,8 +325,8 @@ typedef struct efsys_mem_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 									\
 		EFSYS_PROBE5(mem_writeo, unsigned int, (_offset),	\
@@ -390,8 +391,8 @@ typedef struct efsys_bar_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
 			SFC_BAR_LOCK(_esbp);				\
@@ -415,8 +416,8 @@ typedef struct efsys_bar_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		SFC_BAR_LOCK(_esbp);					\
 									\
@@ -438,8 +439,8 @@ typedef struct efsys_bar_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -469,8 +470,8 @@ typedef struct efsys_bar_s {
 		volatile uint32_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_dword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_dword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -495,8 +496,8 @@ typedef struct efsys_bar_s {
 		volatile uint64_t *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_qword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_qword_t)));	\
 									\
 		SFC_BAR_LOCK(_esbp);					\
 									\
@@ -530,8 +531,8 @@ typedef struct efsys_bar_s {
 		volatile __m128i *_addr;				\
 									\
 		_NOTE(CONSTANTCONDITION);				\
-		SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,		\
-					    sizeof(efx_oword_t)));	\
+		SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset,	\
+						sizeof(efx_oword_t)));	\
 									\
 		_NOTE(CONSTANTCONDITION);				\
 		if (_lock)						\
@@ -629,7 +630,7 @@ typedef rte_spinlock_t efsys_lock_t;
 #define SFC_EFSYS_UNLOCK(_eslp)				\
 	rte_spinlock_unlock((_eslp))
 #define SFC_EFSYS_LOCK_ASSERT_OWNED(_eslp)		\
-	SFC_ASSERT(rte_spinlock_is_locked((_eslp)))
+	SFC_EFX_ASSERT(rte_spinlock_is_locked((_eslp)))
 
 typedef int efsys_lock_state_t;
 
@@ -644,7 +645,7 @@ typedef int efsys_lock_state_t;
 
 #define EFSYS_UNLOCK(_lockp, _state)				\
 	do {							\
-		SFC_ASSERT((_state) == EFSYS_LOCK_MAGIC);	\
+		SFC_EFX_ASSERT((_state) == EFSYS_LOCK_MAGIC);	\
 		SFC_EFSYS_UNLOCK(_lockp);			\
 		_NOTE(CONSTANTCONDITION);			\
 	} while (B_FALSE)
@@ -701,7 +702,7 @@ typedef uint64_t	efsys_stat_t;
 #define EFSYS_ERR(_esip, _code, _dword0, _dword1)			\
 	do {								\
 		(void)(_esip);						\
-		SFC_GENERIC_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)",	\
+		SFC_EFX_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)",	\
 			(_code), (_dword0), (_dword1));			\
 		_NOTE(CONSTANTCONDITION);				\
 	} while (B_FALSE)
diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build
new file mode 100644
index 0000000000..8fab4df792
--- /dev/null
+++ b/drivers/common/sfc_efx/meson.build
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2019-2020 Xilinx, Inc.
+#
+# This software was jointly developed between OKTET Labs (under contract
+# for Solarflare) and Solarflare Communications, Inc.
+
+if arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64')
+	build = false
+	reason = 'only supported on x86_64'
+endif
+
+extra_flags = []
+
+# Enable more warnings
+extra_flags += [
+	'-Wdisabled-optimization'
+]
+
+# Compiler and version dependent flags
+extra_flags += [
+	'-Waggregate-return',
+	'-Wbad-function-cast'
+]
+
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+	'sfc_efx.c',
+)
+
+includes += include_directories('base')
diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
new file mode 100644
index 0000000000..fa297d251b
--- /dev/null
+++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
@@ -0,0 +1,182 @@
+INTERNAL {
+	global:
+
+	efx_crc32_calculate;
+
+	efx_ev_fini;
+	efx_ev_init;
+	efx_ev_qcreate;
+	efx_ev_qdestroy;
+	efx_ev_qmoderate;
+	efx_ev_qpending;
+	efx_ev_qpoll;
+	efx_ev_qpost;
+	efx_ev_qprime;
+	efx_ev_usecs_to_ticks;
+
+	efx_evq_nbufs;
+	efx_evq_size;
+
+	efx_family;
+
+	efx_filter_fini;
+	efx_filter_init;
+	efx_filter_insert;
+	efx_filter_remove;
+	efx_filter_restore;
+	efx_filter_spec_init_rx;
+	efx_filter_spec_init_tx;
+	efx_filter_spec_set_encap_type;
+	efx_filter_spec_set_eth_local;
+	efx_filter_spec_set_ether_type;
+	efx_filter_spec_set_geneve;
+	efx_filter_spec_set_ipv4_full;
+	efx_filter_spec_set_ipv4_local;
+	efx_filter_spec_set_mc_def;
+	efx_filter_spec_set_nvgre;
+	efx_filter_spec_set_rss_context;
+	efx_filter_spec_set_uc_def;
+	efx_filter_spec_set_vxlan;
+	efx_filter_supported_filters;
+
+	efx_hash_bytes;
+	efx_hash_dwords;
+
+	efx_intr_disable;
+	efx_intr_disable_unlocked;
+	efx_intr_enable;
+	efx_intr_fatal;
+	efx_intr_fini;
+	efx_intr_init;
+	efx_intr_status_line;
+	efx_intr_status_message;
+	efx_intr_trigger;
+
+	efx_loopback_mask;
+	efx_loopback_type_name;
+
+	efx_mac_addr_set;
+	efx_mac_drain;
+	efx_mac_fcntl_get;
+	efx_mac_fcntl_set;
+	efx_mac_filter_default_rxq_clear;
+	efx_mac_filter_default_rxq_set;
+	efx_mac_filter_get_all_ucast_mcast;
+	efx_mac_filter_set;
+	efx_mac_multicast_list_set;
+	efx_mac_pdu_get;
+	efx_mac_pdu_set;
+	efx_mac_stat_name;
+	efx_mac_stats_clear;
+	efx_mac_stats_get_mask;
+	efx_mac_stats_periodic;
+	efx_mac_stats_update;
+	efx_mac_stats_upload;
+	efx_mac_up;
+
+	efx_mcdi_fini;
+	efx_mcdi_get_proxy_handle;
+	efx_mcdi_get_timeout;
+	efx_mcdi_init;
+	efx_mcdi_new_epoch;
+	efx_mcdi_reboot;
+	efx_mcdi_request_abort;
+	efx_mcdi_request_poll;
+	efx_mcdi_request_start;
+
+	efx_mon_fini;
+	efx_mon_init;
+	efx_mon_name;
+
+	efx_nic_calculate_pcie_link_bandwidth;
+	efx_nic_cfg_get;
+	efx_nic_check_pcie_link_speed;
+	efx_nic_create;
+	efx_nic_destroy;
+	efx_nic_fini;
+	efx_nic_get_bar_region;
+	efx_nic_get_fw_subvariant;
+	efx_nic_get_fw_version;
+	efx_nic_get_vi_pool;
+	efx_nic_hw_unavailable;
+	efx_nic_init;
+	efx_nic_probe;
+	efx_nic_reset;
+	efx_nic_set_drv_limits;
+	efx_nic_set_drv_version;
+	efx_nic_set_fw_subvariant;
+	efx_nic_set_hw_unavailable;
+	efx_nic_unprobe;
+
+	efx_phy_adv_cap_get;
+	efx_phy_adv_cap_set;
+	efx_phy_fec_type_get;
+	efx_phy_link_state_get;
+	efx_phy_lp_cap_get;
+	efx_phy_media_type_get;
+	efx_phy_module_get_info;
+	efx_phy_oui_get;
+	efx_phy_verify;
+
+	efx_port_fini;
+	efx_port_init;
+	efx_port_loopback_set;
+	efx_port_poll;
+
+	efx_pseudo_hdr_hash_get;
+	efx_pseudo_hdr_pkt_length_get;
+
+	efx_rx_fini;
+	efx_rx_hash_default_support_get;
+	efx_rx_init;
+	efx_rx_qcreate;
+	efx_rx_qcreate_es_super_buffer;
+	efx_rx_qdestroy;
+	efx_rx_qenable;
+	efx_rx_qflush;
+	efx_rx_qpost;
+	efx_rx_qpush;
+	efx_rx_scale_context_alloc;
+	efx_rx_scale_context_free;
+	efx_rx_scale_default_support_get;
+	efx_rx_scale_hash_flags_get;
+	efx_rx_scale_key_set;
+	efx_rx_scale_mode_set;
+	efx_rx_scale_tbl_set;
+	efx_rxq_nbufs;
+	efx_rxq_size;
+
+	efx_sram_buf_tbl_clear;
+	efx_sram_buf_tbl_set;
+
+	efx_tunnel_config_clear;
+	efx_tunnel_config_udp_add;
+	efx_tunnel_config_udp_remove;
+	efx_tunnel_fini;
+	efx_tunnel_init;
+	efx_tunnel_reconfigure;
+
+	efx_tx_fini;
+	efx_tx_init;
+	efx_tx_qcreate;
+	efx_tx_qdesc_checksum_create;
+	efx_tx_qdesc_dma_create;
+	efx_tx_qdesc_post;
+	efx_tx_qdesc_tso_create;
+	efx_tx_qdesc_tso2_create;
+	efx_tx_qdesc_vlantci_create;
+	efx_tx_qdestroy;
+	efx_tx_qenable;
+	efx_tx_qflush;
+	efx_tx_qpace;
+	efx_tx_qpio_disable;
+	efx_tx_qpio_enable;
+	efx_tx_qpio_post;
+	efx_tx_qpio_write;
+	efx_tx_qpost;
+	efx_tx_qpush;
+	efx_txq_nbufs;
+	efx_txq_size;
+
+	local: *;
+};
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
new file mode 100644
index 0000000000..0b8d5efee9
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#include <rte_log.h>
+
+#include "sfc_efx_log.h"
+
+uint32_t sfc_efx_logtype;
+
+RTE_INIT(sfc_efx_register_logtype)
+{
+	int ret;
+
+	ret = rte_log_register_type_and_pick_level("pmd.common.sfc_efx",
+						   RTE_LOG_NOTICE);
+	sfc_efx_logtype = (ret < 0) ? RTE_LOGTYPE_PMD : ret;
+}
diff --git a/drivers/common/sfc_efx/sfc_efx_debug.h b/drivers/common/sfc_efx/sfc_efx_debug.h
new file mode 100644
index 0000000000..e0bdeeb5a4
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_debug.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_EFX_DEBUG_H_
+#define _SFC_EFX_DEBUG_H_
+
+#include <rte_debug.h>
+
+#ifndef RTE_DEBUG_COMMON_SFC_EFX
+#define RTE_DEBUG_COMMON_SFC_EFX	0
+#endif
+
+#ifdef RTE_DEBUG_COMMON_SFC_EFX
+/* Avoid dependency from RTE_LOG_DP_LEVEL to be able to enable debug check
+ * in the driver only.
+ */
+#define SFC_EFX_ASSERT(exp)		RTE_VERIFY(exp)
+#else
+/* If the driver debug is not enabled, follow DPDK debug/non-debug */
+#define SFC_EFX_ASSERT(exp)		RTE_ASSERT(exp)
+#endif
+
+#endif /* _SFC_EFX_DEBUG_H_ */
diff --git a/drivers/common/sfc_efx/sfc_efx_log.h b/drivers/common/sfc_efx/sfc_efx_log.h
new file mode 100644
index 0000000000..f4417ffc30
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_log.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_EFX_LOG_H_
+#define _SFC_EFX_LOG_H_
+
+/** Generic driver log type */
+extern uint32_t sfc_efx_logtype;
+
+/** Log message, add a prefix and a line break */
+#define SFC_EFX_LOG(level, ...) \
+	rte_log(RTE_LOG_ ## level, sfc_efx_logtype,			\
+		RTE_FMT("sfc_efx: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+			RTE_FMT_TAIL(__VA_ARGS__ ,)))
+
+#endif /* _SFC_EFX_LOG_H_ */
diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build
index 35c05ac1dd..26f0323738 100644
--- a/drivers/net/sfc/meson.build
+++ b/drivers/net/sfc/meson.build
@@ -33,9 +33,7 @@ foreach flag: extra_flags
 	endif
 endforeach
 
-subdir('base')
-objs = [base_objs]
-
+deps += ['common_sfc_efx']
 sources = files(
 	'sfc_ethdev.c',
 	'sfc_kvargs.c',
@@ -54,5 +52,3 @@ sources = files(
 	'sfc_ef10_essb_rx.c',
 	'sfc_ef10_tx.c'
 )
-
-includes += include_directories('base')
-- 
2.17.1



^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 06/17] net/sfc: add dedicated header file with MCDI interface
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 05/17] net/sfc: introduce common driver library Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 07/17] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
                     ` (11 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

MCDI helpers will be shared by net and vDPA drivers.
Prepare to move it to common/sfc_efx.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h      | 23 +---------------
 drivers/net/sfc/sfc_mcdi.c |  1 +
 drivers/net/sfc/sfc_mcdi.h | 54 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/sfc/sfc_mcdi.h

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index cdff9be3ec..a530b12a8e 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -23,6 +23,7 @@
 
 #include "sfc_debug.h"
 #include "sfc_filter.h"
+#include "sfc_mcdi.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -86,25 +87,6 @@ enum sfc_dev_filter_mode {
 	SFC_DEV_FILTER_NMODES
 };
 
-enum sfc_mcdi_state {
-	SFC_MCDI_UNINITIALIZED = 0,
-	SFC_MCDI_INITIALIZED,
-	SFC_MCDI_BUSY,
-	SFC_MCDI_COMPLETED,
-
-	SFC_MCDI_NSTATES
-};
-
-struct sfc_mcdi {
-	rte_spinlock_t			lock;
-	efsys_mem_t			mem;
-	enum sfc_mcdi_state		state;
-	efx_mcdi_transport_t		transport;
-	uint32_t			logtype;
-	uint32_t			proxy_handle;
-	efx_rc_t			proxy_result;
-};
-
 struct sfc_intr {
 	efx_intr_type_t			type;
 	rte_intr_callback_fn		handler;
@@ -384,9 +366,6 @@ void sfc_stop(struct sfc_adapter *sa);
 
 void sfc_schedule_restart(struct sfc_adapter *sa);
 
-int sfc_mcdi_init(struct sfc_adapter *sa);
-void sfc_mcdi_fini(struct sfc_adapter *sa);
-
 int sfc_configure(struct sfc_adapter *sa);
 void sfc_close(struct sfc_adapter *sa);
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index ec62ba95ff..9a51b3e030 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -13,6 +13,7 @@
 #include "efx_mcdi.h"
 #include "efx_regs_mcdi.h"
 
+#include "sfc_mcdi.h"
 #include "sfc.h"
 #include "sfc_debug.h"
 #include "sfc_log.h"
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
new file mode 100644
index 0000000000..789a16d8bb
--- /dev/null
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2016-2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_MCDI_H
+#define _SFC_MCDI_H
+
+#include <stdint.h>
+
+#include <rte_spinlock.h>
+
+#include "efsys.h"
+#include "efx.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum sfc_mcdi_state {
+	SFC_MCDI_UNINITIALIZED = 0,
+	SFC_MCDI_INITIALIZED,
+	SFC_MCDI_BUSY,
+	SFC_MCDI_COMPLETED,
+
+	SFC_MCDI_NSTATES
+};
+
+struct sfc_mcdi {
+	rte_spinlock_t			lock;
+	efsys_mem_t			mem;
+	enum sfc_mcdi_state		state;
+	efx_mcdi_transport_t		transport;
+	uint32_t			logtype;
+	uint32_t			proxy_handle;
+	efx_rc_t			proxy_result;
+};
+
+
+struct sfc_adapter;
+
+int sfc_mcdi_init(struct sfc_adapter *sa);
+void sfc_mcdi_fini(struct sfc_adapter *sa);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _SFC_MCDI_H */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 07/17] net/sfc: move MCDI helper interface to dedicated namespace
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (5 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 06/17] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 08/17] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
                     ` (10 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

MCDI helpers will be moved to common/sfc_efx and it is better
to do dummy renamings first before non-trivial changes.

Existing functionality should be split into common and network
driver specific parts. Prepare to do it.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h      |   5 +-
 drivers/net/sfc/sfc_mcdi.c | 108 +++++++++++++++++++++----------------
 drivers/net/sfc/sfc_mcdi.h |  22 +++-----
 3 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index a530b12a8e..b3ac752334 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -220,7 +220,7 @@ struct sfc_adapter {
 	rte_spinlock_t			nic_lock;
 	rte_atomic32_t			restart_required;
 
-	struct sfc_mcdi			mcdi;
+	struct sfc_efx_mcdi		mcdi;
 	struct sfc_intr			intr;
 	struct sfc_port			port;
 	struct sfc_filter		filter;
@@ -366,6 +366,9 @@ void sfc_stop(struct sfc_adapter *sa);
 
 void sfc_schedule_restart(struct sfc_adapter *sa);
 
+int sfc_mcdi_init(struct sfc_adapter *sa);
+void sfc_mcdi_fini(struct sfc_adapter *sa);
+
 int sfc_configure(struct sfc_adapter *sa);
 void sfc_close(struct sfc_adapter *sa);
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 9a51b3e030..c97a33d558 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -19,12 +19,12 @@
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
-#define SFC_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us in 1us units */
-#define SFC_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms in 1us units */
-#define SFC_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s in 1us units */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
+#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
 static void
-sfc_mcdi_timeout(struct sfc_adapter *sa)
+sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
 	sfc_warn(sa, "MC TIMEOUT");
 
@@ -32,9 +32,9 @@ sfc_mcdi_timeout(struct sfc_adapter *sa)
 }
 
 static inline boolean_t
-sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
+sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
@@ -46,7 +46,7 @@ sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
 }
 
 static void
-sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
+sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 {
 	efx_nic_t *enp;
 	unsigned int delay_total;
@@ -54,22 +54,22 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 	boolean_t aborted __rte_unused;
 
 	delay_total = 0;
-	delay_us = SFC_MCDI_POLL_INTERVAL_MIN_US;
+	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
 	enp = sa->nic;
 
 	do {
 		boolean_t poll_completed;
 
-		poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
+		poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) :
 					   efx_mcdi_request_poll(enp);
 		if (poll_completed)
 			return;
 
-		if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
+		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
 			if (!proxy) {
 				aborted = efx_mcdi_request_abort(enp);
 				SFC_ASSERT(aborted);
-				sfc_mcdi_timeout(sa);
+				sfc_efx_mcdi_timeout(sa);
 			}
 
 			return;
@@ -80,27 +80,28 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 		delay_total += delay_us;
 
 		/* Exponentially back off the poll frequency */
-		RTE_BUILD_BUG_ON(SFC_MCDI_POLL_INTERVAL_MAX_US > UINT_MAX / 2);
+		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
+				 UINT_MAX / 2);
 		delay_us *= 2;
-		if (delay_us > SFC_MCDI_POLL_INTERVAL_MAX_US)
-			delay_us = SFC_MCDI_POLL_INTERVAL_MAX_US;
+		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
+			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
 
 	} while (1);
 }
 
 static void
-sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
+sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	uint32_t proxy_handle;
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
-	sfc_mcdi_poll(sa, B_FALSE);
+	sfc_efx_mcdi_poll(sa, B_FALSE);
 
 	if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
 		/*
@@ -109,7 +110,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 		 * a non-zero proxy handle (should be the same as
 		 * the value obtained above) and operation status
 		 */
-		sfc_mcdi_poll(sa, B_TRUE);
+		sfc_efx_mcdi_poll(sa, B_TRUE);
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
@@ -121,7 +122,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * request and poll for an ordinary MCDI response
 			 */
 			efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
-			sfc_mcdi_poll(sa, B_FALSE);
+			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
 			sfc_err(sa, "MCDI proxy authorization failed "
@@ -134,20 +135,20 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 }
 
 static void
-sfc_mcdi_ev_cpl(void *arg)
+sfc_efx_mcdi_ev_cpl(void *arg)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi __rte_unused;
+	struct sfc_efx_mcdi *mcdi __rte_unused;
 
 	mcdi = &sa->mcdi;
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	/* MCDI is polled, completions are not expected */
 	SFC_ASSERT(0);
 }
 
 static void
-sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
+sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
 
@@ -161,7 +162,7 @@ sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 #define SFC_MCDI_LOG_BUF_SIZE	128
 
 static size_t
-sfc_mcdi_do_log(const struct sfc_adapter *sa,
+sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 		char *buffer, void *data, size_t data_size,
 		size_t pfxsize, size_t position)
 {
@@ -190,7 +191,7 @@ sfc_mcdi_do_log(const struct sfc_adapter *sa,
 }
 
 static void
-sfc_mcdi_logger(void *arg, efx_log_msg_t type,
+sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *header, size_t header_size,
 		void *data, size_t data_size)
 {
@@ -215,9 +216,10 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
 			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_mcdi_do_log(sa, buffer, header, header_size,
-				pfxsize, pfxsize);
-	start = sfc_mcdi_do_log(sa, buffer, data, data_size, pfxsize, start);
+	start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size,
+				    pfxsize, pfxsize);
+	start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size,
+				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
 		sfc_log_mcdi(sa, "%s", buffer);
@@ -225,19 +227,19 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
 }
 
 static void
-sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 
 	mcdi->proxy_handle = handle;
 	mcdi->proxy_result = result;
 }
 
-int
-sfc_mcdi_init(struct sfc_adapter *sa)
+static int
+sfc_efx_mcdi_init(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi;
+	struct sfc_efx_mcdi *mcdi;
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
@@ -246,11 +248,11 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 
 	mcdi = &sa->mcdi;
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_UNINITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
-	mcdi->state = SFC_MCDI_INITIALIZED;
+	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
 	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
@@ -265,11 +267,11 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 	emtp = &mcdi->transport;
 	emtp->emt_context = sa;
 	emtp->emt_dma_mem = &mcdi->mem;
-	emtp->emt_execute = sfc_mcdi_execute;
-	emtp->emt_ev_cpl = sfc_mcdi_ev_cpl;
-	emtp->emt_exception = sfc_mcdi_exception;
-	emtp->emt_logger = sfc_mcdi_logger;
-	emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response;
+	emtp->emt_execute = sfc_efx_mcdi_execute;
+	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
+	emtp->emt_exception = sfc_efx_mcdi_exception;
+	emtp->emt_logger = sfc_efx_mcdi_logger;
+	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
 	sfc_log_init(sa, "init MCDI");
 	rc = efx_mcdi_init(sa->nic, emtp);
@@ -283,14 +285,14 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 	sfc_dma_free(sa, &mcdi->mem);
 
 fail_dma_alloc:
-	mcdi->state = SFC_MCDI_UNINITIALIZED;
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 	return rc;
 }
 
-void
-sfc_mcdi_fini(struct sfc_adapter *sa)
+static void
+sfc_efx_mcdi_fini(struct sfc_adapter *sa)
 {
-	struct sfc_mcdi *mcdi;
+	struct sfc_efx_mcdi *mcdi;
 	efx_mcdi_transport_t *emtp;
 
 	sfc_log_init(sa, "entry");
@@ -300,8 +302,8 @@ sfc_mcdi_fini(struct sfc_adapter *sa)
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
-	mcdi->state = SFC_MCDI_UNINITIALIZED;
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_log_init(sa, "fini MCDI");
 	efx_mcdi_fini(sa->nic);
@@ -311,3 +313,15 @@ sfc_mcdi_fini(struct sfc_adapter *sa)
 
 	sfc_dma_free(sa, &mcdi->mem);
 }
+
+int
+sfc_mcdi_init(struct sfc_adapter *sa)
+{
+	return sfc_efx_mcdi_init(sa);
+}
+
+void
+sfc_mcdi_fini(struct sfc_adapter *sa)
+{
+	sfc_efx_mcdi_fini(sa);
+}
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 789a16d8bb..10f5bab666 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -22,31 +22,25 @@
 extern "C" {
 #endif
 
-enum sfc_mcdi_state {
-	SFC_MCDI_UNINITIALIZED = 0,
-	SFC_MCDI_INITIALIZED,
-	SFC_MCDI_BUSY,
-	SFC_MCDI_COMPLETED,
+enum sfc_efx_mcdi_state {
+	SFC_EFX_MCDI_UNINITIALIZED = 0,
+	SFC_EFX_MCDI_INITIALIZED,
+	SFC_EFX_MCDI_BUSY,
+	SFC_EFX_MCDI_COMPLETED,
 
-	SFC_MCDI_NSTATES
+	SFC_EFX_MCDI_NSTATES
 };
 
-struct sfc_mcdi {
+struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
 	efsys_mem_t			mem;
-	enum sfc_mcdi_state		state;
+	enum sfc_efx_mcdi_state		state;
 	efx_mcdi_transport_t		transport;
 	uint32_t			logtype;
 	uint32_t			proxy_handle;
 	efx_rc_t			proxy_result;
 };
 
-
-struct sfc_adapter;
-
-int sfc_mcdi_init(struct sfc_adapter *sa);
-void sfc_mcdi_fini(struct sfc_adapter *sa);
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 08/17] net/sfc: make MCDI logging helper macros local
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (6 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 07/17] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 09/17] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Prepare to move MCDI helpers to drivers/common.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_log.h  | 11 -----------
 drivers/net/sfc/sfc_mcdi.c | 21 ++++++++++++++++-----
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
index 5383091c76..4bf44b1f15 100644
--- a/drivers/net/sfc/sfc_log.h
+++ b/drivers/net/sfc/sfc_log.h
@@ -28,9 +28,6 @@ extern uint32_t sfc_logtype_driver;
 /** Device MCDI log type name prefix */
 #define SFC_LOGTYPE_MCDI_STR	SFC_LOGTYPE_PREFIX "mcdi"
 
-/** Level value used by MCDI log statements */
-#define SFC_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
 /* Log PMD message, automatically add prefix and \n */
 #define SFC_LOG(sas, level, type, ...) \
 	do {								\
@@ -92,13 +89,5 @@ extern uint32_t sfc_logtype_driver;
 				RTE_FMT_TAIL(__VA_ARGS__ ,)));		\
 	} while (0)
 
-#define sfc_log_mcdi(sa, ...) \
-	do {								\
-		const struct sfc_adapter *_sa = (sa);			\
-									\
-		SFC_LOG(_sa->priv.shared, SFC_LOG_LEVEL_MCDI,		\
-			_sa->mcdi.logtype, __VA_ARGS__);		\
-	} while (0)
-
 
 #endif /* _SFC_LOG_H_ */
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index c97a33d558..c716caabdf 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -23,6 +23,17 @@
 #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
 #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(sa, ...) \
+	do {								\
+		const struct sfc_adapter *_sa = (sa);			\
+									\
+		SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI,	\
+			_sa->mcdi.logtype, __VA_ARGS__);		\
+	} while (0)
+
 static void
 sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
@@ -178,7 +189,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 			 * at the end which is required by netlogdecode.
 			 */
 			buffer[position] = '\0';
-			sfc_log_mcdi(sa, "%s \\", buffer);
+			sfc_efx_log_mcdi(sa, "%s \\", buffer);
 			/* Preserve prefix for the next log message */
 			position = pfxsize;
 		}
@@ -207,11 +218,11 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	 *
 	 * To avoid wasting time, the actual level is examined in advance.
 	 */
-	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_LOG_LEVEL_MCDI)
+	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
 		return;
 
-	/* The format including prefix added by sfc_log_mcdi() is the format
-	 * consumed by the Solarflare netlogdecode tool.
+	/* The format including prefix added by sfc_efx_log_mcdi() is the
+	 * format consumed by the Solarflare netlogdecode tool.
 	 */
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
@@ -222,7 +233,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
-		sfc_log_mcdi(sa, "%s", buffer);
+		sfc_efx_log_mcdi(sa, "%s", buffer);
 	}
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 09/17] net/sfc: start to make MCDI helpers interface shareable
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (7 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 08/17] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 10/17] net/sfc: use own logging helper macros Andrew Rybchenko
                     ` (8 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

sfc_adapter is network driver specific structure which finally
should not be used in shared MCDI helpers interface.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index c716caabdf..35e1f3940d 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -248,17 +248,14 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa)
+sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi;
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
 	sfc_log_init(sa, "entry");
 
-	mcdi = &sa->mcdi;
-
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
@@ -301,14 +298,12 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa)
 }
 
 static void
-sfc_efx_mcdi_fini(struct sfc_adapter *sa)
+sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi;
 	efx_mcdi_transport_t *emtp;
 
 	sfc_log_init(sa, "entry");
 
-	mcdi = &sa->mcdi;
 	emtp = &mcdi->transport;
 
 	rte_spinlock_lock(&mcdi->lock);
@@ -328,11 +323,11 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa)
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
-	return sfc_efx_mcdi_init(sa);
+	return sfc_efx_mcdi_init(sa, &sa->mcdi);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
-	sfc_efx_mcdi_fini(sa);
+	sfc_efx_mcdi_fini(sa, &sa->mcdi);
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 10/17] net/sfc: use own logging helper macros
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (8 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 09/17] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 11/17] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Network driver logging macros depends on sfc_adapter which is
specific to the driver and cannot be used in common code.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc.h        |  2 +
 drivers/net/sfc/sfc_ethdev.c | 13 ++++++
 drivers/net/sfc/sfc_log.h    | 12 ++---
 drivers/net/sfc/sfc_mcdi.c   | 86 +++++++++++++++++++++++-------------
 drivers/net/sfc/sfc_mcdi.h   |  1 +
 5 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index b3ac752334..b20fecb4f8 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -22,6 +22,7 @@
 #include "efx.h"
 
 #include "sfc_debug.h"
+#include "sfc_log.h"
 #include "sfc_filter.h"
 #include "sfc_mcdi.h"
 
@@ -170,6 +171,7 @@ struct sfc_adapter_shared {
 	boolean_t			isolated;
 	uint32_t			tunnel_encaps;
 
+	char				log_prefix[SFC_LOG_PREFIX_MAX];
 	struct rte_pci_addr		pci_addr;
 	uint16_t			port_id;
 
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 1a58e0df84..6c96118007 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2136,6 +2136,7 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 	int rc;
 	const efx_nic_cfg_t *encp;
 	const struct rte_ether_addr *from;
+	int ret;
 
 	sfc_register_dp();
 
@@ -2147,6 +2148,18 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
 		return -sfc_eth_dev_secondary_init(dev, logtype_main);
 
 	/* Required for logging */
+	ret = snprintf(sas->log_prefix, sizeof(sas->log_prefix),
+			"PMD: sfc_efx " PCI_PRI_FMT " #%" PRIu16 ": ",
+			pci_dev->addr.domain, pci_dev->addr.bus,
+			pci_dev->addr.devid, pci_dev->addr.function,
+			dev->data->port_id);
+	if (ret < 0 || ret >= (int)sizeof(sas->log_prefix)) {
+		SFC_GENERIC_LOG(ERR,
+			"reserved log prefix is too short for " PCI_PRI_FMT,
+			pci_dev->addr.domain, pci_dev->addr.bus,
+			pci_dev->addr.devid, pci_dev->addr.function);
+		return -EINVAL;
+	}
 	sas->pci_addr = pci_dev->addr;
 	sas->port_id = dev->data->port_id;
 
diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
index 4bf44b1f15..a2d714afb7 100644
--- a/drivers/net/sfc/sfc_log.h
+++ b/drivers/net/sfc/sfc_log.h
@@ -28,20 +28,16 @@ extern uint32_t sfc_logtype_driver;
 /** Device MCDI log type name prefix */
 #define SFC_LOGTYPE_MCDI_STR	SFC_LOGTYPE_PREFIX "mcdi"
 
+#define SFC_LOG_PREFIX_MAX	32
+
 /* Log PMD message, automatically add prefix and \n */
 #define SFC_LOG(sas, level, type, ...) \
 	do {								\
 		const struct sfc_adapter_shared *_sas = (sas);		\
 									\
 		rte_log(level, type,					\
-			RTE_FMT("PMD: sfc_efx "				\
-				PCI_PRI_FMT " #%" PRIu16		\
-				": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
-				_sas->pci_addr.domain,			\
-				_sas->pci_addr.bus,			\
-				_sas->pci_addr.devid,			\
-				_sas->pci_addr.function,		\
-				_sas->port_id,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_sas->log_prefix,			\
 				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 35e1f3940d..5f6ad0a4aa 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -23,21 +23,37 @@
 #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
 #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
 
-/** Level value used by MCDI log statements */
-#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
-#define sfc_efx_log_mcdi(sa, ...) \
+#define sfc_efx_mcdi_log(mcdi, level, ...) \
 	do {								\
-		const struct sfc_adapter *_sa = (sa);			\
+		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
 									\
-		SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI,	\
-			_sa->mcdi.logtype, __VA_ARGS__);		\
+		rte_log(level, _mcdi->logtype,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_mcdi->log_prefix,			\
+				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
+#define sfc_efx_mcdi_err(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
+
+#define sfc_efx_mcdi_warn(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
+
+#define sfc_efx_mcdi_info(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
+
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
+
 static void
 sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 {
-	sfc_warn(sa, "MC TIMEOUT");
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+
+	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
 	sfc_panic(sa, "MCDI timeout handling is not implemented\n");
 }
@@ -125,7 +141,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
-			sfc_err(sa, "Unexpected MCDI proxy event");
+			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
 			emrp->emr_rc = EFAULT;
 		} else if (mcdi->proxy_result == 0) {
 			/*
@@ -136,9 +152,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
-			sfc_err(sa, "MCDI proxy authorization failed "
-				    "(handle=%08x, result=%d)",
-				    proxy_handle, mcdi->proxy_result);
+			sfc_efx_mcdi_err(mcdi,
+				"MCDI proxy authorization failed (handle=%08x, result=%d)",
+				proxy_handle, mcdi->proxy_result);
 		}
 	}
 
@@ -162,8 +178,9 @@ static void
 sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+	struct sfc_efx_mcdi *mcdi  = &sa->mcdi;
 
-	sfc_warn(sa, "MC %s",
+	sfc_efx_mcdi_warn(mcdi, "MC %s",
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
 	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
 
@@ -173,7 +190,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 #define SFC_MCDI_LOG_BUF_SIZE	128
 
 static size_t
-sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
+sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
 		char *buffer, void *data, size_t data_size,
 		size_t pfxsize, size_t position)
 {
@@ -189,7 +206,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa,
 			 * at the end which is required by netlogdecode.
 			 */
 			buffer[position] = '\0';
-			sfc_efx_log_mcdi(sa, "%s \\", buffer);
+			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
 			/* Preserve prefix for the next log message */
 			position = pfxsize;
 		}
@@ -207,6 +224,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *data, size_t data_size)
 {
 	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	char buffer[SFC_MCDI_LOG_BUF_SIZE];
 	size_t pfxsize;
 	size_t start;
@@ -218,7 +236,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	 *
 	 * To avoid wasting time, the actual level is examined in advance.
 	 */
-	if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
+	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
 		return;
 
 	/* The format including prefix added by sfc_efx_log_mcdi() is the
@@ -227,13 +245,13 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
 			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
 			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size,
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
 				    pfxsize, pfxsize);
-	start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size,
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
 				    pfxsize, start);
 	if (start != pfxsize) {
 		buffer[start] = '\0';
-		sfc_efx_log_mcdi(sa, "%s", buffer);
+		sfc_efx_log_mcdi(mcdi, "%s", buffer);
 	}
 }
 
@@ -248,30 +266,28 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
+sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
+		  uint32_t logtype, const char *log_prefix)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
-	sfc_log_init(sa, "entry");
-
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
+	mcdi->logtype = logtype;
+	mcdi->log_prefix = log_prefix;
+
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
 	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
 			   &mcdi->mem);
 	if (rc != 0)
 		goto fail_dma_alloc;
 
-	mcdi->logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
-					     SFC_LOGTYPE_MCDI_STR,
-					     RTE_LOG_NOTICE);
-
 	emtp = &mcdi->transport;
 	emtp->emt_context = sa;
 	emtp->emt_dma_mem = &mcdi->mem;
@@ -281,7 +297,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	emtp->emt_logger = sfc_efx_mcdi_logger;
 	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
-	sfc_log_init(sa, "init MCDI");
+	sfc_efx_mcdi_info(mcdi, "init MCDI");
 	rc = efx_mcdi_init(sa->nic, emtp);
 	if (rc != 0)
 		goto fail_mcdi_init;
@@ -302,8 +318,6 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 {
 	efx_mcdi_transport_t *emtp;
 
-	sfc_log_init(sa, "entry");
-
 	emtp = &mcdi->transport;
 
 	rte_spinlock_lock(&mcdi->lock);
@@ -311,7 +325,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
-	sfc_log_init(sa, "fini MCDI");
+	sfc_efx_mcdi_info(mcdi, "fini MCDI");
 	efx_mcdi_fini(sa->nic);
 	memset(emtp, 0, sizeof(*emtp));
 
@@ -323,11 +337,21 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
-	return sfc_efx_mcdi_init(sa, &sa->mcdi);
+	uint32_t logtype;
+
+	sfc_log_init(sa, "entry");
+
+	logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
+				       SFC_LOGTYPE_MCDI_STR,
+				       RTE_LOG_NOTICE);
+
+	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
+				 sa->priv.shared->log_prefix);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
+	sfc_log_init(sa, "entry");
 	sfc_efx_mcdi_fini(sa, &sa->mcdi);
 }
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 10f5bab666..0194825bfa 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -39,6 +39,7 @@ struct sfc_efx_mcdi {
 	uint32_t			logtype;
 	uint32_t			proxy_handle;
 	efx_rc_t			proxy_result;
+	const char			*log_prefix;
 };
 
 #ifdef __cplusplus
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 11/17] net/sfc: avoid usage of NIC pointer from adapter context
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (9 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 10/17] net/sfc: use own logging helper macros Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 12/17] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Prepare to avoid usage of the adapter context in common MCDI helpers.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 19 +++++++++++--------
 drivers/net/sfc/sfc_mcdi.h |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 5f6ad0a4aa..8f446e8bc8 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -75,6 +75,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 static void
 sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 {
+	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	efx_nic_t *enp;
 	unsigned int delay_total;
 	unsigned int delay_us;
@@ -82,7 +83,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 
 	delay_total = 0;
 	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
-	enp = sa->nic;
+	enp = mcdi->nic;
 
 	do {
 		boolean_t poll_completed;
@@ -127,10 +128,10 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
-	efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
 	sfc_efx_mcdi_poll(sa, B_FALSE);
 
-	if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
+	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
 		/*
 		 * Authorization is required for the MCDI request;
 		 * wait for an MCDI proxy response event to bring
@@ -148,7 +149,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * Authorization succeeded; re-issue the original
 			 * request and poll for an ordinary MCDI response
 			 */
-			efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
 			sfc_efx_mcdi_poll(sa, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
@@ -267,7 +268,7 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 
 static int
 sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix)
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
@@ -277,6 +278,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 
 	rte_spinlock_init(&mcdi->lock);
 
+	mcdi->nic = nic;
+
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
 
 	mcdi->logtype = logtype;
@@ -298,7 +301,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
 
 	sfc_efx_mcdi_info(mcdi, "init MCDI");
-	rc = efx_mcdi_init(sa->nic, emtp);
+	rc = efx_mcdi_init(mcdi->nic, emtp);
 	if (rc != 0)
 		goto fail_mcdi_init;
 
@@ -326,7 +329,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_efx_mcdi_info(mcdi, "fini MCDI");
-	efx_mcdi_fini(sa->nic);
+	efx_mcdi_fini(mcdi->nic);
 	memset(emtp, 0, sizeof(*emtp));
 
 	rte_spinlock_unlock(&mcdi->lock);
@@ -346,7 +349,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       RTE_LOG_NOTICE);
 
 	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
-				 sa->priv.shared->log_prefix);
+				 sa->priv.shared->log_prefix, sa->nic);
 }
 
 void
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 0194825bfa..e2105364ad 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -33,6 +33,7 @@ enum sfc_efx_mcdi_state {
 
 struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
+	efx_nic_t			*nic;
 	efsys_mem_t			mem;
 	enum sfc_efx_mcdi_state		state;
 	efx_mcdi_transport_t		transport;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 12/17] net/sfc: avoid panic in the case of MCDI timeout
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (10 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 11/17] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 13/17] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
                     ` (5 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Implement dummy MCDI timeout handling which simply rejects
further MCDI requests.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 8f446e8bc8..928a08c0a2 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -33,6 +33,9 @@
 				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
+#define sfc_efx_mcdi_crit(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
+
 #define sfc_efx_mcdi_err(mcdi, ...) \
 	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
 
@@ -55,7 +58,9 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
-	sfc_panic(sa, "MCDI timeout handling is not implemented\n");
+	mcdi->state = SFC_EFX_MCDI_DEAD;
+	sfc_efx_mcdi_crit(mcdi,
+		"MCDI timeout handling is not implemented - NIC is unusable");
 }
 
 static inline boolean_t
@@ -124,6 +129,11 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	uint32_t proxy_handle;
 
+	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
+		emrp->emr_rc = ENOEXEC;
+		return;
+	}
+
 	rte_spinlock_lock(&mcdi->lock);
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
@@ -325,7 +335,8 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
+		   mcdi->state == SFC_EFX_MCDI_DEAD);
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_efx_mcdi_info(mcdi, "fini MCDI");
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index e2105364ad..b93b268e32 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -27,6 +27,7 @@ enum sfc_efx_mcdi_state {
 	SFC_EFX_MCDI_INITIALIZED,
 	SFC_EFX_MCDI_BUSY,
 	SFC_EFX_MCDI_COMPLETED,
+	SFC_EFX_MCDI_DEAD,
 
 	SFC_EFX_MCDI_NSTATES
 };
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 13/17] net/sfc: add MCDI callbacks to allocate/free DMA memory
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (11 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 12/17] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 14/17] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Net driver should use rte_eth_dma_zone_reserve(), but it is ethdev
specific API which is not available for vDPA.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 46 +++++++++++++++++++++++++++++++-------
 drivers/net/sfc/sfc_mcdi.h | 12 ++++++++++
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 928a08c0a2..5077fcddd6 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -278,16 +278,22 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 
 static int
 sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic)
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
+		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
 {
 	size_t max_msg_size;
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL)
+		return EINVAL;
+
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
 
 	rte_spinlock_init(&mcdi->lock);
 
+	mcdi->ops = ops;
+	mcdi->ops_cookie = ops_cookie;
 	mcdi->nic = nic;
 
 	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
@@ -296,8 +302,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	mcdi->log_prefix = log_prefix;
 
 	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
-	rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id,
-			   &mcdi->mem);
+	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
 	if (rc != 0)
 		goto fail_dma_alloc;
 
@@ -319,7 +324,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 
 fail_mcdi_init:
 	memset(emtp, 0, sizeof(*emtp));
-	sfc_dma_free(sa, &mcdi->mem);
+	ops->dma_free(ops_cookie, &mcdi->mem);
 
 fail_dma_alloc:
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
@@ -327,7 +332,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 }
 
 static void
-sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
+sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
 {
 	efx_mcdi_transport_t *emtp;
 
@@ -345,9 +350,33 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 
 	rte_spinlock_unlock(&mcdi->lock);
 
-	sfc_dma_free(sa, &mcdi->mem);
+	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
+}
+
+static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
+static int
+sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
+		   efsys_mem_t *esmp)
+{
+	const struct sfc_adapter *sa = cookie;
+
+	return sfc_dma_alloc(sa, name, 0, len, sa->socket_id, esmp);
 }
 
+static sfc_efx_mcdi_dma_free_cb sfc_mcdi_dma_free;
+static void
+sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
+{
+	const struct sfc_adapter *sa = cookie;
+
+	sfc_dma_free(sa, esmp);
+}
+
+static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
+	.dma_alloc	= sfc_mcdi_dma_alloc,
+	.dma_free	= sfc_mcdi_dma_free,
+};
+
 int
 sfc_mcdi_init(struct sfc_adapter *sa)
 {
@@ -360,12 +389,13 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       RTE_LOG_NOTICE);
 
 	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
-				 sa->priv.shared->log_prefix, sa->nic);
+				 sa->priv.shared->log_prefix, sa->nic,
+				 &sfc_mcdi_ops, sa);
 }
 
 void
 sfc_mcdi_fini(struct sfc_adapter *sa)
 {
 	sfc_log_init(sa, "entry");
-	sfc_efx_mcdi_fini(sa, &sa->mcdi);
+	sfc_efx_mcdi_fini(&sa->mcdi);
 }
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index b93b268e32..ef24a8bc67 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -32,8 +32,20 @@ enum sfc_efx_mcdi_state {
 	SFC_EFX_MCDI_NSTATES
 };
 
+typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name,
+					  size_t len, efsys_mem_t *esmp);
+
+typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
+
+struct sfc_efx_mcdi_ops {
+	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
+	sfc_efx_mcdi_dma_free_cb	*dma_free;
+};
+
 struct sfc_efx_mcdi {
 	rte_spinlock_t			lock;
+	const struct sfc_efx_mcdi_ops	*ops;
+	void				*ops_cookie;
 	efx_nic_t			*nic;
 	efsys_mem_t			mem;
 	enum sfc_efx_mcdi_state		state;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 14/17] net/sfc: add MCDI callback to schedule restart
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (12 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 13/17] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 15/17] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
                     ` (3 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

MC reboot handling is driver specific.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  3 +++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 5077fcddd6..73dbd8194b 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -195,7 +195,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
 	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
 
-	sfc_schedule_restart(sa);
+	mcdi->ops->sched_restart(mcdi->ops_cookie);
 }
 
 #define SFC_MCDI_LOG_BUF_SIZE	128
@@ -285,7 +285,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	efx_mcdi_transport_t *emtp;
 	int rc;
 
-	if (ops->dma_alloc == NULL || ops->dma_free == NULL)
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
+	    ops->sched_restart == NULL)
 		return EINVAL;
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
@@ -372,9 +373,19 @@ sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
 	sfc_dma_free(sa, esmp);
 }
 
+static sfc_efx_mcdi_sched_restart_cb sfc_mcdi_sched_restart;
+static void
+sfc_mcdi_sched_restart(void *cookie)
+{
+	struct sfc_adapter *sa = cookie;
+
+	sfc_schedule_restart(sa);
+}
+
 static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
 	.dma_alloc	= sfc_mcdi_dma_alloc,
 	.dma_free	= sfc_mcdi_dma_free,
+	.sched_restart	= sfc_mcdi_sched_restart,
 };
 
 int
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index ef24a8bc67..8f9b1991be 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -37,9 +37,12 @@ typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name,
 
 typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
 
+typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie);
+
 struct sfc_efx_mcdi_ops {
 	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
 	sfc_efx_mcdi_dma_free_cb	*dma_free;
+	sfc_efx_mcdi_sched_restart_cb	*sched_restart;
 };
 
 struct sfc_efx_mcdi {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 15/17] net/sfc: add MCDI callback to poll management event queue
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (13 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 14/17] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 16/17] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
                     ` (2 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Management event queue polling is required in the case of
MCDI proxy authentication (client driver code).

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 14 ++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 73dbd8194b..fa9160f6d3 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -70,7 +70,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
-	sfc_ev_mgmt_qpoll(sa);
+	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
 	if (mcdi->proxy_result != ETIMEDOUT)
 		return B_TRUE;
 
@@ -286,7 +286,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 	int rc;
 
 	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
-	    ops->sched_restart == NULL)
+	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
 		return EINVAL;
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
@@ -382,10 +382,20 @@ sfc_mcdi_sched_restart(void *cookie)
 	sfc_schedule_restart(sa);
 }
 
+static sfc_efx_mcdi_mgmt_evq_poll_cb sfc_mcdi_mgmt_evq_poll;
+static void
+sfc_mcdi_mgmt_evq_poll(void *cookie)
+{
+	struct sfc_adapter *sa = cookie;
+
+	sfc_ev_mgmt_qpoll(sa);
+}
+
 static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
 	.dma_alloc	= sfc_mcdi_dma_alloc,
 	.dma_free	= sfc_mcdi_dma_free,
 	.sched_restart	= sfc_mcdi_sched_restart,
+	.mgmt_evq_poll	= sfc_mcdi_mgmt_evq_poll,
 };
 
 int
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index 8f9b1991be..e3a637aeb7 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -39,10 +39,13 @@ typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
 
 typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie);
 
+typedef void (sfc_efx_mcdi_mgmt_evq_poll_cb)(void *cookie);
+
 struct sfc_efx_mcdi_ops {
 	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
 	sfc_efx_mcdi_dma_free_cb	*dma_free;
 	sfc_efx_mcdi_sched_restart_cb	*sched_restart;
+	sfc_efx_mcdi_mgmt_evq_poll_cb	*mgmt_evq_poll;
 };
 
 struct sfc_efx_mcdi {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 16/17] net/sfc: use MCDI control structure as libefx ops context
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (14 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 15/17] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 17/17] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
  2020-09-21 22:38   ` [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library Ferruh Yigit
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

Now MCDI helpers interface is independent from network driver and
may be moved into common driver.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 47 +++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index fa9160f6d3..ff2bc14c5d 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -52,10 +52,8 @@
 	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
 
 static void
-sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
+sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
 	mcdi->state = SFC_EFX_MCDI_DEAD;
@@ -64,10 +62,8 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 }
 
 static inline boolean_t
-sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
+sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
-
 	mcdi->proxy_handle = 0;
 	mcdi->proxy_result = ETIMEDOUT;
 	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
@@ -78,9 +74,8 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa)
 }
 
 static void
-sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
+sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
 {
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	efx_nic_t *enp;
 	unsigned int delay_total;
 	unsigned int delay_us;
@@ -93,8 +88,9 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 	do {
 		boolean_t poll_completed;
 
-		poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) :
-					   efx_mcdi_request_poll(enp);
+		poll_completed = (proxy) ?
+				sfc_efx_mcdi_proxy_event_available(mcdi) :
+				efx_mcdi_request_poll(enp);
 		if (poll_completed)
 			return;
 
@@ -102,7 +98,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 			if (!proxy) {
 				aborted = efx_mcdi_request_abort(enp);
 				SFC_ASSERT(aborted);
-				sfc_efx_mcdi_timeout(sa);
+				sfc_efx_mcdi_timeout(mcdi);
 			}
 
 			return;
@@ -125,8 +121,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
 static void
 sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	uint32_t proxy_handle;
 
 	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
@@ -139,7 +134,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-	sfc_efx_mcdi_poll(sa, B_FALSE);
+	sfc_efx_mcdi_poll(mcdi, B_FALSE);
 
 	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
 		/*
@@ -148,7 +143,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 		 * a non-zero proxy handle (should be the same as
 		 * the value obtained above) and operation status
 		 */
-		sfc_efx_mcdi_poll(sa, B_TRUE);
+		sfc_efx_mcdi_poll(mcdi, B_TRUE);
 
 		if ((mcdi->proxy_handle != 0) &&
 		    (mcdi->proxy_handle != proxy_handle)) {
@@ -160,7 +155,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 			 * request and poll for an ordinary MCDI response
 			 */
 			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-			sfc_efx_mcdi_poll(sa, B_FALSE);
+			sfc_efx_mcdi_poll(mcdi, B_FALSE);
 		} else {
 			emrp->emr_rc = mcdi->proxy_result;
 			sfc_efx_mcdi_err(mcdi,
@@ -175,10 +170,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 static void
 sfc_efx_mcdi_ev_cpl(void *arg)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi __rte_unused;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
-	mcdi = &sa->mcdi;
+	RTE_SET_USED(mcdi);
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
 
 	/* MCDI is polled, completions are not expected */
@@ -188,8 +182,7 @@ sfc_efx_mcdi_ev_cpl(void *arg)
 static void
 sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi  = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	sfc_efx_mcdi_warn(mcdi, "MC %s",
 	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
@@ -234,8 +227,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 		void *header, size_t header_size,
 		void *data, size_t data_size)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 	char buffer[SFC_MCDI_LOG_BUF_SIZE];
 	size_t pfxsize;
 	size_t start;
@@ -269,15 +261,14 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
 static void
 sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
 {
-	struct sfc_adapter *sa = (struct sfc_adapter *)arg;
-	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
 
 	mcdi->proxy_handle = handle;
 	mcdi->proxy_result = result;
 }
 
 static int
-sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
+sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
 		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
 		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
 {
@@ -308,7 +299,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi,
 		goto fail_dma_alloc;
 
 	emtp = &mcdi->transport;
-	emtp->emt_context = sa;
+	emtp->emt_context = mcdi;
 	emtp->emt_dma_mem = &mcdi->mem;
 	emtp->emt_execute = sfc_efx_mcdi_execute;
 	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
@@ -409,7 +400,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
 				       SFC_LOGTYPE_MCDI_STR,
 				       RTE_LOG_NOTICE);
 
-	return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype,
+	return sfc_efx_mcdi_init(&sa->mcdi, logtype,
 				 sa->priv.shared->log_prefix, sa->nic,
 				 &sfc_mcdi_ops, sa);
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [dpdk-dev] [PATCH v2 17/17] net/sfc: move MCDI helpers to common driver
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (15 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 16/17] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
@ 2020-09-17  6:34   ` Andrew Rybchenko
  2020-09-21 22:38   ` [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library Ferruh Yigit
  17 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2020-09-17  6:34 UTC (permalink / raw)
  To: dev

These helper will be reused by other libefx consumers, e.g. vDPA
driver.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/meson.build            |   1 +
 .../sfc_efx/rte_common_sfc_efx_version.map    |   3 +
 drivers/common/sfc_efx/sfc_efx_mcdi.c         | 343 ++++++++++++++++++
 .../sfc_efx/sfc_efx_mcdi.h}                   |  14 +-
 drivers/net/sfc/sfc.h                         |   3 +-
 drivers/net/sfc/sfc_mcdi.c                    | 333 +----------------
 6 files changed, 361 insertions(+), 336 deletions(-)
 create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.c
 rename drivers/{net/sfc/sfc_mcdi.h => common/sfc_efx/sfc_efx_mcdi.h} (80%)

diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build
index 8fab4df792..b7a0763a34 100644
--- a/drivers/common/sfc_efx/meson.build
+++ b/drivers/common/sfc_efx/meson.build
@@ -34,6 +34,7 @@ objs = [base_objs]
 
 sources = files(
 	'sfc_efx.c',
+	'sfc_efx_mcdi.c',
 )
 
 includes += include_directories('base')
diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
index fa297d251b..5e2a7ad919 100644
--- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
+++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
@@ -178,5 +178,8 @@ INTERNAL {
 	efx_txq_nbufs;
 	efx_txq_size;
 
+	sfc_efx_mcdi_init;
+	sfc_efx_mcdi_fini;
+
 	local: *;
 };
diff --git a/drivers/common/sfc_efx/sfc_efx_mcdi.c b/drivers/common/sfc_efx/sfc_efx_mcdi.c
new file mode 100644
index 0000000000..7eb565bbd6
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx_mcdi.c
@@ -0,0 +1,343 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2016-2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#include <rte_cycles.h>
+
+#include "efx.h"
+#include "efx_mcdi.h"
+#include "efx_regs_mcdi.h"
+
+#include "sfc_efx_mcdi.h"
+#include "sfc_efx_debug.h"
+
+#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
+#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
+#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
+
+#define sfc_efx_mcdi_log(mcdi, level, ...) \
+	do {								\
+		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
+									\
+		rte_log(level, _mcdi->logtype,				\
+			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
+				_mcdi->log_prefix,			\
+				RTE_FMT_TAIL(__VA_ARGS__,)));		\
+	} while (0)
+
+#define sfc_efx_mcdi_crit(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
+
+#define sfc_efx_mcdi_err(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
+
+#define sfc_efx_mcdi_warn(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
+
+#define sfc_efx_mcdi_info(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
+
+/** Level value used by MCDI log statements */
+#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
+
+#define sfc_efx_log_mcdi(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
+
+static void
+sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
+{
+	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
+
+	sfc_efx_mcdi_crit(mcdi, "MCDI timeout handling is not implemented");
+	sfc_efx_mcdi_crit(mcdi, "NIC is unusable");
+	mcdi->state = SFC_EFX_MCDI_DEAD;
+}
+
+static inline boolean_t
+sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
+{
+	mcdi->proxy_handle = 0;
+	mcdi->proxy_result = ETIMEDOUT;
+	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
+	if (mcdi->proxy_result != ETIMEDOUT)
+		return B_TRUE;
+
+	return B_FALSE;
+}
+
+static void
+sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
+{
+	efx_nic_t *enp;
+	unsigned int delay_total;
+	unsigned int delay_us;
+	boolean_t aborted __rte_unused;
+
+	delay_total = 0;
+	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
+	enp = mcdi->nic;
+
+	do {
+		boolean_t poll_completed;
+
+		poll_completed = (proxy) ?
+				sfc_efx_mcdi_proxy_event_available(mcdi) :
+				efx_mcdi_request_poll(enp);
+		if (poll_completed)
+			return;
+
+		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
+			if (!proxy) {
+				aborted = efx_mcdi_request_abort(enp);
+				SFC_EFX_ASSERT(aborted);
+				sfc_efx_mcdi_timeout(mcdi);
+			}
+
+			return;
+		}
+
+		rte_delay_us(delay_us);
+
+		delay_total += delay_us;
+
+		/* Exponentially back off the poll frequency */
+		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
+				 UINT_MAX / 2);
+		delay_us *= 2;
+		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
+			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
+
+	} while (1);
+}
+
+static void
+sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+	uint32_t proxy_handle;
+
+	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
+		emrp->emr_rc = ENOEXEC;
+		return;
+	}
+
+	rte_spinlock_lock(&mcdi->lock);
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+
+	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
+	sfc_efx_mcdi_poll(mcdi, B_FALSE);
+
+	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
+		/*
+		 * Authorization is required for the MCDI request;
+		 * wait for an MCDI proxy response event to bring
+		 * a non-zero proxy handle (should be the same as
+		 * the value obtained above) and operation status
+		 */
+		sfc_efx_mcdi_poll(mcdi, B_TRUE);
+
+		if ((mcdi->proxy_handle != 0) &&
+		    (mcdi->proxy_handle != proxy_handle)) {
+			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
+			emrp->emr_rc = EFAULT;
+		} else if (mcdi->proxy_result == 0) {
+			/*
+			 * Authorization succeeded; re-issue the original
+			 * request and poll for an ordinary MCDI response
+			 */
+			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
+			sfc_efx_mcdi_poll(mcdi, B_FALSE);
+		} else {
+			emrp->emr_rc = mcdi->proxy_result;
+			sfc_efx_mcdi_err(mcdi,
+				"MCDI proxy authorization failed (handle=%08x, result=%d)",
+				proxy_handle, mcdi->proxy_result);
+		}
+	}
+
+	rte_spinlock_unlock(&mcdi->lock);
+}
+
+static void
+sfc_efx_mcdi_ev_cpl(void *arg)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	RTE_SET_USED(mcdi);
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+
+	/* MCDI is polled, completions are not expected */
+	SFC_EFX_ASSERT(0);
+}
+
+static void
+sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	sfc_efx_mcdi_warn(mcdi, "MC %s",
+	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
+	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
+
+	mcdi->ops->sched_restart(mcdi->ops_cookie);
+}
+
+#define SFC_MCDI_LOG_BUF_SIZE	128
+
+static size_t
+sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
+		char *buffer, void *data, size_t data_size,
+		size_t pfxsize, size_t position)
+{
+	uint32_t *words = data;
+	/* Space separator plus 2 characters per byte */
+	const size_t word_str_space = 1 + 2 * sizeof(*words);
+	size_t i;
+
+	for (i = 0; i < data_size; i += sizeof(*words)) {
+		if (position + word_str_space >=
+		    SFC_MCDI_LOG_BUF_SIZE) {
+			/* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash
+			 * at the end which is required by netlogdecode.
+			 */
+			buffer[position] = '\0';
+			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
+			/* Preserve prefix for the next log message */
+			position = pfxsize;
+		}
+		position += snprintf(buffer + position,
+				     SFC_MCDI_LOG_BUF_SIZE - position,
+				     " %08x", *words);
+		words++;
+	}
+	return position;
+}
+
+static void
+sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
+		void *header, size_t header_size,
+		void *data, size_t data_size)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+	char buffer[SFC_MCDI_LOG_BUF_SIZE];
+	size_t pfxsize;
+	size_t start;
+
+	/*
+	 * Unlike the other cases, MCDI logging implies more onerous work
+	 * needed to produce a message. If the dynamic log level prevents
+	 * the end result from being printed, the CPU time will be wasted.
+	 *
+	 * To avoid wasting time, the actual level is examined in advance.
+	 */
+	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
+		return;
+
+	/* The format including prefix added by sfc_efx_log_mcdi() is the
+	 * format consumed by the Solarflare netlogdecode tool.
+	 */
+	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
+			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
+			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
+				    pfxsize, pfxsize);
+	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
+				    pfxsize, start);
+	if (start != pfxsize) {
+		buffer[start] = '\0';
+		sfc_efx_log_mcdi(mcdi, "%s", buffer);
+	}
+}
+
+static void
+sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+{
+	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
+
+	mcdi->proxy_handle = handle;
+	mcdi->proxy_result = result;
+}
+
+int
+sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
+		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
+		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
+{
+	size_t max_msg_size;
+	efx_mcdi_transport_t *emtp;
+	int rc;
+
+	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
+	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
+		return EINVAL;
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
+
+	rte_spinlock_init(&mcdi->lock);
+
+	mcdi->ops = ops;
+	mcdi->ops_cookie = ops_cookie;
+	mcdi->nic = nic;
+
+	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
+
+	mcdi->logtype = logtype;
+	mcdi->log_prefix = log_prefix;
+
+	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
+	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
+	if (rc != 0)
+		goto fail_dma_alloc;
+
+	emtp = &mcdi->transport;
+	emtp->emt_context = mcdi;
+	emtp->emt_dma_mem = &mcdi->mem;
+	emtp->emt_execute = sfc_efx_mcdi_execute;
+	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
+	emtp->emt_exception = sfc_efx_mcdi_exception;
+	emtp->emt_logger = sfc_efx_mcdi_logger;
+	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
+
+	sfc_efx_mcdi_info(mcdi, "init MCDI");
+	rc = efx_mcdi_init(mcdi->nic, emtp);
+	if (rc != 0)
+		goto fail_mcdi_init;
+
+	return 0;
+
+fail_mcdi_init:
+	memset(emtp, 0, sizeof(*emtp));
+	ops->dma_free(ops_cookie, &mcdi->mem);
+
+fail_dma_alloc:
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
+	return rc;
+}
+
+void
+sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
+{
+	efx_mcdi_transport_t *emtp;
+
+	emtp = &mcdi->transport;
+
+	rte_spinlock_lock(&mcdi->lock);
+
+	SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
+		       mcdi->state == SFC_EFX_MCDI_DEAD);
+	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
+
+	sfc_efx_mcdi_info(mcdi, "fini MCDI");
+	efx_mcdi_fini(mcdi->nic);
+	memset(emtp, 0, sizeof(*emtp));
+
+	rte_spinlock_unlock(&mcdi->lock);
+
+	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
+}
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/common/sfc_efx/sfc_efx_mcdi.h
similarity index 80%
rename from drivers/net/sfc/sfc_mcdi.h
rename to drivers/common/sfc_efx/sfc_efx_mcdi.h
index e3a637aeb7..d75d9a7cfd 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/common/sfc_efx/sfc_efx_mcdi.h
@@ -7,8 +7,8 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
-#ifndef _SFC_MCDI_H
-#define _SFC_MCDI_H
+#ifndef _SFC_EFX_MCDI_H
+#define _SFC_EFX_MCDI_H
 
 #include <stdint.h>
 
@@ -62,8 +62,16 @@ struct sfc_efx_mcdi {
 	const char			*log_prefix;
 };
 
+__rte_internal
+int sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
+		      uint32_t logtype, const char *log_prefix,
+		      efx_nic_t *nic,
+		      const struct sfc_efx_mcdi_ops *ops, void *ops_cookie);
+__rte_internal
+void sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi);
+
 #ifdef __cplusplus
 }
 #endif
 
-#endif  /* _SFC_MCDI_H */
+#endif  /* _SFC_EFX_MCDI_H */
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index b20fecb4f8..fa7c79b80b 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -21,10 +21,11 @@
 
 #include "efx.h"
 
+#include "sfc_efx_mcdi.h"
+
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_filter.h"
-#include "sfc_mcdi.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index ff2bc14c5d..644dd9c980 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -7,344 +7,13 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
-#include <rte_cycles.h>
+#include "sfc_efx_mcdi.h"
 
-#include "efx.h"
-#include "efx_mcdi.h"
-#include "efx_regs_mcdi.h"
-
-#include "sfc_mcdi.h"
 #include "sfc.h"
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 
-#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US	10		/* 10us */
-#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US	(US_PER_S / 10)	/* 100ms */
-#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US	(10 * US_PER_S)	/* 10s */
-
-#define sfc_efx_mcdi_log(mcdi, level, ...) \
-	do {								\
-		const struct sfc_efx_mcdi *_mcdi = (mcdi);		\
-									\
-		rte_log(level, _mcdi->logtype,				\
-			RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",	\
-				_mcdi->log_prefix,			\
-				RTE_FMT_TAIL(__VA_ARGS__,)));		\
-	} while (0)
-
-#define sfc_efx_mcdi_crit(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
-
-#define sfc_efx_mcdi_err(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
-
-#define sfc_efx_mcdi_warn(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__)
-
-#define sfc_efx_mcdi_info(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__)
-
-/** Level value used by MCDI log statements */
-#define SFC_EFX_LOG_LEVEL_MCDI	RTE_LOG_INFO
-
-#define sfc_efx_log_mcdi(mcdi, ...) \
-	sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__)
-
-static void
-sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi)
-{
-	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
-
-	mcdi->state = SFC_EFX_MCDI_DEAD;
-	sfc_efx_mcdi_crit(mcdi,
-		"MCDI timeout handling is not implemented - NIC is unusable");
-}
-
-static inline boolean_t
-sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi)
-{
-	mcdi->proxy_handle = 0;
-	mcdi->proxy_result = ETIMEDOUT;
-	mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie);
-	if (mcdi->proxy_result != ETIMEDOUT)
-		return B_TRUE;
-
-	return B_FALSE;
-}
-
-static void
-sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy)
-{
-	efx_nic_t *enp;
-	unsigned int delay_total;
-	unsigned int delay_us;
-	boolean_t aborted __rte_unused;
-
-	delay_total = 0;
-	delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US;
-	enp = mcdi->nic;
-
-	do {
-		boolean_t poll_completed;
-
-		poll_completed = (proxy) ?
-				sfc_efx_mcdi_proxy_event_available(mcdi) :
-				efx_mcdi_request_poll(enp);
-		if (poll_completed)
-			return;
-
-		if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) {
-			if (!proxy) {
-				aborted = efx_mcdi_request_abort(enp);
-				SFC_ASSERT(aborted);
-				sfc_efx_mcdi_timeout(mcdi);
-			}
-
-			return;
-		}
-
-		rte_delay_us(delay_us);
-
-		delay_total += delay_us;
-
-		/* Exponentially back off the poll frequency */
-		RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US >
-				 UINT_MAX / 2);
-		delay_us *= 2;
-		if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US)
-			delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US;
-
-	} while (1);
-}
-
-static void
-sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-	uint32_t proxy_handle;
-
-	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
-		emrp->emr_rc = ENOEXEC;
-		return;
-	}
-
-	rte_spinlock_lock(&mcdi->lock);
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
-
-	efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-	sfc_efx_mcdi_poll(mcdi, B_FALSE);
-
-	if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) {
-		/*
-		 * Authorization is required for the MCDI request;
-		 * wait for an MCDI proxy response event to bring
-		 * a non-zero proxy handle (should be the same as
-		 * the value obtained above) and operation status
-		 */
-		sfc_efx_mcdi_poll(mcdi, B_TRUE);
-
-		if ((mcdi->proxy_handle != 0) &&
-		    (mcdi->proxy_handle != proxy_handle)) {
-			sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event");
-			emrp->emr_rc = EFAULT;
-		} else if (mcdi->proxy_result == 0) {
-			/*
-			 * Authorization succeeded; re-issue the original
-			 * request and poll for an ordinary MCDI response
-			 */
-			efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE);
-			sfc_efx_mcdi_poll(mcdi, B_FALSE);
-		} else {
-			emrp->emr_rc = mcdi->proxy_result;
-			sfc_efx_mcdi_err(mcdi,
-				"MCDI proxy authorization failed (handle=%08x, result=%d)",
-				proxy_handle, mcdi->proxy_result);
-		}
-	}
-
-	rte_spinlock_unlock(&mcdi->lock);
-}
-
-static void
-sfc_efx_mcdi_ev_cpl(void *arg)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	RTE_SET_USED(mcdi);
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
-
-	/* MCDI is polled, completions are not expected */
-	SFC_ASSERT(0);
-}
-
-static void
-sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	sfc_efx_mcdi_warn(mcdi, "MC %s",
-	    (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" :
-	    (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN");
-
-	mcdi->ops->sched_restart(mcdi->ops_cookie);
-}
-
-#define SFC_MCDI_LOG_BUF_SIZE	128
-
-static size_t
-sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi,
-		char *buffer, void *data, size_t data_size,
-		size_t pfxsize, size_t position)
-{
-	uint32_t *words = data;
-	/* Space separator plus 2 characters per byte */
-	const size_t word_str_space = 1 + 2 * sizeof(*words);
-	size_t i;
-
-	for (i = 0; i < data_size; i += sizeof(*words)) {
-		if (position + word_str_space >=
-		    SFC_MCDI_LOG_BUF_SIZE) {
-			/* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash
-			 * at the end which is required by netlogdecode.
-			 */
-			buffer[position] = '\0';
-			sfc_efx_log_mcdi(mcdi, "%s \\", buffer);
-			/* Preserve prefix for the next log message */
-			position = pfxsize;
-		}
-		position += snprintf(buffer + position,
-				     SFC_MCDI_LOG_BUF_SIZE - position,
-				     " %08x", *words);
-		words++;
-	}
-	return position;
-}
-
-static void
-sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type,
-		void *header, size_t header_size,
-		void *data, size_t data_size)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-	char buffer[SFC_MCDI_LOG_BUF_SIZE];
-	size_t pfxsize;
-	size_t start;
-
-	/*
-	 * Unlike the other cases, MCDI logging implies more onerous work
-	 * needed to produce a message. If the dynamic log level prevents
-	 * the end result from being printed, the CPU time will be wasted.
-	 *
-	 * To avoid wasting time, the actual level is examined in advance.
-	 */
-	if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI)
-		return;
-
-	/* The format including prefix added by sfc_efx_log_mcdi() is the
-	 * format consumed by the Solarflare netlogdecode tool.
-	 */
-	pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:",
-			   type == EFX_LOG_MCDI_REQUEST ? "REQ" :
-			   type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???");
-	start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size,
-				    pfxsize, pfxsize);
-	start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size,
-				    pfxsize, start);
-	if (start != pfxsize) {
-		buffer[start] = '\0';
-		sfc_efx_log_mcdi(mcdi, "%s", buffer);
-	}
-}
-
-static void
-sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
-{
-	struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg;
-
-	mcdi->proxy_handle = handle;
-	mcdi->proxy_result = result;
-}
-
-static int
-sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
-		  uint32_t logtype, const char *log_prefix, efx_nic_t *nic,
-		  const struct sfc_efx_mcdi_ops *ops, void *ops_cookie)
-{
-	size_t max_msg_size;
-	efx_mcdi_transport_t *emtp;
-	int rc;
-
-	if (ops->dma_alloc == NULL || ops->dma_free == NULL ||
-	    ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL)
-		return EINVAL;
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED);
-
-	rte_spinlock_init(&mcdi->lock);
-
-	mcdi->ops = ops;
-	mcdi->ops_cookie = ops_cookie;
-	mcdi->nic = nic;
-
-	mcdi->state = SFC_EFX_MCDI_INITIALIZED;
-
-	mcdi->logtype = logtype;
-	mcdi->log_prefix = log_prefix;
-
-	max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2;
-	rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem);
-	if (rc != 0)
-		goto fail_dma_alloc;
-
-	emtp = &mcdi->transport;
-	emtp->emt_context = mcdi;
-	emtp->emt_dma_mem = &mcdi->mem;
-	emtp->emt_execute = sfc_efx_mcdi_execute;
-	emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl;
-	emtp->emt_exception = sfc_efx_mcdi_exception;
-	emtp->emt_logger = sfc_efx_mcdi_logger;
-	emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response;
-
-	sfc_efx_mcdi_info(mcdi, "init MCDI");
-	rc = efx_mcdi_init(mcdi->nic, emtp);
-	if (rc != 0)
-		goto fail_mcdi_init;
-
-	return 0;
-
-fail_mcdi_init:
-	memset(emtp, 0, sizeof(*emtp));
-	ops->dma_free(ops_cookie, &mcdi->mem);
-
-fail_dma_alloc:
-	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
-	return rc;
-}
-
-static void
-sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi)
-{
-	efx_mcdi_transport_t *emtp;
-
-	emtp = &mcdi->transport;
-
-	rte_spinlock_lock(&mcdi->lock);
-
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
-		   mcdi->state == SFC_EFX_MCDI_DEAD);
-	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
-
-	sfc_efx_mcdi_info(mcdi, "fini MCDI");
-	efx_mcdi_fini(mcdi->nic);
-	memset(emtp, 0, sizeof(*emtp));
-
-	rte_spinlock_unlock(&mcdi->lock);
-
-	mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem);
-}
-
 static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
 static int
 sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library
  2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
                     ` (16 preceding siblings ...)
  2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 17/17] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
@ 2020-09-21 22:38   ` Ferruh Yigit
  17 siblings, 0 replies; 38+ messages in thread
From: Ferruh Yigit @ 2020-09-21 22:38 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: Thomas Monjalon, David Marchand

On 9/17/2020 7:34 AM, Andrew Rybchenko wrote:
> Network and vDPA drivers share libefx. So, libefx should be moved
> to common drivers.
> 
> DPDK adaptation of the MCDI interface may be shared as well.
> 
> The new common driver name is sfc_efx since it a new home of
> libefx base driver. sfc_ prefix is used to make it clear that
> it is related to net/sfc (and vdpa/sfc in the future).
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: David Marchand <david.marchand@redhat.com>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> v2:
>   - add patches to introduce LIBEFX_API and LIBEFX_INTERNAL
>     global functions decorators
>   - use LIBEFX_API for __rte_internal markup
> 
> Andrew Rybchenko (17):
>    net/sfc/base: add missing extern storage-class specifiers
>    net/sfc/base: decorate libefx API functions
>    net/sfc/base: decorate libefx internal extern functions
>    net/sfc: include header with debug helpers directly
>    net/sfc: introduce common driver library
>    net/sfc: add dedicated header file with MCDI interface
>    net/sfc: move MCDI helper interface to dedicated namespace
>    net/sfc: make MCDI logging helper macros local
>    net/sfc: start to make MCDI helpers interface shareable
>    net/sfc: use own logging helper macros
>    net/sfc: avoid usage of NIC pointer from adapter context
>    net/sfc: avoid panic in the case of MCDI timeout
>    net/sfc: add MCDI callbacks to allocate/free DMA memory
>    net/sfc: add MCDI callback to schedule restart
>    net/sfc: add MCDI callback to poll management event queue
>    net/sfc: use MCDI control structure as libefx ops context
>    net/sfc: move MCDI helpers to common driver
> 

Series applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2020-09-21 22:38 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  9:14 [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/iavf: downgrade error log Andrew Rybchenko
2020-09-08  9:26   ` Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
2020-09-08  9:14 ` [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
2020-09-09 14:32 ` [dpdk-dev] [PATCH 00/14] net/sfc: factor out common driver library Ferruh Yigit
2020-09-17  6:21   ` Andrew Rybchenko
2020-09-17  6:34 ` [dpdk-dev] [PATCH v2 00/17] " Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 01/17] net/sfc/base: add missing extern storage-class specifiers Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 02/17] net/sfc/base: decorate libefx API functions Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 03/17] net/sfc/base: decorate libefx internal extern functions Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 04/17] net/sfc: include header with debug helpers directly Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 05/17] net/sfc: introduce common driver library Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 06/17] net/sfc: add dedicated header file with MCDI interface Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 07/17] net/sfc: move MCDI helper interface to dedicated namespace Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 08/17] net/sfc: make MCDI logging helper macros local Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 09/17] net/sfc: start to make MCDI helpers interface shareable Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 10/17] net/sfc: use own logging helper macros Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 11/17] net/sfc: avoid usage of NIC pointer from adapter context Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 12/17] net/sfc: avoid panic in the case of MCDI timeout Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 13/17] net/sfc: add MCDI callbacks to allocate/free DMA memory Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 14/17] net/sfc: add MCDI callback to schedule restart Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 15/17] net/sfc: add MCDI callback to poll management event queue Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 16/17] net/sfc: use MCDI control structure as libefx ops context Andrew Rybchenko
2020-09-17  6:34   ` [dpdk-dev] [PATCH v2 17/17] net/sfc: move MCDI helpers to common driver Andrew Rybchenko
2020-09-21 22:38   ` [dpdk-dev] [PATCH v2 00/17] net/sfc: factor out common driver library Ferruh Yigit

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git