From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 944D5A046B for ; Wed, 21 Aug 2019 08:43:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4BEEF1BEE9; Wed, 21 Aug 2019 08:43:09 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id B29881BEE1; Wed, 21 Aug 2019 08:43:06 +0200 (CEST) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:43:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,411,1559545200"; d="scan'208";a="378846677" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by fmsmga006.fm.intel.com with ESMTP; 20 Aug 2019 23:43:03 -0700 Date: Wed, 21 Aug 2019 14:41:50 +0800 From: Ye Xiaolong To: Lu Qiuwen Cc: dev@dpdk.org, stable@dpdk.org, qi.z.zhang@intel.com, jeffrey.b.shaw@intel.com, Xiao Wang Message-ID: <20190821064150.GB87622@intel.com> References: <20190807072053.21108-1-luqiuwen> <20190807082422.20328-1-luqiuwen@iie.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190807082422.20328-1-luqiuwen@iie.ac.cn> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v5] net/fm10k: fix fm10k stats crash in multi-process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 08/07, Lu Qiuwen wrote: >The ops pointers in fm10k_stats_get() are set up from primary >process, when secondary process call these ops pointers, >a segment fault will happen. > >Fixes: 7223d200c227 ("fm10k: add base driver") >Cc: jeffrey.b.shaw@intel.com > >Signed-off-by: Lu Qiuwen >Acked-by: Xiao Wang >--- >V5 - fix grammar problems in the commit messages. >V4 - fix the misspelled word in the commit message. >V3 - add patch version, fixes info and make title shorter. >V2 - delete some empty lines after the function declaration. >--- > drivers/net/fm10k/base/fm10k_api.c | 20 ++++++++++++++++---- > drivers/net/fm10k/base/fm10k_pf.c | 4 ++-- > drivers/net/fm10k/base/fm10k_pf.h | 6 ++++++ > drivers/net/fm10k/base/fm10k_vf.c | 4 ++-- > drivers/net/fm10k/base/fm10k_vf.h | 5 +++++ > 5 files changed, 31 insertions(+), 8 deletions(-) > >diff --git a/drivers/net/fm10k/base/fm10k_api.c b/drivers/net/fm10k/base/fm10k_api.c >index c49d20dfb..e7b2fe710 100644 >--- a/drivers/net/fm10k/base/fm10k_api.c >+++ b/drivers/net/fm10k/base/fm10k_api.c >@@ -234,8 +234,14 @@ s32 fm10k_read_mac_addr(struct fm10k_hw *hw) > * */ > void fm10k_update_hw_stats(struct fm10k_hw *hw, struct fm10k_hw_stats *stats) > { >- if (hw->mac.ops.update_hw_stats) >- hw->mac.ops.update_hw_stats(hw, stats); >+ switch (hw->mac.type) { >+ case fm10k_mac_pf: >+ return fm10k_update_hw_stats_pf(hw, stats); >+ case fm10k_mac_vf: >+ return fm10k_update_hw_stats_vf(hw, stats); >+ default: >+ break; >+ } > } > > /** >@@ -246,8 +252,14 @@ void fm10k_update_hw_stats(struct fm10k_hw *hw, struct fm10k_hw_stats *stats) > * */ > void fm10k_rebind_hw_stats(struct fm10k_hw *hw, struct fm10k_hw_stats *stats) > { >- if (hw->mac.ops.rebind_hw_stats) >- hw->mac.ops.rebind_hw_stats(hw, stats); >+ switch (hw->mac.type) { >+ case fm10k_mac_pf: >+ return fm10k_rebind_hw_stats_pf(hw, stats); >+ case fm10k_mac_vf: >+ return fm10k_rebind_hw_stats_vf(hw, stats); >+ default: >+ break; >+ } > } > > /** >diff --git a/drivers/net/fm10k/base/fm10k_pf.c b/drivers/net/fm10k/base/fm10k_pf.c >index db5f4912f..f5b6a9e2e 100644 >--- a/drivers/net/fm10k/base/fm10k_pf.c >+++ b/drivers/net/fm10k/base/fm10k_pf.c >@@ -1511,7 +1511,7 @@ const struct fm10k_msg_data fm10k_iov_msg_data_pf[] = { > * This function collects and aggregates global and per queue hardware > * statistics. > **/ >-STATIC void fm10k_update_hw_stats_pf(struct fm10k_hw *hw, >+void fm10k_update_hw_stats_pf(struct fm10k_hw *hw, > struct fm10k_hw_stats *stats) > { > u32 timeout, ur, ca, um, xec, vlan_drop, loopback_drop, nodesc_drop; >@@ -1584,7 +1584,7 @@ STATIC void fm10k_update_hw_stats_pf(struct fm10k_hw *hw, > * This function resets the base for global and per queue hardware > * statistics. > **/ >-STATIC void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw, >+void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw, > struct fm10k_hw_stats *stats) > { > DEBUGFUNC("fm10k_rebind_hw_stats_pf"); >diff --git a/drivers/net/fm10k/base/fm10k_pf.h b/drivers/net/fm10k/base/fm10k_pf.h >index ca125c273..2c22bdd02 100644 >--- a/drivers/net/fm10k/base/fm10k_pf.h >+++ b/drivers/net/fm10k/base/fm10k_pf.h >@@ -184,4 +184,10 @@ extern const struct fm10k_msg_data fm10k_iov_msg_data_pf[]; > #endif > > s32 fm10k_init_ops_pf(struct fm10k_hw *hw); >+ >+void fm10k_update_hw_stats_pf(struct fm10k_hw *hw, >+ struct fm10k_hw_stats *stats); >+ >+void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw, >+ struct fm10k_hw_stats *stats); > #endif /* _FM10K_PF_H */ >diff --git a/drivers/net/fm10k/base/fm10k_vf.c b/drivers/net/fm10k/base/fm10k_vf.c >index bd449773a..2f4b5f5d2 100644 >--- a/drivers/net/fm10k/base/fm10k_vf.c >+++ b/drivers/net/fm10k/base/fm10k_vf.c >@@ -526,7 +526,7 @@ const struct fm10k_tlv_attr fm10k_1588_msg_attr[] = { > * > * This function collects and aggregates per queue hardware statistics. > **/ >-STATIC void fm10k_update_hw_stats_vf(struct fm10k_hw *hw, >+void fm10k_update_hw_stats_vf(struct fm10k_hw *hw, > struct fm10k_hw_stats *stats) > { > DEBUGFUNC("fm10k_update_hw_stats_vf"); >@@ -541,7 +541,7 @@ STATIC void fm10k_update_hw_stats_vf(struct fm10k_hw *hw, > * > * This function resets the base for queue hardware statistics. > **/ >-STATIC void fm10k_rebind_hw_stats_vf(struct fm10k_hw *hw, >+void fm10k_rebind_hw_stats_vf(struct fm10k_hw *hw, > struct fm10k_hw_stats *stats) > { > DEBUGFUNC("fm10k_rebind_hw_stats_vf"); >diff --git a/drivers/net/fm10k/base/fm10k_vf.h b/drivers/net/fm10k/base/fm10k_vf.h >index 116c56fcc..d4edd330e 100644 >--- a/drivers/net/fm10k/base/fm10k_vf.h >+++ b/drivers/net/fm10k/base/fm10k_vf.h >@@ -89,4 +89,9 @@ extern const struct fm10k_tlv_attr fm10k_1588_msg_attr[]; > FM10K_MSG_HANDLER(FM10K_VF_MSG_ID_1588, fm10k_1588_msg_attr, func) > > s32 fm10k_init_ops_vf(struct fm10k_hw *hw); >+ >+void fm10k_update_hw_stats_vf(struct fm10k_hw *hw, >+ struct fm10k_hw_stats *stats); >+void fm10k_rebind_hw_stats_vf(struct fm10k_hw *hw, >+ struct fm10k_hw_stats *stats); > #endif /* _FM10K_VF_H */ >-- >2.20.1.windows.1 > Reviewed-by: Xiaolong Ye Applied to dpdk-next-net-intel with "Cc: stable@dpdk.org" added. Thanks, Xiaolong