提交 9a4a0a86 编写于 作者: W Wei Yongjun 提交者: Zheng Zengkai

drivers: hooks: add bonding driver vendor hooks

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4UV43
CVE: NA

---------------------------

Allow vendor modules to attach bonding driver hooks. This
patch introduce vendor_bond_check_dev_link hook.

Usage:

  static void vendor_foo(void *data, const struct bonding *bond,
  		       const struct slave *slave, int *state)
  {
          pr_info("%s\n", __func__);
  }

  static int __init vendor_bond_init(void)
  {
  	return register_trace_vendor_bond_check_dev_link(&vendor_foo, NULL);
  }

  static void __exit vendor_bond_exit(void)
  {
  	unregister_trace_vendor_bond_check_dev_link(&vendor_foo, NULL);
  }

  module_init(vendor_bond_init);
  module_exit(vendor_bond_exit);
Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NZhang Jialin <zhangjialin11@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e408ece8
...@@ -6090,6 +6090,7 @@ CONFIG_USB4=m ...@@ -6090,6 +6090,7 @@ CONFIG_USB4=m
# Vendor Hooks # Vendor Hooks
# #
CONFIG_VENDOR_HOOKS=y CONFIG_VENDOR_HOOKS=y
CONFIG_VENDOR_BOND_HOOKS=y
# end of Vendor Hooks # end of Vendor Hooks
CONFIG_LIBNVDIMM=m CONFIG_LIBNVDIMM=m
......
...@@ -7183,6 +7183,7 @@ CONFIG_USB4=m ...@@ -7183,6 +7183,7 @@ CONFIG_USB4=m
# Vendor Hooks # Vendor Hooks
# #
CONFIG_VENDOR_HOOKS=y CONFIG_VENDOR_HOOKS=y
CONFIG_VENDOR_BOND_HOOKS=y
# end of Vendor Hooks # end of Vendor Hooks
CONFIG_LIBNVDIMM=m CONFIG_LIBNVDIMM=m
......
...@@ -10,4 +10,14 @@ config VENDOR_HOOKS ...@@ -10,4 +10,14 @@ config VENDOR_HOOKS
Allow vendor modules to attach to tracepoint "hooks" defined via Allow vendor modules to attach to tracepoint "hooks" defined via
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK. DECLARE_HOOK or DECLARE_RESTRICTED_HOOK.
config VENDOR_BOND_HOOKS
bool "Ethernet Bonding driver Vendor Hooks"
depends on VENDOR_HOOKS && BONDING
default n
help
Enable ethernet bonding driver vendor hooks
Allow vendor modules to attach bonding driver hooks defined via
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK.
endmenu endmenu
...@@ -8,9 +8,13 @@ ...@@ -8,9 +8,13 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/hooks/vendor_hooks.h> #include <trace/hooks/vendor_hooks.h>
#include <trace/hooks/bonding.h>
/* /*
* Export tracepoints that act as a bare tracehook (ie: have no trace event * Export tracepoints that act as a bare tracehook (ie: have no trace event
* associated with them) to allow external modules to probe them. * associated with them) to allow external modules to probe them.
*/ */
#ifdef CONFIG_VENDOR_BOND_HOOKS
EXPORT_TRACEPOINT_SYMBOL_GPL(vendor_bond_check_dev_link);
#endif
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include <net/bonding.h> #include <net/bonding.h>
#include <net/bond_3ad.h> #include <net/bond_3ad.h>
#include <net/bond_alb.h> #include <net/bond_alb.h>
#include <trace/hooks/bonding.h>
#include "bonding_priv.h" #include "bonding_priv.h"
...@@ -2415,6 +2416,10 @@ static int bond_miimon_inspect(struct bonding *bond) ...@@ -2415,6 +2416,10 @@ static int bond_miimon_inspect(struct bonding *bond)
link_state = bond_check_dev_link(bond, slave->dev, 0); link_state = bond_check_dev_link(bond, slave->dev, 0);
#ifdef CONFIG_VENDOR_BOND_HOOKS
trace_vendor_bond_check_dev_link(bond, slave, &link_state);
#endif
switch (slave->link) { switch (slave->link) {
case BOND_LINK_UP: case BOND_LINK_UP:
if (link_state) if (link_state)
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Ethernet Bonding driver Vendor Hooks
*
* Copyright (c) 2022, Huawei Tech. Co., Ltd.
*/
#ifdef CONFIG_VENDOR_BOND_HOOKS
#undef TRACE_SYSTEM
#define TRACE_SYSTEM bonding
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_BONDING_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_BONDING_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
struct bonding;
struct slave;
DECLARE_HOOK(vendor_bond_check_dev_link,
TP_PROTO(const struct bonding *bond, const struct slave *slave, int *state),
TP_ARGS(bond, slave, state));
#endif
/* This part must be outside protection */
#include <trace/define_trace.h>
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册