net/sfc: start to factor out multi-process shared data
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 7 Feb 2019 12:17:44 +0000 (12:17 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 7 Feb 2019 15:06:30 +0000 (16:06 +0100)
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 <arybchenko@solarflare.com>
drivers/net/sfc/sfc.h
drivers/net/sfc/sfc_debug.h
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_log.h
drivers/net/sfc/sfc_mcdi.c

index 7e95170..766336f 100644 (file)
@@ -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;
index 62f3937..ea1b432 100644 (file)
 /* 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_ */
index aa857ec..88dbecd 100644 (file)
@@ -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;
index 405cc2a..97de9ae 100644 (file)
@@ -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)
 
index e485e07..dede336 100644 (file)
@@ -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);