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 3A206A00E6 for ; Wed, 7 Aug 2019 09:21:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78E412BBD; Wed, 7 Aug 2019 09:21:07 +0200 (CEST) Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by dpdk.org (Postfix) with ESMTP id 134CB374 for ; Wed, 7 Aug 2019 09:21:05 +0200 (CEST) Received: from localhost.localdomain (unknown [202.43.148.188]) by APP-03 (Coremail) with SMTP id rQCowACXndnee0pdLxvhAg--.54735S2; Wed, 07 Aug 2019 15:21:03 +0800 (CST) From: Lu Qiuwen To: dev@dpdk.org Cc: jeffrey.b.shaw@intel.com, Xiao Wang Date: Wed, 7 Aug 2019 15:20:53 +0800 Message-Id: <20190807072053.21108-1-luqiuwen@iie.ac.cn> X-Mailer: git-send-email 2.20.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowACXndnee0pdLxvhAg--.54735S2 X-Coremail-Antispam: 1UD129KBjvJXoWxKr1xKF18Ary5tFWfKr48JFb_yoW7XFW8pF 1xZ347Cr47Xw4xJw17trWxCa4Yvw13G34UKa43Aa4ruF4qqrZaqrs8tay2yFyUAr98Cr1f Zw45ArykG3yFva7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkFb7Iv0xC_KF4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IE w4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMc vjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_GF4l42xK82IY c2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s 026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF 0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0x vE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jePfQUUUUU= X-Originating-IP: [202.43.148.188] X-CM-SenderInfo: 5oxtx3xzhqqx1lhotugofq/ Subject: [dpdk-dev] [PATCH v4] 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" The ops pointers in fm10k_stats_get() is setup from primary process, when secondary process call these function pointers, a segment fault will happened. v2 - delete some empty lines after the function declaration. v3 - add patch version, fixes and make title shorter. v4 - fix the misspelled word in the commit message. Fixes: 7223d200c227 ("fm10k: add base driver") Cc: jeffrey.b.shaw@intel.com Signed-off-by: Lu Qiuwen Acked-by: Xiao Wang --- 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