summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Qiuwen <luqiuwen@iie.ac.cn>2019-08-07 16:24:22 +0800
committerKevin Traynor <ktraynor@redhat.com>2019-09-13 10:37:20 +0100
commit1faa658529c597010a07958b86b7463cc6549551 (patch)
tree97606069286cac9f63715536b3dd393d0fa1dc6f
parentb42591099b8377b36125ad2486516b8507a748d0 (diff)
downloaddpdk-stable-1faa658529c597010a07958b86b7463cc6549551.zip
dpdk-stable-1faa658529c597010a07958b86b7463cc6549551.tar.gz
dpdk-stable-1faa658529c597010a07958b86b7463cc6549551.tar.xz
net/fm10k: fix stats crash in multi-process
[ upstream commit 61874d3c0663504f83d93a4701627a5949160a0f ] The ops pointers in fm10k_stats_get() are set up from primary process, when secondary process calls these ops pointers, a segment fault will happen. Fixes: 7223d200c227 ("fm10k: add base driver") Cc: stable@dpdk.org Signed-off-by: Lu Qiuwen <luqiuwen@iie.ac.cn> Acked-by: Xiao Wang <xiao.w.wang@intel.com> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
-rw-r--r--drivers/net/fm10k/base/fm10k_api.c20
-rw-r--r--drivers/net/fm10k/base/fm10k_pf.c4
-rw-r--r--drivers/net/fm10k/base/fm10k_pf.h6
-rw-r--r--drivers/net/fm10k/base/fm10k_vf.c4
-rw-r--r--drivers/net/fm10k/base/fm10k_vf.h5
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 c49d20d..e7b2fe7 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 db5f491..f5b6a9e 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 ca125c2..2c22bdd 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 bd44977..2f4b5f5 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 116c56f..d4edd33 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 */