From: Andrew Rybchenko Date: Thu, 7 Feb 2019 12:17:44 +0000 (+0000) Subject: net/sfc: start to factor out multi-process shared data X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1d3c7f9c0f261814aa4327ece768547c09e4240e;p=dpdk.git net/sfc: start to factor out multi-process shared data sfc_adapter structure will become primary process only private data. Start to factor out shared data into dedicated structure which will become separate structure finally. Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 7e95170bcb..766336f8cf 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -174,8 +174,15 @@ struct sfc_rss { uint8_t key[EFX_RSS_KEY_SIZE]; }; +/* Adapter private data shared by primary and secondary processes */ +struct sfc_adapter_shared { + struct rte_pci_addr pci_addr; + uint16_t port_id; +}; + /* Adapter process private data */ struct sfc_adapter_priv { + struct sfc_adapter_shared *shared; const struct sfc_dp_rx *dp_rx; const struct sfc_dp_tx *dp_tx; uint32_t logtype_main; @@ -199,6 +206,12 @@ struct sfc_adapter { */ struct sfc_adapter_priv priv; + /* + * Temporary placeholder for multi-process shared data for + * transition. + */ + struct sfc_adapter_shared _shared; + /* * PMD setup and configuration is not thread safe. Since it is not * performance sensitive, it is better to guarantee thread-safety @@ -207,8 +220,6 @@ struct sfc_adapter { */ rte_spinlock_t lock; enum sfc_adapter_state state; - struct rte_pci_addr pci_addr; - uint16_t port_id; struct rte_eth_dev *eth_dev; struct rte_kvargs *kvargs; int socket_id; diff --git a/drivers/net/sfc/sfc_debug.h b/drivers/net/sfc/sfc_debug.h index 62f3937e8a..ea1b43295f 100644 --- a/drivers/net/sfc/sfc_debug.h +++ b/drivers/net/sfc/sfc_debug.h @@ -25,13 +25,14 @@ /* Log PMD message, automatically add prefix and \n */ #define sfc_panic(sa, fmt, args...) \ do { \ - const struct sfc_adapter *_sa = (sa); \ + const struct sfc_adapter_shared *_sas; \ \ + _sas = (sa)->priv.shared; \ rte_panic("sfc " PCI_PRI_FMT \ " #%" PRIu16 ": " fmt "\n", \ - _sa->pci_addr.domain, _sa->pci_addr.bus, \ - _sa->pci_addr.devid, _sa->pci_addr.function, \ - _sa->port_id, ##args); \ + _sas->pci_addr.domain, _sas->pci_addr.bus, \ + _sas->pci_addr.devid, _sas->pci_addr.function,\ + _sas->port_id, ##args); \ } while (0) #endif /* _SFC_DEBUG_H_ */ diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index aa857ec74b..88dbecd465 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2023,6 +2023,7 @@ static int sfc_eth_dev_init(struct rte_eth_dev *dev) { struct sfc_adapter *sa = dev->data->dev_private; + struct sfc_adapter_shared *sas; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); uint32_t logtype_main; int rc; @@ -2035,6 +2036,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) SFC_LOGTYPE_MAIN_STR, RTE_LOG_NOTICE); + sa->priv.shared = &sa->_shared; + sas = sa->priv.shared; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -sfc_eth_dev_secondary_init(dev, logtype_main); @@ -2047,8 +2051,8 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) dev->process_private = sa; /* Required for logging */ - sa->pci_addr = pci_dev->addr; - sa->port_id = dev->data->port_id; + sas->pci_addr = pci_dev->addr; + sas->port_id = dev->data->port_id; sa->priv.logtype_main = logtype_main; sa->eth_dev = dev; diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h index 405cc2a26e..97de9ae535 100644 --- a/drivers/net/sfc/sfc_log.h +++ b/drivers/net/sfc/sfc_log.h @@ -34,17 +34,18 @@ extern uint32_t sfc_logtype_driver; /* Log PMD message, automatically add prefix and \n */ #define SFC_LOG(sa, level, type, ...) \ do { \ - const struct sfc_adapter *__sa = (sa); \ + const struct sfc_adapter_shared *_sas; \ \ + _sas = (sa)->priv.shared; \ rte_log(level, type, \ RTE_FMT("PMD: sfc_efx " \ PCI_PRI_FMT " #%" PRIu16 \ ": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ - __sa->pci_addr.domain, \ - __sa->pci_addr.bus, \ - __sa->pci_addr.devid, \ - __sa->pci_addr.function, \ - __sa->port_id, \ + _sas->pci_addr.domain, \ + _sas->pci_addr.bus, \ + _sas->pci_addr.devid, \ + _sas->pci_addr.function, \ + _sas->port_id, \ RTE_FMT_TAIL(__VA_ARGS__,))); \ } while (0) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index e485e07d63..dede33688a 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -256,7 +256,7 @@ sfc_mcdi_init(struct sfc_adapter *sa) if (rc != 0) goto fail_dma_alloc; - mcdi->logtype = sfc_register_logtype(&sa->pci_addr, + mcdi->logtype = sfc_register_logtype(&sa->priv.shared->pci_addr, SFC_LOGTYPE_MCDI_STR, RTE_LOG_NOTICE);