[dpdk-dev,2/3] net/sfc: use locally stored data for logging

Message ID 1495023908-10977-2-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Andrew Rybchenko May 17, 2017, 12:25 p.m. UTC
  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        |  2 ++
 drivers/net/sfc/sfc_debug.h  | 10 ++++------
 drivers/net/sfc/sfc_ethdev.c |  3 +++
 drivers/net/sfc/sfc_log.h    | 14 ++++++--------
 4 files changed, 15 insertions(+), 14 deletions(-)
  

Comments

Ferruh Yigit May 18, 2017, 10:59 a.m. UTC | #1
On 5/17/2017 1:25 PM, Andrew Rybchenko wrote:
> 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>

<...>

> diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
> index d0f8921..6c43925 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);			\

Getting following build error with clang and icc [1]. I guess that is
because "_sa" declared on both sfc_log_init() and in the macro that
function uses (SFC_LOG).

[1]
.../drivers/net/sfc/sfc_filter.c:121:2:
error: variable '_sa' is uninitialized when used within its own
initialization [-Werror,-Wuninitialized]
        sfc_log_init(sa, "failed %d", rc);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/sfc/sfc_log.h:68:12: note: expanded from macro
'sfc_log_init'
        SFC_LOG(_sa, INFO,                              \
        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/sfc/sfc_log.h:38:36: note: expanded from macro 'SFC_LOG'
        const struct sfc_adapter *_sa = (sa);           \
                                 ~~~    ^~
  
Andrew Rybchenko May 18, 2017, 2:01 p.m. UTC | #2
On 05/18/2017 01:59 PM, Ferruh Yigit wrote:
> On 5/17/2017 1:25 PM, Andrew Rybchenko wrote:
>> 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>
> <...>
>
>> diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
>> index d0f8921..6c43925 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);			\
> Getting following build error with clang and icc [1]. I guess that is
> because "_sa" declared on both sfc_log_init() and in the macro that
> function uses (SFC_LOG).

Thanks, I'll fix it in v2.

> [1]
> .../drivers/net/sfc/sfc_filter.c:121:2:
> error: variable '_sa' is uninitialized when used within its own
> initialization [-Werror,-Wuninitialized]
>          sfc_log_init(sa, "failed %d", rc);
>          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> .../drivers/net/sfc/sfc_log.h:68:12: note: expanded from macro
> 'sfc_log_init'
>          SFC_LOG(_sa, INFO,                              \
>          ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> .../drivers/net/sfc/sfc_log.h:38:36: note: expanded from macro 'SFC_LOG'
>          const struct sfc_adapter *_sa = (sa);           \
>                                   ~~~    ^~
  

Patch

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 7927678..772a713 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 f4fe044..92eba9c 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 e4f051a..d6bba1d 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 d0f8921..6c43925 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)