[v2] net/hinic: fix secondary process's using coredump.

Message ID 238443d2-512d-185d-945e-6c77815f7888@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/hinic: fix secondary process's using coredump. |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Qingqing Li Aug. 8, 2020, 7:45 a.m. UTC
  fix coredump when secondary process using the hinic port.
the reason is that during the stage of
secondary process port initialization,
it lack the initialization of "eth_dev->dev_ops".

Signed-off-by: liqingqing <liqingqing3@huawei.com>
---
v2:  solve the coding style issue.
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
  

Comments

Ferruh Yigit Sept. 1, 2020, 11:44 a.m. UTC | #1
On 8/8/2020 8:45 AM, liqingqing wrote:
> fix coredump when secondary process using the hinic port.
> the reason is that during the stage of
> secondary process port initialization,
> it lack the initialization of "eth_dev->dev_ops".
> 
> Signed-off-by: liqingqing <liqingqing3@huawei.com>

Hi,

Overall patch looks good but can you please add your name and surname to the
sign off, to make it following syntax:
Signed-off-by: Name Surname <liqingqing3@huawei.com>

Also what do you think about following patch title:
"net/hinic: fix crash in secondary process"


> ---
> v2:  solve the coding style issue.
> ---
>  drivers/net/hinic/hinic_pmd_ethdev.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
> index 67e6afcf7..26c6098d3 100644
> --- a/drivers/net/hinic/hinic_pmd_ethdev.c
> +++ b/drivers/net/hinic/hinic_pmd_ethdev.c
> @@ -3060,15 +3060,6 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
>  	int rc;
> 
>  	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
> -
> -	/* EAL is SECONDARY and eth_dev is already created */
> -	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
> -		PMD_DRV_LOG(INFO, "Initialize %s in secondary process",
> -			    eth_dev->data->name);
> -
> -		return 0;
> -	}
> -
>  	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
>  	memset(nic_dev, 0, sizeof(*nic_dev));
> 
> @@ -3206,6 +3197,18 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev)
>  	eth_dev->rx_pkt_burst = hinic_recv_pkts;
>  	eth_dev->tx_pkt_burst = hinic_xmit_pkts;
> 
> +	/* EAL is SECONDARY and eth_dev is already created */
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
> +		PMD_DRV_LOG(INFO, "Initialize %s in secondary process", eth_dev->data->name);
> +
> +		struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
> +		if (HINIC_IS_VF(nic_dev->hwdev))
> +			eth_dev->dev_ops = &hinic_pmd_vf_ops;
> +		else
> +			eth_dev->dev_ops = &hinic_pmd_ops;
> +		return 0;
> +	}
> +
>  	return hinic_func_init(eth_dev);
>  }
>
  
Ferruh Yigit Sept. 14, 2020, 1:21 p.m. UTC | #2
On 9/1/2020 12:44 PM, Ferruh Yigit wrote:
> On 8/8/2020 8:45 AM, liqingqing wrote:
>> fix coredump when secondary process using the hinic port.
>> the reason is that during the stage of
>> secondary process port initialization,
>> it lack the initialization of "eth_dev->dev_ops".
>>
>> Signed-off-by: liqingqing <liqingqing3@huawei.com>
> 
> Hi,
> 
> Overall patch looks good but can you please add your name and surname to the
> sign off, to make it following syntax:
> Signed-off-by: Name Surname <liqingqing3@huawei.com>
> 
> Also what do you think about following patch title:
> "net/hinic: fix crash in secondary process"
> 


Hi Ziyang, Xiaoyun, Guoyang,

Can you please review the patch, also can you please help on getting the
correct sign off?
  

Patch

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 67e6afcf7..26c6098d3 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -3060,15 +3060,6 @@  static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	int rc;

 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-
-	/* EAL is SECONDARY and eth_dev is already created */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
-		PMD_DRV_LOG(INFO, "Initialize %s in secondary process",
-			    eth_dev->data->name);
-
-		return 0;
-	}
-
 	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 	memset(nic_dev, 0, sizeof(*nic_dev));

@@ -3206,6 +3197,18 @@  static int hinic_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->rx_pkt_burst = hinic_recv_pkts;
 	eth_dev->tx_pkt_burst = hinic_xmit_pkts;

+	/* EAL is SECONDARY and eth_dev is already created */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(INFO, "Initialize %s in secondary process", eth_dev->data->name);
+
+		struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
+		if (HINIC_IS_VF(nic_dev->hwdev))
+			eth_dev->dev_ops = &hinic_pmd_vf_ops;
+		else
+			eth_dev->dev_ops = &hinic_pmd_ops;
+		return 0;
+	}
+
 	return hinic_func_init(eth_dev);
 }