net/sfc: use locally stored data for logging
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 18 May 2017 14:00:03 +0000 (15:00 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:26 +0000 (10:41 +0100)
Required to be able to use logging in the secondary process
where Ethernet device pointer stored in sfc_adapter is invalid.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@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

index 7927678..772a713 100644 (file)
@@ -179,6 +179,8 @@ 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;
        bool                            debug_init;
index f4fe044..92eba9c 100644 (file)
 /* Log PMD message, automatically add prefix and \n */
 #define sfc_panic(sa, fmt, args...) \
        do {                                                            \
-               const struct rte_eth_dev *_dev = (sa)->eth_dev;         \
-               const struct rte_pci_device *_pci_dev =                 \
-                       RTE_ETH_DEV_TO_PCI(_dev);                       \
+               const struct sfc_adapter *_sa = (sa);                   \
                                                                        \
                rte_panic("sfc " PCI_PRI_FMT " #%" PRIu8 ": " fmt "\n", \
-                         _pci_dev->addr.domain, _pci_dev->addr.bus,    \
-                         _pci_dev->addr.devid, _pci_dev->addr.function,\
-                         _dev->data->port_id, ##args);                 \
+                         _sa->pci_addr.domain, _sa->pci_addr.bus,      \
+                         _sa->pci_addr.devid, _sa->pci_addr.function,  \
+                         _sa->port_id, ##args);                        \
        } while (0)
 
 #endif /* _SFC_DEBUG_H_ */
index c4d74d0..0660a00 100644 (file)
@@ -1513,6 +1513,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
        sfc_register_dp();
 
        /* Required for logging */
+       sa->pci_addr = pci_dev->addr;
+       sa->port_id = dev->data->port_id;
+
        sa->eth_dev = dev;
 
        /* Copy PCI device info to the dev->data */
index d0f8921..b1a9df4 100644 (file)
 /* Log PMD message, automatically add prefix and \n */
 #define SFC_LOG(sa, level, ...) \
        do {                                                            \
-               const struct rte_eth_dev *_dev = (sa)->eth_dev;         \
-               const struct rte_pci_device *_pci_dev =                 \
-                       RTE_ETH_DEV_TO_PCI(_dev);                       \
+               const struct sfc_adapter *__sa = (sa);                  \
                                                                        \
                RTE_LOG(level, PMD,                                     \
                        RTE_FMT("sfc_efx " PCI_PRI_FMT " #%" PRIu8 ": " \
                                RTE_FMT_HEAD(__VA_ARGS__,) "\n",        \
-                               _pci_dev->addr.domain,                  \
-                               _pci_dev->addr.bus,                     \
-                               _pci_dev->addr.devid,                   \
-                               _pci_dev->addr.function,                \
-                               _dev->data->port_id,                    \
+                               __sa->pci_addr.domain,                  \
+                               __sa->pci_addr.bus,                     \
+                               __sa->pci_addr.devid,                   \
+                               __sa->pci_addr.function,                \
+                               __sa->port_id,                          \
                                RTE_FMT_TAIL(__VA_ARGS__,)));           \
        } while (0)