From: Andrew Rybchenko Date: Thu, 18 May 2017 14:00:03 +0000 (+0100) Subject: net/sfc: use locally stored data for logging X-Git-Tag: spdx-start~3149 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b7be9f4349cf5f5c84b02eb52302c7e09b5c64d1;p=dpdk.git net/sfc: use locally stored data for logging 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 Reviewed-by: Andy Moreton --- diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 7927678a69..772a713a07 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -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; diff --git a/drivers/net/sfc/sfc_debug.h b/drivers/net/sfc/sfc_debug.h index f4fe044401..92eba9c382 100644 --- a/drivers/net/sfc/sfc_debug.h +++ b/drivers/net/sfc/sfc_debug.h @@ -47,14 +47,12 @@ /* 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_ */ diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index c4d74d0dd0..0660a000cf 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -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 */ diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h index d0f89215d7..b1a9df4476 100644 --- a/drivers/net/sfc/sfc_log.h +++ b/drivers/net/sfc/sfc_log.h @@ -35,18 +35,16 @@ /* 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)