From 36653b7d853082fed65275721525dc6087e22711 Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Thu, 7 Feb 2019 12:17:46 +0000 Subject: [PATCH] net/sfc: make main logging macro reusable in secondary Logging should be supported in secondary process and now we have everything required to share at least main logging macro. sfc_adapter is going to become primary process only. Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ethdev.c | 14 ++++---------- drivers/net/sfc/sfc_log.h | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 9f00363753..e30217cf1c 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1922,12 +1922,6 @@ static const struct eth_dev_ops sfc_eth_dev_secondary_ops = { static int sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main) { - /* - * Device private data has really many process-local pointers. - * Below code should be extremely careful to use data located - * in shared memory only. - */ - struct sfc_adapter *sa = dev->data->dev_private; struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev); struct sfc_adapter_priv *sap; const struct sfc_dp_rx *dp_rx; @@ -1948,13 +1942,13 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main) dp_rx = sfc_dp_find_rx_by_name(&sfc_dp_head, sas->dp_rx_name); if (dp_rx == NULL) { - SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + SFC_LOG(sas, RTE_LOG_ERR, logtype_main, "cannot find %s Rx datapath", sas->dp_rx_name); rc = ENOENT; goto fail_dp_rx; } if (~dp_rx->features & SFC_DP_RX_FEAT_MULTI_PROCESS) { - SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + SFC_LOG(sas, RTE_LOG_ERR, logtype_main, "%s Rx datapath does not support multi-process", sas->dp_rx_name); rc = EINVAL; @@ -1963,13 +1957,13 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main) dp_tx = sfc_dp_find_tx_by_name(&sfc_dp_head, sas->dp_tx_name); if (dp_tx == NULL) { - SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + SFC_LOG(sas, RTE_LOG_ERR, logtype_main, "cannot find %s Tx datapath", sas->dp_tx_name); rc = ENOENT; goto fail_dp_tx; } if (~dp_tx->features & SFC_DP_TX_FEAT_MULTI_PROCESS) { - SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + SFC_LOG(sas, RTE_LOG_ERR, logtype_main, "%s Tx datapath does not support multi-process", sas->dp_tx_name); rc = EINVAL; diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h index 97de9ae535..62c4f4dd16 100644 --- a/drivers/net/sfc/sfc_log.h +++ b/drivers/net/sfc/sfc_log.h @@ -32,11 +32,10 @@ extern uint32_t sfc_logtype_driver; #define SFC_LOG_LEVEL_MCDI RTE_LOG_INFO /* Log PMD message, automatically add prefix and \n */ -#define SFC_LOG(sa, level, type, ...) \ +#define SFC_LOG(sas, level, type, ...) \ do { \ - const struct sfc_adapter_shared *_sas; \ + const struct sfc_adapter_shared *_sas = (sas); \ \ - _sas = (sa)->priv.shared; \ rte_log(level, type, \ RTE_FMT("PMD: sfc_efx " \ PCI_PRI_FMT " #%" PRIu16 \ @@ -53,39 +52,40 @@ extern uint32_t sfc_logtype_driver; do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, RTE_LOG_ERR, _sa->priv.logtype_main, \ - __VA_ARGS__); \ + SFC_LOG(_sa->priv.shared, RTE_LOG_ERR, \ + _sa->priv.logtype_main, __VA_ARGS__); \ } while (0) #define sfc_warn(sa, ...) \ do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, RTE_LOG_WARNING, _sa->priv.logtype_main, \ - __VA_ARGS__); \ + SFC_LOG(_sa->priv.shared, RTE_LOG_WARNING, \ + _sa->priv.logtype_main, __VA_ARGS__); \ } while (0) #define sfc_notice(sa, ...) \ do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, RTE_LOG_NOTICE, _sa->priv.logtype_main, \ - __VA_ARGS__); \ + SFC_LOG(_sa->priv.shared, RTE_LOG_NOTICE, \ + _sa->priv.logtype_main, __VA_ARGS__); \ } while (0) #define sfc_info(sa, ...) \ do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, RTE_LOG_INFO, _sa->priv.logtype_main, \ - __VA_ARGS__); \ + SFC_LOG(_sa->priv.shared, RTE_LOG_INFO, \ + _sa->priv.logtype_main, __VA_ARGS__); \ } while (0) #define sfc_log_init(sa, ...) \ do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, RTE_LOG_INFO, _sa->priv.logtype_main, \ + SFC_LOG(_sa->priv.shared, RTE_LOG_INFO, \ + _sa->priv.logtype_main, \ RTE_FMT("%s(): " \ RTE_FMT_HEAD(__VA_ARGS__ ,), \ __func__, \ @@ -96,8 +96,8 @@ extern uint32_t sfc_logtype_driver; do { \ const struct sfc_adapter *_sa = (sa); \ \ - SFC_LOG(_sa, SFC_LOG_LEVEL_MCDI, _sa->mcdi.logtype, \ - __VA_ARGS__); \ + SFC_LOG(_sa->priv.shared, SFC_LOG_LEVEL_MCDI, \ + _sa->mcdi.logtype, __VA_ARGS__); \ } while (0) -- 2.20.1