| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/30 07:40 | flow | patch-triage |
39mArgs:null Results: {
"EnableConfigs": [
"NET_NCSI",
"INET"
],
"FocusSymbols": [
"ncsi_dev_get",
"ncsi_dev_put",
"ncsi_unregister_dev",
"ncsi_register_dev",
"ncsi_pkg_info_nl",
"ncsi_pkg_info_all_nl",
"ncsi_set_interface_nl",
"ncsi_clear_interface_nl",
"ncsi_send_cmd_nl",
"ncsi_set_package_mask_nl",
"ncsi_set_channel_mask_nl",
"ncsi_update_tx_channel",
"ncsi_channel_is_last",
"ncsi_free_request"
],
"KMSANReasoning": "The patch refactors memory management and concurrency synchronization for NCSI (Network Controller Sideband Interface) devices, packages, and channels by introducing RCU-protected lists and reference counting (kref) along with deferred RCU frees (call_rcu/kfree_rcu). \n\nThese modifications aim to fix race conditions and use-after-free (UAF) hazards during device unregistration and concurrent netlink operations. All involved structures (such as `struct ncsi_dev_priv`, `struct ncsi_package`, `struct ncsi_channel`) continue to be allocated using `kzalloc_obj` (zero-initialized), and local variables in altered paths are explicitly initialized. No new uninitialized data paths, padding leaks, or uninitialized buffer operations are introduced or exposed. Potential issues arising from these changes (such as lifetime/UAF bugs, RCU locking imbalance, or reference counting bugs) are covered by KASAN and LOCKDEP/PROVE_RCU rather than KMSAN. Thus, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch introduces RCU-based synchronization, reference counting (kref), and work cancellation handling across NCSI (Network Controller Sideband Interface) core management and Generic Netlink interfaces. It fixes potential race conditions and use-after-free bugs between device deregistration, channel removal, and user-initiated Netlink operations. These changes affect reachable kernel networking code accessible via generic netlink sockets and are worth fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/30 07:40 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit c66bd73b2eb7d3d1fcc1847d455a8306933c93d1\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sun Aug 30 07:40:41 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/net/ncsi/internal.h b/net/ncsi/internal.h\nindex adee6dcabdc3f..fbd90f270f5ee 100644\n--- a/net/ncsi/internal.h\n+++ b/net/ncsi/internal.h\n@@ -239,6 +239,7 @@ struct ncsi_channel {\n \t} monitor;\n \tstruct list_head node;\n \tstruct list_head link;\n+\tstruct rcu_head rcu; /* RCU cleanup */\n };\n \n struct ncsi_package {\n@@ -253,6 +254,7 @@ struct ncsi_package {\n \tbool multi_channel; /* Enable multiple channels */\n \tu32 channel_whitelist; /* Channels to configure */\n \tstruct ncsi_channel *preferred_channel; /* Primary channel */\n+\tstruct rcu_head rcu; /* RCU cleanup */\n };\n \n struct ncsi_request {\n@@ -315,6 +317,8 @@ struct vlan_vid {\n };\n \n struct ncsi_dev_priv {\n+\tstruct rcu_head rcu; /* RCU cleanup */\n+\tstruct kref ref;\n \tstruct ncsi_dev ndev; /* Associated NCSI device */\n \tunsigned int flags; /* NCSI device flags */\n #define NCSI_DEV_PROBED\t\t1 /* Finalized NCSI topology */\n@@ -337,6 +341,7 @@ struct ncsi_dev_priv {\n \tstruct ncsi_channel *active_channel; /* Currently handled channel */\n \tstruct list_head channel_queue; /* Config queue of channels */\n \tstruct work_struct work; /* For channel management */\n+\tbool work_cancelled; /* Work has been cancelled */\n \tstruct packet_type ptype; /* NCSI packet Rx handler */\n \tstruct list_head node; /* Form NCSI device list */\n #define NCSI_MAX_VLAN_VIDS\t15\n@@ -406,7 +411,8 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,\n \t\t\t struct ncsi_package *np,\n \t\t\t struct ncsi_channel *disable,\n \t\t\t struct ncsi_channel *enable);\n-\n+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev);\n+void ncsi_dev_put(struct ncsi_dev_priv *ndp);\n /* Packet handlers */\n u32 ncsi_calculate_checksum(unsigned char *data, int len);\n int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);\ndiff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c\nindex 54d0df0a9efe6..afc34c2b36136 100644\n--- a/net/ncsi/ncsi-manage.c\n+++ b/net/ncsi/ncsi-manage.c\n@@ -10,6 +10,7 @@\n #include \u003clinux/skbuff.h\u003e\n #include \u003clinux/of.h\u003e\n #include \u003clinux/platform_device.h\u003e\n+#include \u003clinux/rcupdate.h\u003e\n \n #include \u003cnet/ncsi.h\u003e\n #include \u003cnet/net_namespace.h\u003e\n@@ -35,17 +36,23 @@ bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,\n {\n \tstruct ncsi_package *np;\n \tstruct ncsi_channel *nc;\n+\tbool is_last = true;\n \n-\tNCSI_FOR_EACH_PACKAGE(ndp, np)\n+\trcu_read_lock();\n+\tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tNCSI_FOR_EACH_CHANNEL(np, nc) {\n \t\t\tif (nc == channel)\n \t\t\t\tcontinue;\n \t\t\tif (nc-\u003estate == NCSI_CHANNEL_ACTIVE \u0026\u0026\n-\t\t\t ncsi_channel_has_link(nc))\n-\t\t\t\treturn false;\n+\t\t\t ncsi_channel_has_link(nc)) {\n+\t\t\t\tis_last = false;\n+\t\t\t\tgoto out;\n+\t\t\t}\n \t\t}\n-\n-\treturn true;\n+\t}\n+ out:\n+\trcu_read_unlock();\n+\treturn is_last;\n }\n \n static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)\n@@ -62,6 +69,7 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)\n \t}\n \n \tnd-\u003elink_up = 0;\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tNCSI_FOR_EACH_CHANNEL(np, nc) {\n \t\t\tspin_lock_irqsave(\u0026nc-\u003elock, flags);\n@@ -75,12 +83,14 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)\n \t\t\tif (ncsi_channel_has_link(nc)) {\n \t\t\t\tspin_unlock_irqrestore(\u0026nc-\u003elock, flags);\n \t\t\t\tnd-\u003elink_up = 1;\n+\t\t\t\trcu_read_unlock();\n \t\t\t\tgoto report;\n \t\t\t}\n \n \t\t\tspin_unlock_irqrestore(\u0026nc-\u003elock, flags);\n \t\t}\n \t}\n+\trcu_read_unlock();\n \n report:\n \tnd-\u003ehandler(nd);\n@@ -242,28 +252,37 @@ struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id)\n \treturn nc;\n }\n \n+static void ncsi_channel_rcu_free(struct rcu_head *head)\n+{\n+\tstruct ncsi_channel *nc = container_of(head, struct ncsi_channel, rcu);\n+\n+\tkfree(nc-\u003emac_filter.addrs);\n+\tkfree(nc-\u003evlan_filter.vids);\n+\tkfree(nc);\n+}\n+\n static void ncsi_remove_channel(struct ncsi_channel *nc)\n {\n \tstruct ncsi_package *np = nc-\u003epackage;\n+\tstruct ncsi_dev_priv *ndp = np-\u003endp;\n \tunsigned long flags;\n \n-\tspin_lock_irqsave(\u0026nc-\u003elock, flags);\n-\n-\t/* Release filters */\n-\tkfree(nc-\u003emac_filter.addrs);\n-\tkfree(nc-\u003evlan_filter.vids);\n+\tncsi_stop_channel_monitor(nc);\n \n+\tspin_lock_irqsave(\u0026nc-\u003elock, flags);\n \tnc-\u003estate = NCSI_CHANNEL_INACTIVE;\n \tspin_unlock_irqrestore(\u0026nc-\u003elock, flags);\n-\tncsi_stop_channel_monitor(nc);\n \n-\t/* Remove and free channel */\n+\tspin_lock_irqsave(\u0026ndp-\u003elock, flags);\n+\tlist_del_rcu(\u0026nc-\u003elink);\n+\tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\n+\n \tspin_lock_irqsave(\u0026np-\u003elock, flags);\n \tlist_del_rcu(\u0026nc-\u003enode);\n \tnp-\u003echannel_num--;\n \tspin_unlock_irqrestore(\u0026np-\u003elock, flags);\n \n-\tkfree(nc);\n+\tcall_rcu(\u0026nc-\u003ercu, ncsi_channel_rcu_free);\n }\n \n struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,\n@@ -326,7 +345,7 @@ void ncsi_remove_package(struct ncsi_package *np)\n \tndp-\u003epackage_num--;\n \tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\n \n-\tkfree(np);\n+\tkfree_rcu(np, rcu);\n }\n \n void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,\n@@ -409,7 +428,8 @@ void ncsi_free_request(struct ncsi_request *nr)\n \tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\n \n \tif (driven \u0026\u0026 cmd \u0026\u0026 --ndp-\u003epending_req_num == 0)\n-\t\tschedule_work(\u0026ndp-\u003ework);\n+\t\tif (!READ_ONCE(ndp-\u003ework_cancelled))\n+\t\t\tschedule_work(\u0026ndp-\u003ework);\n \n \t/* Release command and response */\n \tconsume_skb(cmd);\n@@ -912,6 +932,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,\n \tnca.req_flags = 0;\n \n \t/* Find current channel with Tx enabled */\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tif (disable)\n \t\t\tbreak;\n@@ -924,8 +945,10 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,\n \t\t\t\tbreak;\n \t\t\t}\n \t}\n+\trcu_read_unlock();\n \n \t/* Find a suitable channel for Tx */\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tif (enable)\n \t\t\tbreak;\n@@ -951,6 +974,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,\n \t\t\t}\n \t\t}\n \t}\n+\trcu_read_unlock();\n \n \tif (disable == enable)\n \t\treturn -1;\n@@ -1253,6 +1277,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)\n \t */\n \tfound = NULL;\n \twith_link = false;\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tif (!(ndp-\u003epackage_whitelist \u0026 (0x1 \u003c\u003c np-\u003eid)))\n \t\t\tcontinue;\n@@ -1304,6 +1329,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)\n \t\tif (with_link \u0026\u0026 !ndp-\u003emulti_package)\n \t\t\tbreak;\n \t}\n+\trcu_read_unlock();\n \n \tif (list_empty(\u0026ndp-\u003echannel_queue) \u0026\u0026 found) {\n \t\tnetdev_info(ndp-\u003endev.dev,\n@@ -1332,6 +1358,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)\n \t/* The hardware arbitration is disabled if any one channel\n \t * doesn't support explicitly.\n \t */\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tNCSI_FOR_EACH_CHANNEL(np, nc) {\n \t\t\thas_channel = true;\n@@ -1345,6 +1372,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)\n \t\t\t}\n \t\t}\n \t}\n+\trcu_read_unlock();\n \n \tif (has_channel) {\n \t\tndp-\u003eflags |= NCSI_DEV_HWA;\n@@ -1782,6 +1810,7 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\n \tndp-\u003epackage_whitelist = UINT_MAX;\n \n \t/* Initialize private NCSI device */\n+\tkref_init(\u0026ndp-\u003eref);\n \tspin_lock_init(\u0026ndp-\u003elock);\n \tINIT_LIST_HEAD(\u0026ndp-\u003epackages);\n \tndp-\u003erequest_id = NCSI_REQ_START_IDX;\n@@ -1952,23 +1981,65 @@ int ncsi_reset_dev(struct ncsi_dev *nd)\n \treturn 0;\n }\n \n+static void ncsi_dev_release(struct kref *ref)\n+{\n+\tstruct ncsi_dev_priv *ndp;\n+\n+\tndp = container_of(ref, struct ncsi_dev_priv, ref);\n+\tkfree_rcu(ndp, rcu);\n+}\n+\n+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev)\n+{\n+\tstruct ncsi_dev_priv *ndp = NULL;\n+\tstruct ncsi_dev *nd;\n+\n+\trcu_read_lock();\n+\tnd = ncsi_find_dev(dev);\n+\tif (nd) {\n+\t\tndp = TO_NCSI_DEV_PRIV(nd);\n+\t\t/* Safely grab a reference while under RCU lock */\n+\t\tif (!kref_get_unless_zero(\u0026ndp-\u003eref))\n+\t\t\tndp = NULL;\n+\t}\n+\trcu_read_unlock();\n+\n+\treturn ndp;\n+}\n+\n+void ncsi_dev_put(struct ncsi_dev_priv *ndp)\n+{\n+\tif (ndp)\n+\t\tkref_put(\u0026ndp-\u003eref, ncsi_dev_release);\n+}\n+\n void ncsi_unregister_dev(struct ncsi_dev *nd)\n {\n \tstruct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);\n \tstruct ncsi_package *np, *tmp;\n \tunsigned long flags;\n \n-\tdev_remove_pack(\u0026ndp-\u003eptype);\n-\n-\tlist_for_each_entry_safe(np, tmp, \u0026ndp-\u003epackages, node)\n-\t\tncsi_remove_package(np);\n-\n \tspin_lock_irqsave(\u0026ncsi_dev_lock, flags);\n \tlist_del_rcu(\u0026ndp-\u003enode);\n \tspin_unlock_irqrestore(\u0026ncsi_dev_lock, flags);\n \n+\tspin_lock_irqsave(\u0026ndp-\u003elock, flags);\n+\tndp-\u003ework_cancelled = true;\n+\tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\n+\n+\tfor (int i = 0; i \u003c ARRAY_SIZE(ndp-\u003erequests); i++) {\n+\t\tstruct ncsi_request *nr = \u0026ndp-\u003erequests[i];\n+\n+\t\tif (nr-\u003eenabled)\n+\t\t\tncsi_free_request(nr);\n+\t}\n+\n+\tdev_remove_pack(\u0026ndp-\u003eptype);\n \tdisable_work_sync(\u0026ndp-\u003ework);\n \n-\tkfree(ndp);\n+\tlist_for_each_entry_safe(np, tmp, \u0026ndp-\u003epackages, node)\n+\t\tncsi_remove_package(np);\n+\n+\tkref_put(\u0026ndp-\u003eref, ncsi_dev_release);\n }\n EXPORT_SYMBOL_GPL(ncsi_unregister_dev);\ndiff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c\nindex 8cc538358f6a3..59fd735c367ad 100644\n--- a/net/ncsi/ncsi-netlink.c\n+++ b/net/ncsi/ncsi-netlink.c\n@@ -35,8 +35,6 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)\n {\n \tstruct ncsi_dev_priv *ndp;\n \tstruct net_device *dev;\n-\tstruct ncsi_dev *nd;\n-\tstruct ncsi_dev;\n \n \tif (!net)\n \t\treturn NULL;\n@@ -47,9 +45,7 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)\n \t\treturn NULL;\n \t}\n \n-\tnd = ncsi_find_dev(dev);\n-\tndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL;\n-\n+\tndp = ncsi_dev_get(dev);\n \tdev_put(dev);\n \treturn ndp;\n }\n@@ -175,13 +171,16 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)\n \t\treturn -ENODEV;\n \n \tskb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\n-\tif (!skb)\n+\tif (!skb) {\n+\t\tncsi_dev_put(ndp);\n \t\treturn -ENOMEM;\n+\t}\n \n \thdr = genlmsg_put(skb, info-\u003esnd_portid, info-\u003esnd_seq,\n \t\t\t \u0026ncsi_genl_family, 0, NCSI_CMD_PKG_INFO);\n \tif (!hdr) {\n \t\tkfree_skb(skb);\n+\t\tncsi_dev_put(ndp);\n \t\treturn -EMSGSIZE;\n \t}\n \n@@ -190,9 +189,13 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)\n \tattr = nla_nest_start_noflag(skb, NCSI_ATTR_PACKAGE_LIST);\n \tif (!attr) {\n \t\tkfree_skb(skb);\n+\t\tncsi_dev_put(ndp);\n \t\treturn -EMSGSIZE;\n \t}\n+\n+\trcu_read_lock();\n \trc = ncsi_write_package_info(skb, ndp, package_id);\n+\trcu_read_unlock();\n \n \tif (rc) {\n \t\tnla_nest_cancel(skb, attr);\n@@ -202,10 +205,12 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)\n \tnla_nest_end(skb, attr);\n \n \tgenlmsg_end(skb, hdr);\n+\tncsi_dev_put(ndp);\n \treturn genlmsg_reply(skb, info);\n \n err:\n \tkfree_skb(skb);\n+\tncsi_dev_put(ndp);\n \treturn rc;\n }\n \n@@ -235,14 +240,17 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,\n \t\treturn -ENODEV;\n \n \tpackage_id = cb-\u003eargs[0];\n+\trcu_read_lock();\n \tpackage = NULL;\n \tNCSI_FOR_EACH_PACKAGE(ndp, np)\n \t\tif (np-\u003eid == package_id)\n \t\t\tpackage = np;\n \n-\tif (!package)\n+\tif (!package) {\n+\t\trcu_read_unlock();\n+\t\tncsi_dev_put(ndp);\n \t\treturn 0; /* done */\n-\n+\t}\n \thdr = genlmsg_put(skb, NETLINK_CB(cb-\u003eskb).portid, cb-\u003enlh-\u003enlmsg_seq,\n \t\t\t \u0026ncsi_genl_family, NLM_F_MULTI, NCSI_CMD_PKG_INFO);\n \tif (!hdr) {\n@@ -255,7 +263,9 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,\n \t\trc = -EMSGSIZE;\n \t\tgoto err;\n \t}\n+\n \trc = ncsi_write_package_info(skb, ndp, package-\u003eid);\n+\n \tif (rc) {\n \t\tnla_nest_cancel(skb, attr);\n \t\tgoto err;\n@@ -266,9 +276,13 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,\n \n \tcb-\u003eargs[0] = package_id + 1;\n \n+\trcu_read_unlock();\n+\tncsi_dev_put(ndp);\n \treturn skb-\u003elen;\n err:\n+\trcu_read_unlock();\n \tgenlmsg_cancel(skb, hdr);\n+\tncsi_dev_put(ndp);\n \treturn rc;\n }\n \n@@ -297,11 +311,15 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \tpackage_id = nla_get_u32(info-\u003eattrs[NCSI_ATTR_PACKAGE_ID]);\n \tpackage = NULL;\n \n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np)\n \t\tif (np-\u003eid == package_id)\n \t\t\tpackage = np;\n+\n \tif (!package) {\n \t\t/* The user has set a package that does not exist */\n+\t\trcu_read_unlock();\n+\t\tncsi_dev_put(ndp);\n \t\treturn -ERANGE;\n \t}\n \n@@ -317,6 +335,8 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \t\t\tnetdev_info(ndp-\u003endev.dev,\n \t\t\t\t \"NCSI: Channel %u does not exist!\\n\",\n \t\t\t\t channel_id);\n+\t\t\trcu_read_unlock();\n+\t\t\tncsi_dev_put(ndp);\n \t\t\treturn -ERANGE;\n \t\t}\n \t}\n@@ -337,6 +357,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \t\tpackage-\u003epreferred_channel = NULL;\n \t}\n \tspin_unlock_irqrestore(\u0026package-\u003elock, flags);\n+\trcu_read_unlock();\n \n \tif (channel)\n \t\tnetdev_info(ndp-\u003endev.dev,\n@@ -350,6 +371,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \tif (!(ndp-\u003eflags \u0026 NCSI_DEV_RESET))\n \t\tncsi_reset_dev(\u0026ndp-\u003endev);\n \n+\tncsi_dev_put(ndp);\n \treturn 0;\n }\n \n@@ -376,6 +398,7 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \tndp-\u003emulti_package = false;\n \tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\n \n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n \t\tspin_lock_irqsave(\u0026np-\u003elock, flags);\n \t\tnp-\u003emulti_channel = false;\n@@ -383,18 +406,21 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)\n \t\tnp-\u003epreferred_channel = NULL;\n \t\tspin_unlock_irqrestore(\u0026np-\u003elock, flags);\n \t}\n+\trcu_read_unlock();\n+\n \tnetdev_info(ndp-\u003endev.dev, \"NCSI: Cleared preferred package/channel\\n\");\n \n \t/* Update channel configuration */\n \tif (!(ndp-\u003eflags \u0026 NCSI_DEV_RESET))\n \t\tncsi_reset_dev(\u0026ndp-\u003endev);\n \n+\tncsi_dev_put(ndp);\n \treturn 0;\n }\n \n static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)\n {\n-\tstruct ncsi_dev_priv *ndp;\n+\tstruct ncsi_dev_priv *ndp = NULL;\n \tstruct ncsi_pkt_hdr *hdr;\n \tstruct ncsi_cmd_arg nca;\n \tunsigned char *data;\n@@ -480,6 +506,7 @@ static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)\n \t\t\t\t ret);\n \t}\n out:\n+\tncsi_dev_put(ndp);\n \treturn ret;\n }\n \n@@ -639,6 +666,7 @@ static int ncsi_set_package_mask_nl(struct sk_buff *msg,\n \t\t\tncsi_reset_dev(\u0026ndp-\u003endev);\n \t}\n \n+\tncsi_dev_put(ndp);\n \treturn rc;\n }\n \n@@ -670,14 +698,17 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,\n \n \tpackage_id = nla_get_u32(info-\u003eattrs[NCSI_ATTR_PACKAGE_ID]);\n \tpackage = NULL;\n+\trcu_read_lock();\n \tNCSI_FOR_EACH_PACKAGE(ndp, np)\n \t\tif (np-\u003eid == package_id) {\n \t\t\tpackage = np;\n \t\t\tbreak;\n \t\t}\n-\tif (!package)\n+\tif (!package) {\n+\t\trcu_read_unlock();\n+\t\tncsi_dev_put(ndp);\n \t\treturn -ERANGE;\n-\n+\t}\n \tspin_lock_irqsave(\u0026package-\u003elock, flags);\n \n \tchannel = NULL;\n@@ -690,6 +721,7 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,\n \t\t\t}\n \t\tif (!channel) {\n \t\t\tspin_unlock_irqrestore(\u0026package-\u003elock, flags);\n+\t\t\tncsi_dev_put(ndp);\n \t\t\treturn -ERANGE;\n \t\t}\n \t\tnetdev_dbg(ndp-\u003endev.dev,\n@@ -716,11 +748,13 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,\n \t}\n \n \tspin_unlock_irqrestore(\u0026package-\u003elock, flags);\n+\trcu_read_unlock();\n \n \t/* Update channel configuration */\n \tif (!(ndp-\u003eflags \u0026 NCSI_DEV_RESET))\n \t\tncsi_reset_dev(\u0026ndp-\u003endev);\n \n+\tncsi_dev_put(ndp);\n \treturn 0;\n }\n \n"
} |
| 2/1 | 2026/08/30 07:40 | agent | patch-evaluator |
29mModel:core Args: null Results: {
"EnableConfigs": [
"NET_NCSI",
"INET"
],
"FocusSymbols": [
"ncsi_dev_get",
"ncsi_dev_put",
"ncsi_unregister_dev",
"ncsi_register_dev",
"ncsi_pkg_info_nl",
"ncsi_pkg_info_all_nl",
"ncsi_set_interface_nl",
"ncsi_clear_interface_nl",
"ncsi_send_cmd_nl",
"ncsi_set_package_mask_nl",
"ncsi_set_channel_mask_nl",
"ncsi_update_tx_channel",
"ncsi_channel_is_last",
"ncsi_free_request"
],
"Reasoning": "The patch introduces RCU-based synchronization, reference counting (kref), and work cancellation handling across NCSI (Network Controller Sideband Interface) core management and Generic Netlink interfaces. It fixes potential race conditions and use-after-free bugs between device deregistration, channel removal, and user-initiated Netlink operations. These changes affect reachable kernel networking code accessible via generic netlink sockets and are worth fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit c66bd73b2eb7d3d1fcc1847d455a8306933c93d1
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Aug 30 07:40:41 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index adee6dcabdc3f..fbd90f270f5ee 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -239,6 +239,7 @@ struct ncsi_channel {
} monitor;
struct list_head node;
struct list_head link;
+ struct rcu_head rcu; /* RCU cleanup */
};
struct ncsi_package {
@@ -253,6 +254,7 @@ struct ncsi_package {
bool multi_channel; /* Enable multiple channels */
u32 channel_whitelist; /* Channels to configure */
struct ncsi_channel *preferred_channel; /* Primary channel */
+ struct rcu_head rcu; /* RCU cleanup */
};
struct ncsi_request {
@@ -315,6 +317,8 @@ struct vlan_vid {
};
struct ncsi_dev_priv {
+ struct rcu_head rcu; /* RCU cleanup */
+ struct kref ref;
struct ncsi_dev ndev; /* Associated NCSI device */
unsigned int flags; /* NCSI device flags */
#define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */
@@ -337,6 +341,7 @@ struct ncsi_dev_priv {
struct ncsi_channel *active_channel; /* Currently handled channel */
struct list_head channel_queue; /* Config queue of channels */
struct work_struct work; /* For channel management */
+ bool work_cancelled; /* Work has been cancelled */
struct packet_type ptype; /* NCSI packet Rx handler */
struct list_head node; /* Form NCSI device list */
#define NCSI_MAX_VLAN_VIDS 15
@@ -406,7 +411,8 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
struct ncsi_package *np,
struct ncsi_channel *disable,
struct ncsi_channel *enable);
-
+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev);
+void ncsi_dev_put(struct ncsi_dev_priv *ndp);
/* Packet handlers */
u32 ncsi_calculate_checksum(unsigned char *data, int len);
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 54d0df0a9efe6..afc34c2b36136 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -10,6 +10,7 @@
#include <linux/skbuff.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/rcupdate.h>
#include <net/ncsi.h>
#include <net/net_namespace.h>
@@ -35,17 +36,23 @@ bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,
{
struct ncsi_package *np;
struct ncsi_channel *nc;
+ bool is_last = true;
- NCSI_FOR_EACH_PACKAGE(ndp, np)
+ rcu_read_lock();
+ NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
if (nc == channel)
continue;
if (nc->state == NCSI_CHANNEL_ACTIVE &&
- ncsi_channel_has_link(nc))
- return false;
+ ncsi_channel_has_link(nc)) {
+ is_last = false;
+ goto out;
+ }
}
-
- return true;
+ }
+ out:
+ rcu_read_unlock();
+ return is_last;
}
static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
@@ -62,6 +69,7 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
}
nd->link_up = 0;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
spin_lock_irqsave(&nc->lock, flags);
@@ -75,12 +83,14 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
if (ncsi_channel_has_link(nc)) {
spin_unlock_irqrestore(&nc->lock, flags);
nd->link_up = 1;
+ rcu_read_unlock();
goto report;
}
spin_unlock_irqrestore(&nc->lock, flags);
}
}
+ rcu_read_unlock();
report:
nd->handler(nd);
@@ -242,28 +252,37 @@ struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id)
return nc;
}
+static void ncsi_channel_rcu_free(struct rcu_head *head)
+{
+ struct ncsi_channel *nc = container_of(head, struct ncsi_channel, rcu);
+
+ kfree(nc->mac_filter.addrs);
+ kfree(nc->vlan_filter.vids);
+ kfree(nc);
+}
+
static void ncsi_remove_channel(struct ncsi_channel *nc)
{
struct ncsi_package *np = nc->package;
+ struct ncsi_dev_priv *ndp = np->ndp;
unsigned long flags;
- spin_lock_irqsave(&nc->lock, flags);
-
- /* Release filters */
- kfree(nc->mac_filter.addrs);
- kfree(nc->vlan_filter.vids);
+ ncsi_stop_channel_monitor(nc);
+ spin_lock_irqsave(&nc->lock, flags);
nc->state = NCSI_CHANNEL_INACTIVE;
spin_unlock_irqrestore(&nc->lock, flags);
- ncsi_stop_channel_monitor(nc);
- /* Remove and free channel */
+ spin_lock_irqsave(&ndp->lock, flags);
+ list_del_rcu(&nc->link);
+ spin_unlock_irqrestore(&ndp->lock, flags);
+
spin_lock_irqsave(&np->lock, flags);
list_del_rcu(&nc->node);
np->channel_num--;
spin_unlock_irqrestore(&np->lock, flags);
- kfree(nc);
+ call_rcu(&nc->rcu, ncsi_channel_rcu_free);
}
struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,
@@ -326,7 +345,7 @@ void ncsi_remove_package(struct ncsi_package *np)
ndp->package_num--;
spin_unlock_irqrestore(&ndp->lock, flags);
- kfree(np);
+ kfree_rcu(np, rcu);
}
void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
@@ -409,7 +428,8 @@ void ncsi_free_request(struct ncsi_request *nr)
spin_unlock_irqrestore(&ndp->lock, flags);
if (driven && cmd && --ndp->pending_req_num == 0)
- schedule_work(&ndp->work);
+ if (!READ_ONCE(ndp->work_cancelled))
+ schedule_work(&ndp->work);
/* Release command and response */
consume_skb(cmd);
@@ -912,6 +932,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
nca.req_flags = 0;
/* Find current channel with Tx enabled */
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (disable)
break;
@@ -924,8 +945,10 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
break;
}
}
+ rcu_read_unlock();
/* Find a suitable channel for Tx */
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (enable)
break;
@@ -951,6 +974,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
}
}
}
+ rcu_read_unlock();
if (disable == enable)
return -1;
@@ -1253,6 +1277,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
*/
found = NULL;
with_link = false;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (!(ndp->package_whitelist & (0x1 << np->id)))
continue;
@@ -1304,6 +1329,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
if (with_link && !ndp->multi_package)
break;
}
+ rcu_read_unlock();
if (list_empty(&ndp->channel_queue) && found) {
netdev_info(ndp->ndev.dev,
@@ -1332,6 +1358,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
/* The hardware arbitration is disabled if any one channel
* doesn't support explicitly.
*/
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
has_channel = true;
@@ -1345,6 +1372,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
}
}
}
+ rcu_read_unlock();
if (has_channel) {
ndp->flags |= NCSI_DEV_HWA;
@@ -1782,6 +1810,7 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
ndp->package_whitelist = UINT_MAX;
/* Initialize private NCSI device */
+ kref_init(&ndp->ref);
spin_lock_init(&ndp->lock);
INIT_LIST_HEAD(&ndp->packages);
ndp->request_id = NCSI_REQ_START_IDX;
@@ -1952,23 +1981,65 @@ int ncsi_reset_dev(struct ncsi_dev *nd)
return 0;
}
+static void ncsi_dev_release(struct kref *ref)
+{
+ struct ncsi_dev_priv *ndp;
+
+ ndp = container_of(ref, struct ncsi_dev_priv, ref);
+ kfree_rcu(ndp, rcu);
+}
+
+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev)
+{
+ struct ncsi_dev_priv *ndp = NULL;
+ struct ncsi_dev *nd;
+
+ rcu_read_lock();
+ nd = ncsi_find_dev(dev);
+ if (nd) {
+ ndp = TO_NCSI_DEV_PRIV(nd);
+ /* Safely grab a reference while under RCU lock */
+ if (!kref_get_unless_zero(&ndp->ref))
+ ndp = NULL;
+ }
+ rcu_read_unlock();
+
+ return ndp;
+}
+
+void ncsi_dev_put(struct ncsi_dev_priv *ndp)
+{
+ if (ndp)
+ kref_put(&ndp->ref, ncsi_dev_release);
+}
+
void ncsi_unregister_dev(struct ncsi_dev *nd)
{
struct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);
struct ncsi_package *np, *tmp;
unsigned long flags;
- dev_remove_pack(&ndp->ptype);
-
- list_for_each_entry_safe(np, tmp, &ndp->packages, node)
- ncsi_remove_package(np);
-
spin_lock_irqsave(&ncsi_dev_lock, flags);
list_del_rcu(&ndp->node);
spin_unlock_irqrestore(&ncsi_dev_lock, flags);
+ spin_lock_irqsave(&ndp->lock, flags);
+ ndp->work_cancelled = true;
+ spin_unlock_irqrestore(&ndp->lock, flags);
+
+ for (int i = 0; i < ARRAY_SIZE(ndp->requests); i++) {
+ struct ncsi_request *nr = &ndp->requests[i];
+
+ if (nr->enabled)
+ ncsi_free_request(nr);
+ }
+
+ dev_remove_pack(&ndp->ptype);
disable_work_sync(&ndp->work);
- kfree(ndp);
+ list_for_each_entry_safe(np, tmp, &ndp->packages, node)
+ ncsi_remove_package(np);
+
+ kref_put(&ndp->ref, ncsi_dev_release);
}
EXPORT_SYMBOL_GPL(ncsi_unregister_dev);
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
index 8cc538358f6a3..59fd735c367ad 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -35,8 +35,6 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)
{
struct ncsi_dev_priv *ndp;
struct net_device *dev;
- struct ncsi_dev *nd;
- struct ncsi_dev;
if (!net)
return NULL;
@@ -47,9 +45,7 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)
return NULL;
}
- nd = ncsi_find_dev(dev);
- ndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL;
-
+ ndp = ncsi_dev_get(dev);
dev_put(dev);
return ndp;
}
@@ -175,13 +171,16 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
return -ENODEV;
skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (!skb)
+ if (!skb) {
+ ncsi_dev_put(ndp);
return -ENOMEM;
+ }
hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq,
&ncsi_genl_family, 0, NCSI_CMD_PKG_INFO);
if (!hdr) {
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return -EMSGSIZE;
}
@@ -190,9 +189,13 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
attr = nla_nest_start_noflag(skb, NCSI_ATTR_PACKAGE_LIST);
if (!attr) {
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return -EMSGSIZE;
}
+
+ rcu_read_lock();
rc = ncsi_write_package_info(skb, ndp, package_id);
+ rcu_read_unlock();
if (rc) {
nla_nest_cancel(skb, attr);
@@ -202,10 +205,12 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
nla_nest_end(skb, attr);
genlmsg_end(skb, hdr);
+ ncsi_dev_put(ndp);
return genlmsg_reply(skb, info);
err:
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return rc;
}
@@ -235,14 +240,17 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
return -ENODEV;
package_id = cb->args[0];
+ rcu_read_lock();
package = NULL;
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id)
package = np;
- if (!package)
+ if (!package) {
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return 0; /* done */
-
+ }
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
&ncsi_genl_family, NLM_F_MULTI, NCSI_CMD_PKG_INFO);
if (!hdr) {
@@ -255,7 +263,9 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
rc = -EMSGSIZE;
goto err;
}
+
rc = ncsi_write_package_info(skb, ndp, package->id);
+
if (rc) {
nla_nest_cancel(skb, attr);
goto err;
@@ -266,9 +276,13 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
cb->args[0] = package_id + 1;
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return skb->len;
err:
+ rcu_read_unlock();
genlmsg_cancel(skb, hdr);
+ ncsi_dev_put(ndp);
return rc;
}
@@ -297,11 +311,15 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]);
package = NULL;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id)
package = np;
+
if (!package) {
/* The user has set a package that does not exist */
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
}
@@ -317,6 +335,8 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
netdev_info(ndp->ndev.dev,
"NCSI: Channel %u does not exist!\n",
channel_id);
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
}
}
@@ -337,6 +357,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
package->preferred_channel = NULL;
}
spin_unlock_irqrestore(&package->lock, flags);
+ rcu_read_unlock();
if (channel)
netdev_info(ndp->ndev.dev,
@@ -350,6 +371,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
@@ -376,6 +398,7 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)
ndp->multi_package = false;
spin_unlock_irqrestore(&ndp->lock, flags);
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
spin_lock_irqsave(&np->lock, flags);
np->multi_channel = false;
@@ -383,18 +406,21 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)
np->preferred_channel = NULL;
spin_unlock_irqrestore(&np->lock, flags);
}
+ rcu_read_unlock();
+
netdev_info(ndp->ndev.dev, "NCSI: Cleared preferred package/channel\n");
/* Update channel configuration */
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
{
- struct ncsi_dev_priv *ndp;
+ struct ncsi_dev_priv *ndp = NULL;
struct ncsi_pkt_hdr *hdr;
struct ncsi_cmd_arg nca;
unsigned char *data;
@@ -480,6 +506,7 @@ static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
ret);
}
out:
+ ncsi_dev_put(ndp);
return ret;
}
@@ -639,6 +666,7 @@ static int ncsi_set_package_mask_nl(struct sk_buff *msg,
ncsi_reset_dev(&ndp->ndev);
}
+ ncsi_dev_put(ndp);
return rc;
}
@@ -670,14 +698,17 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]);
package = NULL;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id) {
package = np;
break;
}
- if (!package)
+ if (!package) {
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
-
+ }
spin_lock_irqsave(&package->lock, flags);
channel = NULL;
@@ -690,6 +721,7 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
}
if (!channel) {
spin_unlock_irqrestore(&package->lock, flags);
+ ncsi_dev_put(ndp);
return -ERANGE;
}
netdev_dbg(ndp->ndev.dev,
@@ -716,11 +748,13 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
}
spin_unlock_irqrestore(&package->lock, flags);
+ rcu_read_unlock();
/* Update channel configuration */
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
|
| 3/2 | 2026/08/30 07:40 | llm | patch-evaluator |
1mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 8778 output: 30 thoughts: 102 Thoughts: **NCSI Patch Analysis** Okay, so I've been given a patch that touches `net/ncsi/internal.h`, `net/ncsi/ncsi-manage.c`, and `net/ncsi/ncsi-netlink.c`. Before I dive into the specifics of *this* patch, I need a solid understanding of NCSI itself. I need to know what it is, how it works, and importantly, how it's *used* in the kernel. My immediate focus is on figuring out what configurations are necessary to enable this. I need to identify the relevant Kconfigs. Understanding the build requirements is key. Then, I'll need to determine the accessibility of the NCSI code; How reachable it is from a standard environment is paramount. Can I trigger it easily? Is it something that I can fuzz with standard tools and setups? That'll really drive how I approach the code review, and what kind of testing strategy I'll recommend. Therefore, the first step is a code search. I need to grep the codebase for "NCSI" and see what comes up. This will help me understand the dependencies, the enabling conditions, and hopefully, give me a broader view of how NCSI integrates into the kernel network stack. Once I have that context, I can really understand what the patch *is* doing, and if it's correct. |
| 4/2 | 2026/08/30 07:42 | tool | grepper |
0mArgs:{
"Expression": "config NET_NCSI",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/Kconfig-5-\nnet/ncsi/Kconfig:6:config NET_NCSI\nnet/ncsi/Kconfig-7-\tbool \"NCSI interface support\"\n"
} |
| 5/2 | 2026/08/30 07:42 | llm | patch-evaluator |
1mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 9268 output: 34 thoughts: 22 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into the `net/ncsi/Kconfig` File** Alright, time to get to the heart of the matter. I need to understand the configuration landscape surrounding Network Controller Sideband Interface (NCSI). My immediate focus is on the `net/ncsi/Kconfig` file. I'm going to parse through the Kconfig to see what the dependencies are, which modules this is tied to, and how the various configuration options are structured. Understanding the Kconfig structure is fundamental to understanding any kernel module. I expect to find intricate interplays with other networking components, likely some hardware-specific configurations, and hopefully a clear view of how NCSI's features are exposed to the user. From a system design perspective, this Kconfig should reveal how extensible the implementation is, and if there are limitations on functionality depending on the system configuration. |
| 6/2 | 2026/08/30 07:43 | tool | read-file |
0mArgs:{
"File": "net/ncsi/Kconfig",
"FirstLine": 1,
"LineCount": 40
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# Configuration for NCSI support\n 4:\t#\n 5:\t\n 6:\tconfig NET_NCSI\n 7:\t\tbool \"NCSI interface support\"\n 8:\t\tdepends on INET\n 9:\t\thelp\n 10:\t\t This module provides NCSI (Network Controller Sideband Interface)\n 11:\t\t support. Enable this only if your system connects to a network\n 12:\t\t device via NCSI and the ethernet driver you're using supports\n 13:\t\t the protocol explicitly.\n 14:\tconfig NCSI_OEM_CMD_GET_MAC\n 15:\t\tbool \"Get NCSI OEM MAC Address\"\n 16:\t\tdepends on NET_NCSI\n 17:\t\thelp\n 18:\t\t This allows to get MAC address from NCSI firmware and set them back to\n 19:\t\t\tcontroller.\n 20:\tconfig NCSI_OEM_CMD_KEEP_PHY\n 21:\t\tbool \"Keep PHY Link up\"\n 22:\t\tdepends on NET_NCSI\n 23:\t\thelp\n 24:\t\t This allows to keep PHY link up and prevents any channel resets during\n 25:\t\t the host load.\n"
} |
| 7/2 | 2026/08/30 07:43 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 9848 output: 21 thoughts: 52 Thoughts: Here's my thought process, as if I were analyzing NCSI device registration: **NCSI Device Registration Deep Dive** Okay, so I'm digging into how NCSI devices are brought into the system and utilized. My first thought is to understand the mechanics – specifically, who's responsible for calling `ncsi_register_dev`. Is this triggered by some core network driver, or maybe something in the platform initialization? I need to trace the call chain. How does the NCSI interface expose its functionality to userspace, or, does it use netlink? Let's assume that it's going to use the classic approaches. The most direct approach seems to be a quick `grep` for `ncsi_register_dev` throughout the codebase. That should give me a good starting point, showing me the call sites and, hopefully, reveal the registration workflow and any associated initialization routines. From there, I can start to build a clearer picture of the NCSI device lifecycle within the kernel. |
| 8/2 | 2026/08/30 07:44 | tool | grepper |
0mArgs:{
"Expression": "ncsi_register_dev"
}Results: {
"Output": "drivers/net/ethernet/faraday/ftgmac100.c=1848=static int ftgmac100_probe_ncsi(struct net_device *netdev,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1862-\tpriv-\u003euse_ncsi = true;\ndrivers/net/ethernet/faraday/ftgmac100.c:1863:\tpriv-\u003endev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);\ndrivers/net/ethernet/faraday/ftgmac100.c-1864-\tif (!priv-\u003endev)\n--\ninclude/net/ncsi.h=35=int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid);\ninclude/net/ncsi.h:36:struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\ninclude/net/ncsi.h-37-\t\t\t\t void (*notifier)(struct ncsi_dev *nd));\n--\ninclude/net/ncsi.h=47=static inline int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)\n--\ninclude/net/ncsi.h-51-\ninclude/net/ncsi.h:52:static inline struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\ninclude/net/ncsi.h-53-\t\t\t\t\tvoid (*notifier)(struct ncsi_dev *nd))\n--\nnet/ncsi/ncsi-manage.c=1780=EXPORT_SYMBOL_GPL(ncsi_vlan_rx_kill_vid);\nnet/ncsi/ncsi-manage.c-1781-\nnet/ncsi/ncsi-manage.c:1782:struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\nnet/ncsi/ncsi-manage.c-1783-\t\t\t\t void (*handler)(struct ncsi_dev *ndev))\n--\nnet/ncsi/ncsi-manage.c-1843-}\nnet/ncsi/ncsi-manage.c:1844:EXPORT_SYMBOL_GPL(ncsi_register_dev);\nnet/ncsi/ncsi-manage.c-1845-\n"
} |
| 9/2 | 2026/08/30 07:44 | llm | patch-evaluator |
2mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 10780 output: 26 thoughts: 116 Thoughts: **Investigating NCSIs and ftgmac100.c** Okay, so `ftgmac100.c`—that's the driver for the Faraday FTGMAC100, the one used on those ASPEED AST2400/AST2500/AST2600 BMC SoCs. Hang on a minute... is *this* the only driver that's registering a NCSI device with `ncsi_register_dev`? I need to double-check. I could swear there are others... let's see. Just `ftgmac100`? That seems odd. Time to go hunting. I should probably do a broad search, to make sure I don't miss anything. Let's fire up `grep` and search the code base for any calls to *any* `ncsi_` functions. Or, for a more targeted search, I could focus directly on `ncsi_register_dev`. This should tell me the lay of the land. |
| 10/2 | 2026/08/30 07:46 | tool | grepper |
0mArgs:{
"Expression": "ncsi_",
"PathPrefix": "drivers/"
}Results: {
"Output": "drivers/infiniband/hw/ocrdma/ocrdma_sli.h=2123=struct mgmt_hba_attribs {\n--\ndrivers/infiniband/hw/ocrdma/ocrdma_sli.h-2129-\tu32 epfw_ds_ver;\ndrivers/infiniband/hw/ocrdma/ocrdma_sli.h:2130:\tu8 ncsi_ver_string[12];\ndrivers/infiniband/hw/ocrdma/ocrdma_sli.h-2131-\tu32 default_extended_timeout;\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c=73=static int bnge_devlink_info_get(struct devlink *devlink,\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-81-\tchar roce_ver[FW_VER_STR_LEN];\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:82:\tchar ncsi_ver[FW_VER_STR_LEN];\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-83-\tchar buf[32];\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-161-\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:162:\t\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-163-\t\t\t ver_resp-\u003emgmt_fw_major, ver_resp-\u003emgmt_fw_minor,\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-173-\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:174:\t\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-175-\t\t\t ver_resp-\u003emgmt_fw_maj_8b, ver_resp-\u003emgmt_fw_min_8b,\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-199-\trc = bnge_dl_info_put(bd, req, BNGE_VERSION_RUNNING,\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:200:\t\t\t DEVLINK_INFO_VERSION_GENERIC_FW_NCSI, ncsi_ver);\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-201-\tif (rc) {\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-238-\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:239:\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-240-\t\t nvm_dev_info.mgmt_fw_major, nvm_dev_info.mgmt_fw_minor,\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-242-\trc = bnge_dl_info_put(bd, req, BNGE_VERSION_STORED,\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c:243:\t\t\t DEVLINK_INFO_VERSION_GENERIC_FW_NCSI, ncsi_ver);\ndrivers/net/ethernet/broadcom/bnge/bnge_devlink.c-244-\tif (rc) {\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h=2042=struct os_drv_ver {\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2054-\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h:2055:struct ncsi_oem_fcoe_features {\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2056-\tu32 fcoe_features1;\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h=2107=struct mdump_driver_info {\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2120-\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h:2121:struct ncsi_oem_data {\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2122-\tu32 driver_version[4];\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h:2123:\tstruct ncsi_oem_fcoe_features ncsi_oem_fcoe_features;\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2124-};\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h=2126=struct shmem2_region {\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2227-\tu32 extended_dev_info_shared_addr;\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h:2228:\tu32 ncsi_oem_data_addr;\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h-2229-\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c=14669=static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl)\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14778-\t\t\tif ((ulp_type != CNIC_ULP_FCOE) ||\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:14779:\t\t\t (!SHMEM2_HAS(bp, ncsi_oem_data_addr)) ||\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14780-\t\t\t (!(bp-\u003eflags \u0026 BC_SUPPORTS_FCOE_FEATURES)))\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14783-\t\t\t/* if reached here - should write fcoe capabilities */\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:14784:\t\t\tscratch_offset = SHMEM2_RD(bp, ncsi_oem_data_addr);\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14785-\t\t\tif (!scratch_offset)\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14786-\t\t\t\tbreak;\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:14787:\t\t\tscratch_offset += offsetof(struct glob_ncsi_oem_data,\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c-14788-\t\t\t\t\t\t fcoe_features[path][port]);\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h=21=struct fcoe_capabilities {\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h-51-\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h:52:struct glob_ncsi_oem_data {\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h-53-\tu32 driver_version;\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c=856=static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-863-\tchar roce_ver[FW_VER_STR_LEN];\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:864:\tchar ncsi_ver[FW_VER_STR_LEN];\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-865-\tchar buf[32];\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-930-\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:931:\t\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-932-\t\t\t ver_resp-\u003emgmt_fw_major, ver_resp-\u003emgmt_fw_minor,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-942-\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:943:\t\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-944-\t\t\t ver_resp-\u003emgmt_fw_maj_8b, ver_resp-\u003emgmt_fw_min_8b,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-962-\trc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING,\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:963:\t\t\t DEVLINK_INFO_VERSION_GENERIC_FW_NCSI, ncsi_ver);\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-964-\tif (rc)\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-996-\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:997:\tsnprintf(ncsi_ver, FW_VER_STR_LEN, \"%d.%d.%d.%d\",\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-998-\t\t nvm_dev_info.mgmt_fw_major, nvm_dev_info.mgmt_fw_minor,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-1000-\trc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED,\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:1001:\t\t\t DEVLINK_INFO_VERSION_GENERIC_FW_NCSI, ncsi_ver);\ndrivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c-1002-\tif (rc)\n--\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c=4913=static void smb_intr_handler(struct adapter *adap)\n--\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-4928- */\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c:4929:static void ncsi_intr_handler(struct adapter *adap)\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-4930-{\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c:4931:\tstatic const struct intr_info ncsi_intr_info[] = {\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-4932-\t\t{ CIM_DM_PRTY_ERR_F, \"NC-SI CIM parity error\", -1, 1 },\n--\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-4938-\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c:4939:\tif (t4_handle_intr_status(adap, NCSI_INT_CAUSE_A, ncsi_intr_info))\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-4940-\t\tt4_fatal_err(adap);\n--\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c=4999=int t4_slow_intr_handler(struct adapter *adapter)\n--\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-5015-\tif (cause \u0026 NCSI_F)\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c:5016:\t\tncsi_intr_handler(adapter);\ndrivers/net/ethernet/chelsio/cxgb4/t4_hw.c-5017-\tif (cause \u0026 PL_F)\n--\ndrivers/net/ethernet/emulex/benet/be_cmds.c=2692=static int be_flash(struct be_adapter *adapter, const u8 *img,\n--\ndrivers/net/ethernet/emulex/benet/be_cmds.c-2733-#define NCSI_UPDATE_LOG\t\"NCSI section update is not supported in FW ver %s\\n\"\ndrivers/net/ethernet/emulex/benet/be_cmds.c:2734:static bool be_fw_ncsi_supported(char *ver)\ndrivers/net/ethernet/emulex/benet/be_cmds.c-2735-{\n--\ndrivers/net/ethernet/emulex/benet/be_cmds.c=2754=static int be_flash_BEx(struct be_adapter *adapter,\n--\ndrivers/net/ethernet/emulex/benet/be_cmds.c-2829-\t\tif ((pflashcomp[i].optype == OPTYPE_NCSI_FW) \u0026\u0026\ndrivers/net/ethernet/emulex/benet/be_cmds.c:2830:\t\t !be_fw_ncsi_supported(adapter-\u003efw_ver)) {\ndrivers/net/ethernet/emulex/benet/be_cmds.c-2831-\t\t\tdev_info(dev, NCSI_UPDATE_LOG, adapter-\u003efw_ver);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=43=struct ftgmac100_match_data {\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-66-/* For NC-SI to register a fixed-link phy device */\ndrivers/net/ethernet/faraday/ftgmac100.c:67:static struct fixed_phy_status ncsi_phy_status = {\ndrivers/net/ethernet/faraday/ftgmac100.c-68-\t.link = 1,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=75=struct ftgmac100 {\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-109-\tstruct device *dev;\ndrivers/net/ethernet/faraday/ftgmac100.c:110:\tstruct ncsi_dev *ndev;\ndrivers/net/ethernet/faraday/ftgmac100.c-111-\tstruct napi_struct napi;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1561=static int ftgmac100_open(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1617-\t\t/* Start the NCSI device */\ndrivers/net/ethernet/faraday/ftgmac100.c:1618:\t\terr = ncsi_start_dev(priv-\u003endev);\ndrivers/net/ethernet/faraday/ftgmac100.c-1619-\t\tif (err)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1640=static int ftgmac100_stop(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1660-\tif (priv-\u003euse_ncsi)\ndrivers/net/ethernet/faraday/ftgmac100.c:1661:\t\tncsi_stop_dev(priv-\u003endev);\ndrivers/net/ethernet/faraday/ftgmac100.c-1662-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1717=static const struct net_device_ops ftgmac100_netdev_ops = {\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1729-#endif\ndrivers/net/ethernet/faraday/ftgmac100.c:1730:\t.ndo_vlan_rx_add_vid\t= ncsi_vlan_rx_add_vid,\ndrivers/net/ethernet/faraday/ftgmac100.c:1731:\t.ndo_vlan_rx_kill_vid\t= ncsi_vlan_rx_kill_vid,\ndrivers/net/ethernet/faraday/ftgmac100.c-1732-};\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1780=static void ftgmac100_phy_disconnect(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1795-\ndrivers/net/ethernet/faraday/ftgmac100.c:1796:static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)\ndrivers/net/ethernet/faraday/ftgmac100.c-1797-{\ndrivers/net/ethernet/faraday/ftgmac100.c:1798:\tif (unlikely(nd-\u003estate != ncsi_dev_state_functional))\ndrivers/net/ethernet/faraday/ftgmac100.c-1799-\t\treturn;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1848=static int ftgmac100_probe_ncsi(struct net_device *netdev,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1862-\tpriv-\u003euse_ncsi = true;\ndrivers/net/ethernet/faraday/ftgmac100.c:1863:\tpriv-\u003endev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);\ndrivers/net/ethernet/faraday/ftgmac100.c-1864-\tif (!priv-\u003endev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1866-\ndrivers/net/ethernet/faraday/ftgmac100.c:1867:\tphydev = fixed_phy_register(\u0026ncsi_phy_status, np);\ndrivers/net/ethernet/faraday/ftgmac100.c-1868-\tif (IS_ERR(phydev)) {\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1884-\tif (priv-\u003endev)\ndrivers/net/ethernet/faraday/ftgmac100.c:1885:\t\tncsi_unregister_dev(priv-\u003endev);\ndrivers/net/ethernet/faraday/ftgmac100.c-1886-\tpriv-\u003endev = NULL;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1942=static int ftgmac100_probe(struct platform_device *pdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2097-\tif (priv-\u003endev)\ndrivers/net/ethernet/faraday/ftgmac100.c:2098:\t\tncsi_unregister_dev(priv-\u003endev);\ndrivers/net/ethernet/faraday/ftgmac100.c-2099-\treturn err;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=2102=static void ftgmac100_remove(struct platform_device *pdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2110-\tif (priv-\u003endev)\ndrivers/net/ethernet/faraday/ftgmac100.c:2111:\t\tncsi_unregister_dev(priv-\u003endev);\ndrivers/net/ethernet/faraday/ftgmac100.c-2112-\tunregister_netdev(netdev);\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c=302=static const struct hclge_dbg_dfx_message hclge_dbg_rpu_reg_1[] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-317-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:318:static const struct hclge_dbg_dfx_message hclge_dbg_ncsi_reg[] = {\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-319-\t{false, \"Reserved\"},\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c=664=static const struct hclge_dbg_reg_type_info hclge_dbg_reg_info[] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-700-\t{ .cmd = HNAE3_DBG_CMD_REG_NCSI,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:701:\t .dfx_msg = \u0026hclge_dbg_ncsi_reg[0],\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:702:\t .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ncsi_reg),\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-703-\t\t .offset = HCLGE_DBG_DFX_NCSI_OFFSET,\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c=1239=static int hclge_dbg_dump_rpu_reg_cmd(struct seq_file *s, void *data)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-1243-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:1244:static int hclge_dbg_dump_ncsi_reg_cmd(struct seq_file *s, void *data)\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-1245-{\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c=2938=static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-3036-\t\t.cmd = HNAE3_DBG_CMD_REG_NCSI,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:3037:\t\t.dbg_read_func = hclge_dbg_dump_ncsi_reg_cmd,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c-3038-\t},\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c=178=static const struct hclge_hw_error hclge_igu_egu_tnl_int[] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-207-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:208:static const struct hclge_hw_error hclge_ncsi_err_int[] = {\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-209-\t{\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-210-\t\t.int_msk = BIT(1),\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:211:\t\t.msg = \"ncsi_tx_ecc_mbit_err\",\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-212-\t\t.reset_level = HNAE3_NONE_RESET\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c=1705=static const struct hclge_hw_type_id hclge_hw_type_id_st[] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1742-\t\t.type_id = NCSI_ERROR,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:1743:\t\t.msg = \"ncsi_error\"\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1744-\t}, {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c=1820=static int hclge_config_common_hw_err_int(struct hclge_dev *hdev, bool en)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1856-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:1857:static int hclge_config_ncsi_hw_err_int(struct hclge_dev *hdev, bool en)\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1858-{\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c=1879=static int hclge_config_igu_egu_hw_err_int(struct hclge_dev *hdev, bool en)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1912-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:1913:\tret = hclge_config_ncsi_hw_err_int(hdev, en);\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-1914-\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c=2250=static int hclge_handle_mpf_ras_error(struct hclge_dev *hdev,\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-2387-\t\thclge_log_error(dev, \"NCSI_ECC_INT_RPT\",\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c:2388:\t\t\t\t\u0026hclge_ncsi_err_int[0], status,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c-2389-\t\t\t\t\u0026ae_dev-\u003ehw_err_reset_req);\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c=802=static bool hclge_cmd_crq_empty(struct hclge_hw *hw)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-808-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c:809:static void hclge_handle_ncsi_error(struct hclge_dev *hdev)\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-810-{\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c=1026=static int hclge_mbx_get_mac_addr_handler(struct hclge_mbx_ops_param *param)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-1031-\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c:1032:static int hclge_mbx_ncsi_error_handler(struct hclge_mbx_ops_param *param)\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-1033-{\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c:1034:\thclge_handle_ncsi_error(param-\u003evport-\u003eback);\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-1035-\treturn 0;\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c=1044=static const hclge_mbx_ops_fn hclge_mbx_ops_list[HCLGE_MBX_OPCODE_MAX] = {\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-1069-\t[HCLGE_MBX_PUSH_LINK_STATUS] = hclge_mbx_push_link_status_handler,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c:1070:\t[HCLGE_MBX_NCSI_ERROR] = hclge_mbx_ncsi_error_handler,\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c-1071-};\n--\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h=112=struct octep_iface_rx_stats {\n--\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h-146-\t/* NCSI-bound packets dropped */\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h:147:\tu64 ncsi_dropped_pkts;\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h-148-\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h-149-\t/* NCSI-bound octets dropped */\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h:150:\tu64 ncsi_dropped_octets;\ndrivers/net/ethernet/marvell/octeon_ep/octep_rx.h-151-\n--\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h=112=struct octep_vf_iface_rx_stats {\n--\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h-146-\t/* NCSI-bound packets dropped */\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h:147:\tu64 ncsi_dropped_pkts;\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h-148-\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h-149-\t/* NCSI-bound octets dropped */\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h:150:\tu64 ncsi_dropped_octets;\ndrivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.h-151-\n--\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h=500=struct public_global {\n--\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h-527-\tu32 ucast_dropped_to_bmc_cnt;\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h:528:\tu32 ncsi_response_failure_cnt;\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h-529-\tu32 device_attr;\n--\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h=578=struct public_port {\n--\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h-758-\tu32 nig_reg_stat_rx_bmb_packet;\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h:759:\tu32 nig_reg_rx_llh_ncsi_mcp_mask;\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h:760:\tu32 nig_reg_rx_llh_ncsi_mcp_mask_2;\ndrivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h-761-\tstruct pause_flood_monitor pause_flood_monitor;\n--\ndrivers/net/ethernet/wangxun/libwx/wx_type.h=1297=struct wx {\n--\ndrivers/net/ethernet/wangxun/libwx/wx_type.h-1340-\tbool wol_hw_supported;\ndrivers/net/ethernet/wangxun/libwx/wx_type.h:1341:\tbool ncsi_enabled;\ndrivers/net/ethernet/wangxun/libwx/wx_type.h-1342-\tbool gpio_ctrl;\n--\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c=68=static void ngbe_init_type_code(struct wx *wx)\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-69-{\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c:70:\tint wol_mask = 0, ncsi_mask = 0;\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-71-\tu16 type_mask = 0, val;\n--\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-74-\ttype_mask = (u16)(wx-\u003esubsystem_device_id \u0026 NGBE_OEM_MASK);\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c:75:\tncsi_mask = wx-\u003esubsystem_device_id \u0026 WX_NCSI_MASK;\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-76-\twol_mask = wx-\u003esubsystem_device_id \u0026 WX_WOL_MASK;\n--\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-83-\twx-\u003ewol_hw_supported = (wol_mask == WX_WOL_SUP) ? 1 : 0;\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c:84:\twx-\u003encsi_enabled = (ncsi_mask == WX_NCSI_SUP ||\ndrivers/net/ethernet/wangxun/ngbe/ngbe_main.c-85-\t\t\t type_mask == NGBE_SUBID_OCP_CARD) ? 1 : 0;\n--\ndrivers/scsi/be2iscsi/be_mgmt.h=66=struct mgmt_hba_attributes {\n--\ndrivers/scsi/be2iscsi/be_mgmt.h-74-\tu32 ep_fw_data_struct_version;\ndrivers/scsi/be2iscsi/be_mgmt.h:75:\tu8 ncsi_version_string[12];\ndrivers/scsi/be2iscsi/be_mgmt.h-76-\tu32 default_extended_timeout;\n--\ndrivers/scsi/csiostor/csio_hw.c=3526=static void csio_smb_intr_handler(struct csio_hw *hw)\n--\ndrivers/scsi/csiostor/csio_hw.c-3541- */\ndrivers/scsi/csiostor/csio_hw.c:3542:static void csio_ncsi_intr_handler(struct csio_hw *hw)\ndrivers/scsi/csiostor/csio_hw.c-3543-{\ndrivers/scsi/csiostor/csio_hw.c:3544:\tstatic struct intr_info ncsi_intr_info[] = {\ndrivers/scsi/csiostor/csio_hw.c-3545-\t\t{ CIM_DM_PRTY_ERR_F, \"NC-SI CIM parity error\", -1, 1 },\n--\ndrivers/scsi/csiostor/csio_hw.c-3551-\ndrivers/scsi/csiostor/csio_hw.c:3552:\tif (csio_handle_intr_status(hw, NCSI_INT_CAUSE_A, ncsi_intr_info))\ndrivers/scsi/csiostor/csio_hw.c-3553-\t\tcsio_hw_fatal_err(hw);\n--\ndrivers/scsi/csiostor/csio_hw.c=3599=csio_hw_slow_intr_handler(struct csio_hw *hw)\n--\ndrivers/scsi/csiostor/csio_hw.c-3618-\tif (cause \u0026 NCSI_F)\ndrivers/scsi/csiostor/csio_hw.c:3619:\t\tcsio_ncsi_intr_handler(hw);\ndrivers/scsi/csiostor/csio_hw.c-3620-\n--\ndrivers/scsi/elx/libefc_sli/sli4.h=2869=struct sli4_rsp_cmn_get_cntl_attributes {\n--\ndrivers/scsi/elx/libefc_sli/sli4.h-2878-\t__le32\t\tep_fw_ds_version;\ndrivers/scsi/elx/libefc_sli/sli4.h:2879:\tu8\t\tncsi_version_str[12];\ndrivers/scsi/elx/libefc_sli/sli4.h-2880-\t__le32\t\tdef_extended_timeout;\n--\ndrivers/scsi/lpfc/lpfc_hw4.h=3798=struct lpfc_controller_attribute {\n--\ndrivers/scsi/lpfc/lpfc_hw4.h-3809-\tuint32_t rsvd18[2];\ndrivers/scsi/lpfc/lpfc_hw4.h:3810:\tuint32_t ncsi_ver_str[3];\ndrivers/scsi/lpfc/lpfc_hw4.h-3811-\tuint32_t rsvd23;\n"
} |
| 11/2 | 2026/08/30 07:46 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 21931 output: 27 thoughts: 54 Thoughts: Here's my take on those NCSI netlink interactions... **NCSI Netlink Dive** Okay, so I'm taking a look at how NCSI interacts with the kernel's netlink generic netlink family. I need to get a handle on the message structure and the available commands. Time to dig into `net/ncsi/ncsi-netlink.c` and `net/ncsi/ncsi-netlink.h`. I expect to find the definitions for the NCSI specific netlink family, the attributes for the messages that are exchanged and the handler functions. These files should map out what operations are available to configure and manage NCSI interfaces using netlink. This is where the magic happens! |
| 12/2 | 2026/08/30 07:47 | tool | grepper |
0mArgs:{
"Expression": "genl",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/internal.h=356=struct ncsi_cmd_arg {\n--\nnet/ncsi/internal.h-369-\tunsigned char *data; /* NCSI OEM data */\nnet/ncsi/internal.h:370:\tstruct genl_info *info; /* Netlink information */\nnet/ncsi/internal.h-371-};\n--\nnet/ncsi/ncsi-netlink.c-20-\nnet/ncsi/ncsi-netlink.c:21:static struct genl_family ncsi_genl_family;\nnet/ncsi/ncsi-netlink.c-22-\nnet/ncsi/ncsi-netlink.c:23:static const struct nla_policy ncsi_genl_policy[NCSI_ATTR_MAX + 1] = {\nnet/ncsi/ncsi-netlink.c-24-\t[NCSI_ATTR_IFINDEX] =\t\t{ .type = NLA_U32 },\n--\nnet/ncsi/ncsi-netlink.c=90=static int ncsi_write_package_info(struct sk_buff *skb,\n--\nnet/ncsi/ncsi-netlink.c-149-\nnet/ncsi/ncsi-netlink.c:150:static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-151-{\n--\nnet/ncsi/ncsi-netlink.c-167-\nnet/ncsi/ncsi-netlink.c:168:\tndp = ndp_from_ifindex(genl_info_net(info),\nnet/ncsi/ncsi-netlink.c-169-\t\t\t nla_get_u32(info-\u003eattrs[NCSI_ATTR_IFINDEX]));\n--\nnet/ncsi/ncsi-netlink.c-172-\nnet/ncsi/ncsi-netlink.c:173:\tskb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\nnet/ncsi/ncsi-netlink.c-174-\tif (!skb) {\n--\nnet/ncsi/ncsi-netlink.c-178-\nnet/ncsi/ncsi-netlink.c:179:\thdr = genlmsg_put(skb, info-\u003esnd_portid, info-\u003esnd_seq,\nnet/ncsi/ncsi-netlink.c:180:\t\t\t \u0026ncsi_genl_family, 0, NCSI_CMD_PKG_INFO);\nnet/ncsi/ncsi-netlink.c-181-\tif (!hdr) {\n--\nnet/ncsi/ncsi-netlink.c-206-\nnet/ncsi/ncsi-netlink.c:207:\tgenlmsg_end(skb, hdr);\nnet/ncsi/ncsi-netlink.c-208-\tncsi_dev_put(ndp);\nnet/ncsi/ncsi-netlink.c:209:\treturn genlmsg_reply(skb, info);\nnet/ncsi/ncsi-netlink.c-210-\n--\nnet/ncsi/ncsi-netlink.c=217=static int ncsi_pkg_info_all_nl(struct sk_buff *skb,\n--\nnet/ncsi/ncsi-netlink.c-227-\nnet/ncsi/ncsi-netlink.c:228:\trc = genlmsg_parse_deprecated(cb-\u003enlh, \u0026ncsi_genl_family, attrs, NCSI_ATTR_MAX,\nnet/ncsi/ncsi-netlink.c:229:\t\t\t\t ncsi_genl_policy, NULL);\nnet/ncsi/ncsi-netlink.c-230-\tif (rc)\n--\nnet/ncsi/ncsi-netlink.c-253-\t}\nnet/ncsi/ncsi-netlink.c:254:\thdr = genlmsg_put(skb, NETLINK_CB(cb-\u003eskb).portid, cb-\u003enlh-\u003enlmsg_seq,\nnet/ncsi/ncsi-netlink.c:255:\t\t\t \u0026ncsi_genl_family, NLM_F_MULTI, NCSI_CMD_PKG_INFO);\nnet/ncsi/ncsi-netlink.c-256-\tif (!hdr) {\n--\nnet/ncsi/ncsi-netlink.c-274-\tnla_nest_end(skb, attr);\nnet/ncsi/ncsi-netlink.c:275:\tgenlmsg_end(skb, hdr);\nnet/ncsi/ncsi-netlink.c-276-\n--\nnet/ncsi/ncsi-netlink.c-283-\trcu_read_unlock();\nnet/ncsi/ncsi-netlink.c:284:\tgenlmsg_cancel(skb, hdr);\nnet/ncsi/ncsi-netlink.c-285-\tncsi_dev_put(ndp);\n--\nnet/ncsi/ncsi-netlink.c-288-\nnet/ncsi/ncsi-netlink.c:289:static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-290-{\n--\nnet/ncsi/ncsi-netlink.c-377-\nnet/ncsi/ncsi-netlink.c:378:static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-379-{\n--\nnet/ncsi/ncsi-netlink.c-420-\nnet/ncsi/ncsi-netlink.c:421:static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-422-{\n--\nnet/ncsi/ncsi-netlink.c=513=int ncsi_send_netlink_rsp(struct ncsi_request *nr,\n--\nnet/ncsi/ncsi-netlink.c-523-\nnet/ncsi/ncsi-netlink.c:524:\tskb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\nnet/ncsi/ncsi-netlink.c-525-\tif (!skb)\n--\nnet/ncsi/ncsi-netlink.c-527-\nnet/ncsi/ncsi-netlink.c:528:\thdr = genlmsg_put(skb, nr-\u003esnd_portid, nr-\u003esnd_seq,\nnet/ncsi/ncsi-netlink.c:529:\t\t\t \u0026ncsi_genl_family, 0, NCSI_CMD_SEND_CMD);\nnet/ncsi/ncsi-netlink.c-530-\tif (!hdr) {\n--\nnet/ncsi/ncsi-netlink.c-546-\nnet/ncsi/ncsi-netlink.c:547:\tgenlmsg_end(skb, hdr);\nnet/ncsi/ncsi-netlink.c:548:\treturn genlmsg_unicast(net, skb, nr-\u003esnd_portid);\nnet/ncsi/ncsi-netlink.c-549-\n--\nnet/ncsi/ncsi-netlink.c=555=int ncsi_send_netlink_timeout(struct ncsi_request *nr,\n--\nnet/ncsi/ncsi-netlink.c-562-\nnet/ncsi/ncsi-netlink.c:563:\tskb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\nnet/ncsi/ncsi-netlink.c-564-\tif (!skb)\n--\nnet/ncsi/ncsi-netlink.c-566-\nnet/ncsi/ncsi-netlink.c:567:\thdr = genlmsg_put(skb, nr-\u003esnd_portid, nr-\u003esnd_seq,\nnet/ncsi/ncsi-netlink.c:568:\t\t\t \u0026ncsi_genl_family, 0, NCSI_CMD_SEND_CMD);\nnet/ncsi/ncsi-netlink.c-569-\tif (!hdr) {\n--\nnet/ncsi/ncsi-netlink.c-589-\nnet/ncsi/ncsi-netlink.c:590:\tgenlmsg_end(skb, hdr);\nnet/ncsi/ncsi-netlink.c:591:\treturn genlmsg_unicast(net, skb, nr-\u003esnd_portid);\nnet/ncsi/ncsi-netlink.c-592-}\n--\nnet/ncsi/ncsi-netlink.c=594=int ncsi_send_netlink_err(struct net_device *dev,\n--\nnet/ncsi/ncsi-netlink.c-618-\nnet/ncsi/ncsi-netlink.c:619:\treturn nlmsg_unicast(net-\u003egenl_sock, skb, snd_portid);\nnet/ncsi/ncsi-netlink.c-620-}\n--\nnet/ncsi/ncsi-netlink.c=622=static int ncsi_set_package_mask_nl(struct sk_buff *msg,\nnet/ncsi/ncsi-netlink.c:623:\t\t\t\t struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-624-{\n--\nnet/ncsi/ncsi-netlink.c=673=static int ncsi_set_channel_mask_nl(struct sk_buff *msg,\nnet/ncsi/ncsi-netlink.c:674:\t\t\t\t struct genl_info *info)\nnet/ncsi/ncsi-netlink.c-675-{\n--\nnet/ncsi/ncsi-netlink.c-760-\nnet/ncsi/ncsi-netlink.c:761:static const struct genl_small_ops ncsi_ops[] = {\nnet/ncsi/ncsi-netlink.c-762-\t{\n--\nnet/ncsi/ncsi-netlink.c-800-\nnet/ncsi/ncsi-netlink.c:801:static struct genl_family ncsi_genl_family __ro_after_init = {\nnet/ncsi/ncsi-netlink.c-802-\t.name = \"NCSI\",\n--\nnet/ncsi/ncsi-netlink.c-804-\t.maxattr = NCSI_ATTR_MAX,\nnet/ncsi/ncsi-netlink.c:805:\t.policy = ncsi_genl_policy,\nnet/ncsi/ncsi-netlink.c-806-\t.module = THIS_MODULE,\n--\nnet/ncsi/ncsi-netlink.c=812=static int __init ncsi_init_netlink(void)\nnet/ncsi/ncsi-netlink.c-813-{\nnet/ncsi/ncsi-netlink.c:814:\treturn genl_register_family(\u0026ncsi_genl_family);\nnet/ncsi/ncsi-netlink.c-815-}\n"
} |
| 13/2 | 2026/08/30 07:47 | llm | patch-evaluator |
2mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 25295 output: 25 thoughts: 37 Thoughts: Here's my take on those thoughts: **NCSI Initialization and Build Process: A Quick Dive** Hold on a minute, let's zero in on this `ncsi_init_netlink()` function. I need to understand how the NCSI module gets off the ground. My first move is to jump straight to the source, the `net/ncsi/Makefile`. That file is the key to understanding how this whole NCSI thing is compiled and linked into the kernel. It’ll tell me the dependencies, the build flags, and hopefully give me a bird's-eye view of the NCSI integration process. From there I can piece together the rest of the puzzle. |
| 14/2 | 2026/08/30 07:49 | tool | grepper |
0mArgs:{
"Expression": "ncsi",
"PathPrefix": "net/"
}Results: {
"Output": "\nFull output is too long, showing 500 out of 2673 lines.\nUse more precise expression if possible.\n\nnet/Kconfig=282=source \"net/qrtr/Kconfig\"\nnet/Kconfig:283:source \"net/ncsi/Kconfig\"\nnet/Kconfig-284-\n--\nnet/Makefile=71=obj-$(CONFIG_QRTR)\t\t+= qrtr/\nnet/Makefile:72:obj-$(CONFIG_NET_NCSI)\t\t+= ncsi/\nnet/Makefile-73-obj-$(CONFIG_XDP_SOCKETS)\t+= xdp/\n--\nnet/ncsi/Makefile-4-#\nnet/ncsi/Makefile:5:obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-aen.o ncsi-manage.o ncsi-netlink.o\n--\nnet/ncsi/internal.h=73=enum {\n--\nnet/ncsi/internal.h-106-\nnet/ncsi/internal.h:107:struct ncsi_channel_version {\nnet/ncsi/internal.h-108-\tu8 major;\t\t/* NCSI version major */\n--\nnet/ncsi/internal.h-118-\nnet/ncsi/internal.h:119:struct ncsi_channel_cap {\nnet/ncsi/internal.h-120-\tu32 index;\t/* Index of channel capabilities */\n--\nnet/ncsi/internal.h-123-\nnet/ncsi/internal.h:124:struct ncsi_channel_mode {\nnet/ncsi/internal.h-125-\tu32 index;\t/* Index of channel modes */\n--\nnet/ncsi/internal.h-130-\nnet/ncsi/internal.h:131:struct ncsi_channel_mac_filter {\nnet/ncsi/internal.h-132-\tu8\tn_uc;\n--\nnet/ncsi/internal.h-138-\nnet/ncsi/internal.h:139:struct ncsi_channel_vlan_filter {\nnet/ncsi/internal.h-140-\tu8\tn_vids;\n--\nnet/ncsi/internal.h-144-\nnet/ncsi/internal.h:145:struct ncsi_channel_stats {\nnet/ncsi/internal.h-146-\tu64 hnc_cnt;\t\t/* Counter cleared */\n--\nnet/ncsi/internal.h-185-\tu32 hnc_rx_jabber_pkts;\t/* Rx error jabber packets */\nnet/ncsi/internal.h:186:\tu32 ncsi_rx_cmds;\t/* Rx NCSI commands */\nnet/ncsi/internal.h:187:\tu32 ncsi_dropped_cmds;\t/* Dropped commands */\nnet/ncsi/internal.h:188:\tu32 ncsi_cmd_type_errs;\t/* Command type errors */\nnet/ncsi/internal.h:189:\tu32 ncsi_cmd_csum_errs;\t/* Command checksum errors */\nnet/ncsi/internal.h:190:\tu32 ncsi_rx_pkts;\t/* Rx NCSI packets */\nnet/ncsi/internal.h:191:\tu32 ncsi_tx_pkts;\t/* Tx NCSI packets */\nnet/ncsi/internal.h:192:\tu32 ncsi_tx_aen_pkts;\t/* Tx AEN packets */\nnet/ncsi/internal.h-193-\tu32 pt_tx_pkts;\t\t/* Tx packets */\n--\nnet/ncsi/internal.h-203-\nnet/ncsi/internal.h:204:struct ncsi_dev_priv;\nnet/ncsi/internal.h:205:struct ncsi_package;\nnet/ncsi/internal.h-206-\n--\nnet/ncsi/internal.h-214-\nnet/ncsi/internal.h:215:struct ncsi_channel {\nnet/ncsi/internal.h-216-\tunsigned char id;\n--\nnet/ncsi/internal.h-222-\tspinlock_t lock;\t/* Protect filters etc */\nnet/ncsi/internal.h:223:\tstruct ncsi_package *package;\nnet/ncsi/internal.h:224:\tstruct ncsi_channel_version version;\nnet/ncsi/internal.h:225:\tstruct ncsi_channel_cap\t caps[NCSI_CAP_MAX];\nnet/ncsi/internal.h:226:\tstruct ncsi_channel_mode modes[NCSI_MODE_MAX];\nnet/ncsi/internal.h-227-\t/* Filtering Settings */\nnet/ncsi/internal.h:228:\tstruct ncsi_channel_mac_filter\tmac_filter;\nnet/ncsi/internal.h:229:\tstruct ncsi_channel_vlan_filter\tvlan_filter;\nnet/ncsi/internal.h:230:\tstruct ncsi_channel_stats stats;\nnet/ncsi/internal.h-231-\tstruct {\n--\nnet/ncsi/internal.h-244-\nnet/ncsi/internal.h:245:struct ncsi_package {\nnet/ncsi/internal.h-246-\tunsigned char id; /* NCSI 3-bits package ID */\nnet/ncsi/internal.h-247-\tunsigned char uuid[16]; /* UUID */\nnet/ncsi/internal.h:248:\tstruct ncsi_dev_priv *ndp; /* NCSI device */\nnet/ncsi/internal.h-249-\tspinlock_t lock; /* Protect the package */\n--\nnet/ncsi/internal.h-255-\tu32 channel_whitelist; /* Channels to configure */\nnet/ncsi/internal.h:256:\tstruct ncsi_channel *preferred_channel; /* Primary channel */\nnet/ncsi/internal.h-257-\tstruct rcu_head rcu; /* RCU cleanup */\n--\nnet/ncsi/internal.h-259-\nnet/ncsi/internal.h:260:struct ncsi_request {\nnet/ncsi/internal.h-261-\tunsigned char id; /* Request ID - 0 to 255 */\n--\nnet/ncsi/internal.h-265-#define NCSI_REQ_FLAG_NETLINK_DRIVEN\t2\nnet/ncsi/internal.h:266:\tstruct ncsi_dev_priv *ndp; /* Associated NCSI device */\nnet/ncsi/internal.h-267-\tstruct sk_buff *cmd; /* Associated NCSI command packet */\n--\nnet/ncsi/internal.h=276=enum {\nnet/ncsi/internal.h:277:\tncsi_dev_state_major\t\t= 0xff00,\nnet/ncsi/internal.h:278:\tncsi_dev_state_minor\t\t= 0x00ff,\nnet/ncsi/internal.h:279:\tncsi_dev_state_probe_deselect\t= 0x0201,\nnet/ncsi/internal.h:280:\tncsi_dev_state_probe_package,\nnet/ncsi/internal.h:281:\tncsi_dev_state_probe_channel,\nnet/ncsi/internal.h:282:\tncsi_dev_state_probe_mlx_gma,\nnet/ncsi/internal.h:283:\tncsi_dev_state_probe_mlx_smaf,\nnet/ncsi/internal.h:284:\tncsi_dev_state_probe_cis,\nnet/ncsi/internal.h:285:\tncsi_dev_state_probe_keep_phy,\nnet/ncsi/internal.h:286:\tncsi_dev_state_probe_gvi,\nnet/ncsi/internal.h:287:\tncsi_dev_state_probe_gc,\nnet/ncsi/internal.h:288:\tncsi_dev_state_probe_gls,\nnet/ncsi/internal.h:289:\tncsi_dev_state_probe_dp,\nnet/ncsi/internal.h:290:\tncsi_dev_state_config_sp\t= 0x0301,\nnet/ncsi/internal.h:291:\tncsi_dev_state_config_cis,\nnet/ncsi/internal.h:292:\tncsi_dev_state_config_oem_gma,\nnet/ncsi/internal.h:293:\tncsi_dev_state_config_apply_mac,\nnet/ncsi/internal.h:294:\tncsi_dev_state_config_clear_vids,\nnet/ncsi/internal.h:295:\tncsi_dev_state_config_svf,\nnet/ncsi/internal.h:296:\tncsi_dev_state_config_ev,\nnet/ncsi/internal.h:297:\tncsi_dev_state_config_sma,\nnet/ncsi/internal.h:298:\tncsi_dev_state_config_ebf,\nnet/ncsi/internal.h:299:\tncsi_dev_state_config_dgmf,\nnet/ncsi/internal.h:300:\tncsi_dev_state_config_ecnt,\nnet/ncsi/internal.h:301:\tncsi_dev_state_config_ec,\nnet/ncsi/internal.h:302:\tncsi_dev_state_config_ae,\nnet/ncsi/internal.h:303:\tncsi_dev_state_config_gls,\nnet/ncsi/internal.h:304:\tncsi_dev_state_config_done,\nnet/ncsi/internal.h:305:\tncsi_dev_state_suspend_select\t= 0x0401,\nnet/ncsi/internal.h:306:\tncsi_dev_state_suspend_gls,\nnet/ncsi/internal.h:307:\tncsi_dev_state_suspend_dcnt,\nnet/ncsi/internal.h:308:\tncsi_dev_state_suspend_dc,\nnet/ncsi/internal.h:309:\tncsi_dev_state_suspend_deselect,\nnet/ncsi/internal.h:310:\tncsi_dev_state_suspend_done\nnet/ncsi/internal.h-311-};\n--\nnet/ncsi/internal.h=313=struct vlan_vid {\n--\nnet/ncsi/internal.h-318-\nnet/ncsi/internal.h:319:struct ncsi_dev_priv {\nnet/ncsi/internal.h-320-\tstruct rcu_head rcu; /* RCU cleanup */\nnet/ncsi/internal.h-321-\tstruct kref ref;\nnet/ncsi/internal.h:322:\tstruct ncsi_dev ndev; /* Associated NCSI device */\nnet/ncsi/internal.h-323-\tunsigned int flags; /* NCSI device flags */\n--\nnet/ncsi/internal.h-334-\tstruct list_head packages; /* List of packages */\nnet/ncsi/internal.h:335:\tstruct ncsi_channel *hot_channel; /* Channel was ever active */\nnet/ncsi/internal.h:336:\tstruct ncsi_request requests[256]; /* Request table */\nnet/ncsi/internal.h-337-\tunsigned int request_id; /* Last used request ID */\n--\nnet/ncsi/internal.h-339-\tunsigned int pending_req_num; /* Number of pending requests */\nnet/ncsi/internal.h:340:\tstruct ncsi_package *active_package; /* Currently handled package */\nnet/ncsi/internal.h:341:\tstruct ncsi_channel *active_channel; /* Currently handled channel */\nnet/ncsi/internal.h-342-\tstruct list_head channel_queue; /* Config queue of channels */\n--\nnet/ncsi/internal.h-355-\nnet/ncsi/internal.h:356:struct ncsi_cmd_arg {\nnet/ncsi/internal.h:357:\tstruct ncsi_dev_priv *ndp; /* Associated NCSI device */\nnet/ncsi/internal.h-358-\tunsigned char type; /* Command in the NCSI packet */\n--\nnet/ncsi/internal.h-372-\nnet/ncsi/internal.h:373:extern struct list_head ncsi_dev_list;\nnet/ncsi/internal.h:374:extern spinlock_t ncsi_dev_lock;\nnet/ncsi/internal.h-375-\nnet/ncsi/internal.h-376-#define TO_NCSI_DEV_PRIV(nd) \\\nnet/ncsi/internal.h:377:\tcontainer_of(nd, struct ncsi_dev_priv, ndev)\nnet/ncsi/internal.h-378-#define NCSI_FOR_EACH_DEV(ndp) \\\nnet/ncsi/internal.h:379:\tlist_for_each_entry_rcu(ndp, \u0026ncsi_dev_list, node)\nnet/ncsi/internal.h-380-#define NCSI_FOR_EACH_PACKAGE(ndp, np) \\\n--\nnet/ncsi/internal.h-385-/* Resources */\nnet/ncsi/internal.h:386:int ncsi_reset_dev(struct ncsi_dev *nd);\nnet/ncsi/internal.h:387:void ncsi_start_channel_monitor(struct ncsi_channel *nc);\nnet/ncsi/internal.h:388:void ncsi_stop_channel_monitor(struct ncsi_channel *nc);\nnet/ncsi/internal.h:389:struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,\nnet/ncsi/internal.h-390-\t\t\t\t unsigned char id);\nnet/ncsi/internal.h:391:struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np,\nnet/ncsi/internal.h-392-\t\t\t\t unsigned char id);\nnet/ncsi/internal.h:393:struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h-394-\t\t\t\t unsigned char id);\nnet/ncsi/internal.h:395:struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h-396-\t\t\t\t unsigned char id);\nnet/ncsi/internal.h:397:void ncsi_remove_package(struct ncsi_package *np);\nnet/ncsi/internal.h:398:void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h-399-\t\t\t\t unsigned char id,\nnet/ncsi/internal.h:400:\t\t\t\t struct ncsi_package **np,\nnet/ncsi/internal.h:401:\t\t\t\t struct ncsi_channel **nc);\nnet/ncsi/internal.h:402:struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h-403-\t\t\t\t\tunsigned int req_flags);\nnet/ncsi/internal.h:404:void ncsi_free_request(struct ncsi_request *nr);\nnet/ncsi/internal.h:405:struct ncsi_dev *ncsi_find_dev(struct net_device *dev);\nnet/ncsi/internal.h:406:int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);\nnet/ncsi/internal.h:407:bool ncsi_channel_has_link(struct ncsi_channel *channel);\nnet/ncsi/internal.h:408:bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h:409:\t\t\t struct ncsi_channel *channel);\nnet/ncsi/internal.h:410:int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,\nnet/ncsi/internal.h:411:\t\t\t struct ncsi_package *np,\nnet/ncsi/internal.h:412:\t\t\t struct ncsi_channel *disable,\nnet/ncsi/internal.h:413:\t\t\t struct ncsi_channel *enable);\nnet/ncsi/internal.h:414:struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev);\nnet/ncsi/internal.h:415:void ncsi_dev_put(struct ncsi_dev_priv *ndp);\nnet/ncsi/internal.h-416-/* Packet handlers */\nnet/ncsi/internal.h:417:u32 ncsi_calculate_checksum(unsigned char *data, int len);\nnet/ncsi/internal.h:418:int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);\nnet/ncsi/internal.h:419:int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,\nnet/ncsi/internal.h-420-\t\t struct packet_type *pt, struct net_device *orig_dev);\nnet/ncsi/internal.h:421:int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb);\nnet/ncsi/internal.h-422-\n--\nnet/ncsi/ncsi-aen.c-11-\nnet/ncsi/ncsi-aen.c:12:#include \u003cnet/ncsi.h\u003e\nnet/ncsi/ncsi-aen.c-13-#include \u003cnet/net_namespace.h\u003e\n--\nnet/ncsi/ncsi-aen.c-16-#include \"internal.h\"\nnet/ncsi/ncsi-aen.c:17:#include \"ncsi-pkt.h\"\nnet/ncsi/ncsi-aen.c-18-\nnet/ncsi/ncsi-aen.c:19:static int ncsi_validate_aen_pkt(struct ncsi_aen_pkt_hdr *h,\nnet/ncsi/ncsi-aen.c-20-\t\t\t\t const unsigned short payload)\n--\nnet/ncsi/ncsi-aen.c-37-\nnet/ncsi/ncsi-aen.c:38:\tchecksum = ncsi_calculate_checksum((unsigned char *)h,\nnet/ncsi/ncsi-aen.c-39-\t\t\t\t\t sizeof(*h) + payload - 4);\n--\nnet/ncsi/ncsi-aen.c-45-\nnet/ncsi/ncsi-aen.c:46:static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,\nnet/ncsi/ncsi-aen.c:47:\t\t\t\tstruct ncsi_aen_pkt_hdr *h)\nnet/ncsi/ncsi-aen.c-48-{\nnet/ncsi/ncsi-aen.c:49:\tstruct ncsi_channel *nc, *tmp;\nnet/ncsi/ncsi-aen.c:50:\tstruct ncsi_channel_mode *ncm;\nnet/ncsi/ncsi-aen.c-51-\tunsigned long old_data, data;\nnet/ncsi/ncsi-aen.c:52:\tstruct ncsi_aen_lsc_pkt *lsc;\nnet/ncsi/ncsi-aen.c:53:\tstruct ncsi_package *np;\nnet/ncsi/ncsi-aen.c-54-\tbool had_link, has_link;\n--\nnet/ncsi/ncsi-aen.c-59-\t/* Find the NCSI channel */\nnet/ncsi/ncsi-aen.c:60:\tncsi_find_package_and_channel(ndp, h-\u003ecommon.channel, NULL, \u0026nc);\nnet/ncsi/ncsi-aen.c-61-\tif (!nc)\n--\nnet/ncsi/ncsi-aen.c-64-\t/* Update the link status */\nnet/ncsi/ncsi-aen.c:65:\tlsc = (struct ncsi_aen_lsc_pkt *)h;\nnet/ncsi/ncsi-aen.c-66-\n--\nnet/ncsi/ncsi-aen.c-94-\t\t\tndp-\u003eflags |= NCSI_DEV_RESHUFFLE;\nnet/ncsi/ncsi-aen.c:95:\t\t\tncsi_stop_channel_monitor(nc);\nnet/ncsi/ncsi-aen.c-96-\t\t\tspin_lock_irqsave(\u0026ndp-\u003elock, flags);\n--\nnet/ncsi/ncsi-aen.c-98-\t\t\tspin_unlock_irqrestore(\u0026ndp-\u003elock, flags);\nnet/ncsi/ncsi-aen.c:99:\t\t\treturn ncsi_process_next_channel(ndp);\nnet/ncsi/ncsi-aen.c-100-\t\t}\n--\nnet/ncsi/ncsi-aen.c-106-\t\tncm = \u0026nc-\u003emodes[NCSI_MODE_TX_ENABLE];\nnet/ncsi/ncsi-aen.c:107:\t\tif (ncsi_channel_is_last(ndp, nc)) {\nnet/ncsi/ncsi-aen.c-108-\t\t\t/* No channels left, reconfigure */\nnet/ncsi/ncsi-aen.c:109:\t\t\treturn ncsi_reset_dev(\u0026ndp-\u003endev);\nnet/ncsi/ncsi-aen.c-110-\t\t} else if (ncm-\u003eenable) {\nnet/ncsi/ncsi-aen.c-111-\t\t\t/* Need to failover Tx channel */\nnet/ncsi/ncsi-aen.c:112:\t\t\tncsi_update_tx_channel(ndp, nc-\u003epackage, nc, NULL);\nnet/ncsi/ncsi-aen.c-113-\t\t}\n--\nnet/ncsi/ncsi-aen.c-115-\t\t/* Return Tx to preferred channel */\nnet/ncsi/ncsi-aen.c:116:\t\tncsi_update_tx_channel(ndp, nc-\u003epackage, NULL, nc);\nnet/ncsi/ncsi-aen.c-117-\t} else if (has_link) {\n--\nnet/ncsi/ncsi-aen.c-124-\t\t\t\tif (ncm-\u003eenable \u0026\u0026\nnet/ncsi/ncsi-aen.c:125:\t\t\t\t !ncsi_channel_has_link(tmp)) {\nnet/ncsi/ncsi-aen.c:126:\t\t\t\t\tncsi_update_tx_channel(ndp, nc-\u003epackage,\nnet/ncsi/ncsi-aen.c-127-\t\t\t\t\t\t\t tmp, nc);\n--\nnet/ncsi/ncsi-aen.c-139-\nnet/ncsi/ncsi-aen.c:140:static int ncsi_aen_handler_cr(struct ncsi_dev_priv *ndp,\nnet/ncsi/ncsi-aen.c:141:\t\t\t struct ncsi_aen_pkt_hdr *h)\nnet/ncsi/ncsi-aen.c-142-{\nnet/ncsi/ncsi-aen.c:143:\tstruct ncsi_channel *nc;\nnet/ncsi/ncsi-aen.c-144-\tunsigned long flags;\n--\nnet/ncsi/ncsi-aen.c-146-\t/* Find the NCSI channel */\nnet/ncsi/ncsi-aen.c:147:\tncsi_find_package_and_channel(ndp, h-\u003ecommon.channel, NULL, \u0026nc);\nnet/ncsi/ncsi-aen.c-148-\tif (!nc)\n--\nnet/ncsi/ncsi-aen.c-158-\nnet/ncsi/ncsi-aen.c:159:\tncsi_stop_channel_monitor(nc);\nnet/ncsi/ncsi-aen.c-160-\tspin_lock_irqsave(\u0026nc-\u003elock, flags);\n--\nnet/ncsi/ncsi-aen.c-169-\nnet/ncsi/ncsi-aen.c:170:\treturn ncsi_process_next_channel(ndp);\nnet/ncsi/ncsi-aen.c-171-}\nnet/ncsi/ncsi-aen.c-172-\nnet/ncsi/ncsi-aen.c:173:static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,\nnet/ncsi/ncsi-aen.c:174:\t\t\t\t struct ncsi_aen_pkt_hdr *h)\nnet/ncsi/ncsi-aen.c-175-{\nnet/ncsi/ncsi-aen.c:176:\tstruct ncsi_channel *nc;\nnet/ncsi/ncsi-aen.c:177:\tstruct ncsi_channel_mode *ncm;\nnet/ncsi/ncsi-aen.c:178:\tstruct ncsi_aen_hncdsc_pkt *hncdsc;\nnet/ncsi/ncsi-aen.c-179-\tunsigned long flags;\n--\nnet/ncsi/ncsi-aen.c-181-\t/* Find the NCSI channel */\nnet/ncsi/ncsi-aen.c:182:\tncsi_find_package_and_channel(ndp, h-\u003ecommon.channel, NULL, \u0026nc);\nnet/ncsi/ncsi-aen.c-183-\tif (!nc)\n--\nnet/ncsi/ncsi-aen.c-187-\tncm = \u0026nc-\u003emodes[NCSI_MODE_LINK];\nnet/ncsi/ncsi-aen.c:188:\thncdsc = (struct ncsi_aen_hncdsc_pkt *)h;\nnet/ncsi/ncsi-aen.c-189-\tncm-\u003edata[3] = ntohl(hncdsc-\u003estatus);\n--\nnet/ncsi/ncsi-aen.c-197-\nnet/ncsi/ncsi-aen.c:198:static struct ncsi_aen_handler {\nnet/ncsi/ncsi-aen.c-199-\tunsigned char type;\nnet/ncsi/ncsi-aen.c-200-\tint payload;\nnet/ncsi/ncsi-aen.c:201:\tint (*handler)(struct ncsi_dev_priv *ndp,\nnet/ncsi/ncsi-aen.c:202:\t\t\t\t struct ncsi_aen_pkt_hdr *h);\nnet/ncsi/ncsi-aen.c:203:} ncsi_aen_handlers[] = {\nnet/ncsi/ncsi-aen.c:204:\t{ NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },\nnet/ncsi/ncsi-aen.c:205:\t{ NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr },\nnet/ncsi/ncsi-aen.c:206:\t{ NCSI_PKT_AEN_HNCDSC, 8, ncsi_aen_handler_hncdsc }\nnet/ncsi/ncsi-aen.c-207-};\nnet/ncsi/ncsi-aen.c-208-\nnet/ncsi/ncsi-aen.c:209:int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)\nnet/ncsi/ncsi-aen.c-210-{\nnet/ncsi/ncsi-aen.c:211:\tstruct ncsi_aen_pkt_hdr *h;\nnet/ncsi/ncsi-aen.c:212:\tstruct ncsi_aen_handler *nah = NULL;\nnet/ncsi/ncsi-aen.c-213-\tint i, ret;\n--\nnet/ncsi/ncsi-aen.c-215-\t/* Find the handler */\nnet/ncsi/ncsi-aen.c:216:\th = (struct ncsi_aen_pkt_hdr *)skb_network_header(skb);\nnet/ncsi/ncsi-aen.c:217:\tfor (i = 0; i \u003c ARRAY_SIZE(ncsi_aen_handlers); i++) {\nnet/ncsi/ncsi-aen.c:218:\t\tif (ncsi_aen_handlers[i].type == h-\u003etype) {\nnet/ncsi/ncsi-aen.c:219:\t\t\tnah = \u0026ncsi_aen_handlers[i];\nnet/ncsi/ncsi-aen.c-220-\t\t\tbreak;\n--\nnet/ncsi/ncsi-aen.c-230-\nnet/ncsi/ncsi-aen.c:231:\tret = ncsi_validate_aen_pkt(h, nah-\u003epayload);\nnet/ncsi/ncsi-aen.c-232-\tif (ret) {\n--\nnet/ncsi/ncsi-cmd.c-12-\nnet/ncsi/ncsi-cmd.c:13:#include \u003cnet/ncsi.h\u003e\nnet/ncsi/ncsi-cmd.c-14-#include \u003cnet/net_namespace.h\u003e\n--\nnet/ncsi/ncsi-cmd.c-18-#include \"internal.h\"\nnet/ncsi/ncsi-cmd.c:19:#include \"ncsi-pkt.h\"\nnet/ncsi/ncsi-cmd.c-20-\nnet/ncsi/ncsi-cmd.c=21=static const int padding_bytes = 26;\nnet/ncsi/ncsi-cmd.c-22-\nnet/ncsi/ncsi-cmd.c:23:u32 ncsi_calculate_checksum(unsigned char *data, int len)\nnet/ncsi/ncsi-cmd.c-24-{\n--\nnet/ncsi/ncsi-cmd.c-37- */\nnet/ncsi/ncsi-cmd.c:38:static void ncsi_cmd_build_header(struct ncsi_pkt_hdr *h,\nnet/ncsi/ncsi-cmd.c:39:\t\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-40-{\n--\nnet/ncsi/ncsi-cmd.c-55-\t/* Fill with calculated checksum */\nnet/ncsi/ncsi-cmd.c:56:\tchecksum = ncsi_calculate_checksum((unsigned char *)h,\nnet/ncsi/ncsi-cmd.c-57-\t\t\t\t\t sizeof(*h) + nca-\u003epayload);\nnet/ncsi/ncsi-cmd.c:58:\tpchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) +\nnet/ncsi/ncsi-cmd.c-59-\t\t ALIGN(nca-\u003epayload, 4));\n--\nnet/ncsi/ncsi-cmd.c-62-\nnet/ncsi/ncsi-cmd.c:63:static int ncsi_cmd_handler_default(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:64:\t\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-65-{\nnet/ncsi/ncsi-cmd.c:66:\tstruct ncsi_cmd_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-67-\nnet/ncsi/ncsi-cmd.c-68-\tcmd = skb_put_zero(skb, sizeof(*cmd));\nnet/ncsi/ncsi-cmd.c:69:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-70-\n--\nnet/ncsi/ncsi-cmd.c-73-\nnet/ncsi/ncsi-cmd.c:74:static int ncsi_cmd_handler_sp(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:75:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-76-{\nnet/ncsi/ncsi-cmd.c:77:\tstruct ncsi_cmd_sp_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-78-\n--\nnet/ncsi/ncsi-cmd.c-80-\tcmd-\u003ehw_arbitration = nca-\u003ebytes[0];\nnet/ncsi/ncsi-cmd.c:81:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-82-\n--\nnet/ncsi/ncsi-cmd.c-85-\nnet/ncsi/ncsi-cmd.c:86:static int ncsi_cmd_handler_dc(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:87:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-88-{\nnet/ncsi/ncsi-cmd.c:89:\tstruct ncsi_cmd_dc_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-90-\n--\nnet/ncsi/ncsi-cmd.c-92-\tcmd-\u003eald = nca-\u003ebytes[0];\nnet/ncsi/ncsi-cmd.c:93:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-94-\n--\nnet/ncsi/ncsi-cmd.c-97-\nnet/ncsi/ncsi-cmd.c:98:static int ncsi_cmd_handler_rc(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:99:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-100-{\nnet/ncsi/ncsi-cmd.c:101:\tstruct ncsi_cmd_rc_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-102-\nnet/ncsi/ncsi-cmd.c-103-\tcmd = skb_put_zero(skb, sizeof(*cmd));\nnet/ncsi/ncsi-cmd.c:104:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-105-\n--\nnet/ncsi/ncsi-cmd.c-108-\nnet/ncsi/ncsi-cmd.c:109:static int ncsi_cmd_handler_ae(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:110:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-111-{\nnet/ncsi/ncsi-cmd.c:112:\tstruct ncsi_cmd_ae_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-113-\n--\nnet/ncsi/ncsi-cmd.c-116-\tcmd-\u003emode = htonl(nca-\u003edwords[1]);\nnet/ncsi/ncsi-cmd.c:117:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-118-\n--\nnet/ncsi/ncsi-cmd.c-121-\nnet/ncsi/ncsi-cmd.c:122:static int ncsi_cmd_handler_sl(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:123:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-124-{\nnet/ncsi/ncsi-cmd.c:125:\tstruct ncsi_cmd_sl_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-126-\n--\nnet/ncsi/ncsi-cmd.c-129-\tcmd-\u003eoem_mode = htonl(nca-\u003edwords[1]);\nnet/ncsi/ncsi-cmd.c:130:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-131-\n--\nnet/ncsi/ncsi-cmd.c-134-\nnet/ncsi/ncsi-cmd.c:135:static int ncsi_cmd_handler_svf(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:136:\t\t\t\tstruct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-137-{\nnet/ncsi/ncsi-cmd.c:138:\tstruct ncsi_cmd_svf_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-139-\n--\nnet/ncsi/ncsi-cmd.c-143-\tcmd-\u003eenable = nca-\u003ebytes[7];\nnet/ncsi/ncsi-cmd.c:144:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-145-\n--\nnet/ncsi/ncsi-cmd.c-148-\nnet/ncsi/ncsi-cmd.c:149:static int ncsi_cmd_handler_ev(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:150:\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-151-{\nnet/ncsi/ncsi-cmd.c:152:\tstruct ncsi_cmd_ev_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-153-\n--\nnet/ncsi/ncsi-cmd.c-155-\tcmd-\u003emode = nca-\u003ebytes[3];\nnet/ncsi/ncsi-cmd.c:156:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-157-\n--\nnet/ncsi/ncsi-cmd.c-160-\nnet/ncsi/ncsi-cmd.c:161:static int ncsi_cmd_handler_sma(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:162:\t\t\t\tstruct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-163-{\nnet/ncsi/ncsi-cmd.c:164:\tstruct ncsi_cmd_sma_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-165-\tint i;\n--\nnet/ncsi/ncsi-cmd.c-171-\tcmd-\u003eat_e = nca-\u003ebytes[7];\nnet/ncsi/ncsi-cmd.c:172:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-173-\n--\nnet/ncsi/ncsi-cmd.c-176-\nnet/ncsi/ncsi-cmd.c:177:static int ncsi_cmd_handler_ebf(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:178:\t\t\t\tstruct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-179-{\nnet/ncsi/ncsi-cmd.c:180:\tstruct ncsi_cmd_ebf_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-181-\n--\nnet/ncsi/ncsi-cmd.c-183-\tcmd-\u003emode = htonl(nca-\u003edwords[0]);\nnet/ncsi/ncsi-cmd.c:184:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-185-\n--\nnet/ncsi/ncsi-cmd.c-188-\nnet/ncsi/ncsi-cmd.c:189:static int ncsi_cmd_handler_egmf(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:190:\t\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-191-{\nnet/ncsi/ncsi-cmd.c:192:\tstruct ncsi_cmd_egmf_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-193-\n--\nnet/ncsi/ncsi-cmd.c-195-\tcmd-\u003emode = htonl(nca-\u003edwords[0]);\nnet/ncsi/ncsi-cmd.c:196:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-197-\n--\nnet/ncsi/ncsi-cmd.c-200-\nnet/ncsi/ncsi-cmd.c:201:static int ncsi_cmd_handler_snfc(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:202:\t\t\t\t struct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-203-{\nnet/ncsi/ncsi-cmd.c:204:\tstruct ncsi_cmd_snfc_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-205-\n--\nnet/ncsi/ncsi-cmd.c-207-\tcmd-\u003emode = nca-\u003ebytes[0];\nnet/ncsi/ncsi-cmd.c:208:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-209-\n--\nnet/ncsi/ncsi-cmd.c-212-\nnet/ncsi/ncsi-cmd.c:213:static int ncsi_cmd_handler_oem(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:214:\t\t\t\tstruct ncsi_cmd_arg *nca)\nnet/ncsi/ncsi-cmd.c-215-{\nnet/ncsi/ncsi-cmd.c:216:\tstruct ncsi_cmd_oem_pkt *cmd;\nnet/ncsi/ncsi-cmd.c-217-\tunsigned int len;\n--\nnet/ncsi/ncsi-cmd.c-226-\tpayload = ALIGN(nca-\u003epayload, 4);\nnet/ncsi/ncsi-cmd.c:227:\tlen = sizeof(struct ncsi_cmd_pkt_hdr) + 4;\nnet/ncsi/ncsi-cmd.c-228-\tlen += max(payload, padding_bytes);\n--\nnet/ncsi/ncsi-cmd.c-232-\t\t /* skb allocated with enough to load the payload */);\nnet/ncsi/ncsi-cmd.c:233:\tncsi_cmd_build_header(\u0026cmd-\u003ecmd.common, nca);\nnet/ncsi/ncsi-cmd.c-234-\n--\nnet/ncsi/ncsi-cmd.c-237-\nnet/ncsi/ncsi-cmd.c:238:static struct ncsi_cmd_handler {\nnet/ncsi/ncsi-cmd.c-239-\tunsigned char type;\n--\nnet/ncsi/ncsi-cmd.c-241-\tint (*handler)(struct sk_buff *skb,\nnet/ncsi/ncsi-cmd.c:242:\t\t\t\t struct ncsi_cmd_arg *nca);\nnet/ncsi/ncsi-cmd.c:243:} ncsi_cmd_handlers[] = {\nnet/ncsi/ncsi-cmd.c:244:\t{ NCSI_PKT_CMD_CIS, 0, ncsi_cmd_handler_default },\nnet/ncsi/ncsi-cmd.c:245:\t{ NCSI_PKT_CMD_SP, 4, ncsi_cmd_handler_sp },\nnet/ncsi/ncsi-cmd.c:246:\t{ NCSI_PKT_CMD_DP, 0, ncsi_cmd_handler_default },\nnet/ncsi/ncsi-cmd.c:247:\t{ NCSI_PKT_CMD_EC, 0, ncsi_cmd_handler_default },\nnet/ncsi/ncsi-cmd.c:248:\t{ NCSI_PKT_CMD_DC, 4, ncsi_cmd_handler_dc },\nnet/ncsi/ncsi-cmd.c:249:\t{ NCSI_PKT_CMD_RC, 4, ncsi_cmd_handler_rc },\n\n"
} |
| 15/2 | 2026/08/30 07:49 | llm | patch-evaluator |
1mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 38087 output: 32 thoughts: 138 Thoughts: **NCSI Packet Reception: A Quick Recap** Okay, so I'm trying to wrap my head around how NCSI packets are actually received and processed. Let's trace this back a bit, right? I'm thinking the key is likely in `ncsi-manage.c`. First thought: how does the system register an NCSI packet type? Ah, right, there's `ncsi_register_dev`. It's registering a `packet_type` with `ETH_P_NCSI` using `dev_add_pack(&ndp->ptype)`. Good. But wait... this triggers a question. Does NCSI processing *require* that `ncsi_register_dev()` has been called for a specific network device? That seems like a crucial point. To confirm this, I need to revisit the implementation details of `ncsi_register_dev`. And also `ncsi_find_dev`. I suspect the answer lies there. Let's quickly search for instances of `ETH_P_NCSI` and also `ncsi_dev_list`. That should paint the picture of what's happening. |
| 16/2 | 2026/08/30 07:51 | tool | grepper |
0mArgs:{
"Expression": "ncsi_find_dev",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/internal.h=404=void ncsi_free_request(struct ncsi_request *nr);\nnet/ncsi/internal.h:405:struct ncsi_dev *ncsi_find_dev(struct net_device *dev);\nnet/ncsi/internal.h-406-int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);\n--\nnet/ncsi/ncsi-manage.c=409=void ncsi_free_request(struct ncsi_request *nr)\n--\nnet/ncsi/ncsi-manage.c-438-\nnet/ncsi/ncsi-manage.c:439:struct ncsi_dev *ncsi_find_dev(struct net_device *dev)\nnet/ncsi/ncsi-manage.c-440-{\n--\nnet/ncsi/ncsi-manage.c=1693=int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)\n--\nnet/ncsi/ncsi-manage.c-1703-\nnet/ncsi/ncsi-manage.c:1704:\tnd = ncsi_find_dev(dev);\nnet/ncsi/ncsi-manage.c-1705-\tif (!nd) {\n--\nnet/ncsi/ncsi-manage.c=1744=int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)\n--\nnet/ncsi/ncsi-manage.c-1753-\nnet/ncsi/ncsi-manage.c:1754:\tnd = ncsi_find_dev(dev);\nnet/ncsi/ncsi-manage.c-1755-\tif (!nd) {\n--\nnet/ncsi/ncsi-manage.c=1782=struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\n--\nnet/ncsi/ncsi-manage.c-1792-\t/* Check if the device has been registered or not */\nnet/ncsi/ncsi-manage.c:1793:\tnd = ncsi_find_dev(dev);\nnet/ncsi/ncsi-manage.c-1794-\tif (nd)\n--\nnet/ncsi/ncsi-manage.c=1992=struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev)\n--\nnet/ncsi/ncsi-manage.c-1997-\trcu_read_lock();\nnet/ncsi/ncsi-manage.c:1998:\tnd = ncsi_find_dev(dev);\nnet/ncsi/ncsi-manage.c-1999-\tif (nd) {\n--\nnet/ncsi/ncsi-rsp.c=1165=int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ncsi/ncsi-rsp.c-1176-\t/* Find the NCSI device */\nnet/ncsi/ncsi-rsp.c:1177:\tnd = ncsi_find_dev(orig_dev);\nnet/ncsi/ncsi-rsp.c-1178-\tndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL;\n"
} |
| 17/2 | 2026/08/30 07:51 | llm | patch-evaluator |
2mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 39439 output: 42 thoughts: 88 Thoughts: Here's my thought process, as it stands: **Digging into NCSI Device Discovery** Okay, so I'm looking at how NCSI devices are handled. Specifically, I'm trying to understand the device discovery process. The function `ncsi_find_dev(dev)` is what immediately grabs my attention. My understanding is that this function searches the `ncsi_dev_list`. The logical next step for me is to understand how a device *gets* into that `ncsi_dev_list`. I need to track the entry point. This points me directly to `ncsi_register_dev()`. Given my expertise, I'll go straight to the code. I need to read the implementation of `ncsi_register_dev` to understand how devices are registered in the first place, and I'll find it in `net/ncsi/ncsi-manage.c`. That should give me the full picture. |
| 18/2 | 2026/08/30 07:54 | tool | read-file |
0mArgs:{
"File": "net/ncsi/ncsi-manage.c",
"FirstLine": 1780,
"LineCount": 80
}Results: {
"Contents": "1780:\tEXPORT_SYMBOL_GPL(ncsi_vlan_rx_kill_vid);\n1781:\t\n1782:\tstruct ncsi_dev *ncsi_register_dev(struct net_device *dev,\n1783:\t\t\t\t\t void (*handler)(struct ncsi_dev *ndev))\n1784:\t{\n1785:\t\tstruct ncsi_dev_priv *ndp;\n1786:\t\tstruct ncsi_dev *nd;\n1787:\t\tstruct platform_device *pdev;\n1788:\t\tstruct device_node *np;\n1789:\t\tunsigned long flags;\n1790:\t\tint i;\n1791:\t\n1792:\t\t/* Check if the device has been registered or not */\n1793:\t\tnd = ncsi_find_dev(dev);\n1794:\t\tif (nd)\n1795:\t\t\treturn nd;\n1796:\t\n1797:\t\t/* Create NCSI device */\n1798:\t\tndp = kzalloc_obj(*ndp, GFP_ATOMIC);\n1799:\t\tif (!ndp)\n1800:\t\t\treturn NULL;\n1801:\t\n1802:\t\tnd = \u0026ndp-\u003endev;\n1803:\t\tnd-\u003estate = ncsi_dev_state_registered;\n1804:\t\tnd-\u003edev = dev;\n1805:\t\tnd-\u003ehandler = handler;\n1806:\t\tndp-\u003epending_req_num = 0;\n1807:\t\tINIT_LIST_HEAD(\u0026ndp-\u003echannel_queue);\n1808:\t\tINIT_LIST_HEAD(\u0026ndp-\u003evlan_vids);\n1809:\t\tINIT_WORK(\u0026ndp-\u003ework, ncsi_dev_work);\n1810:\t\tndp-\u003epackage_whitelist = UINT_MAX;\n1811:\t\n1812:\t\t/* Initialize private NCSI device */\n1813:\t\tkref_init(\u0026ndp-\u003eref);\n1814:\t\tspin_lock_init(\u0026ndp-\u003elock);\n1815:\t\tINIT_LIST_HEAD(\u0026ndp-\u003epackages);\n1816:\t\tndp-\u003erequest_id = NCSI_REQ_START_IDX;\n1817:\t\tfor (i = 0; i \u003c ARRAY_SIZE(ndp-\u003erequests); i++) {\n1818:\t\t\tndp-\u003erequests[i].id = i;\n1819:\t\t\tndp-\u003erequests[i].ndp = ndp;\n1820:\t\t\ttimer_setup(\u0026ndp-\u003erequests[i].timer, ncsi_request_timeout, 0);\n1821:\t\t}\n1822:\t\tndp-\u003echannel_count = NCSI_RESERVED_CHANNEL;\n1823:\t\n1824:\t\tspin_lock_irqsave(\u0026ncsi_dev_lock, flags);\n1825:\t\tlist_add_tail_rcu(\u0026ndp-\u003enode, \u0026ncsi_dev_list);\n1826:\t\tspin_unlock_irqrestore(\u0026ncsi_dev_lock, flags);\n1827:\t\n1828:\t\t/* Register NCSI packet Rx handler */\n1829:\t\tndp-\u003eptype.type = cpu_to_be16(ETH_P_NCSI);\n1830:\t\tndp-\u003eptype.func = ncsi_rcv_rsp;\n1831:\t\tndp-\u003eptype.dev = dev;\n1832:\t\tdev_add_pack(\u0026ndp-\u003eptype);\n1833:\t\n1834:\t\tpdev = to_platform_device(dev-\u003edev.parent);\n1835:\t\tif (pdev) {\n1836:\t\t\tnp = pdev-\u003edev.of_node;\n1837:\t\t\tif (np \u0026\u0026 (of_property_read_bool(np, \"mellanox,multi-host\") ||\n1838:\t\t\t\t of_property_read_bool(np, \"mlx,multi-host\")))\n1839:\t\t\t\tndp-\u003emlx_multi_host = true;\n1840:\t\t}\n1841:\t\n1842:\t\treturn nd;\n1843:\t}\n1844:\tEXPORT_SYMBOL_GPL(ncsi_register_dev);\n1845:\t\n1846:\tint ncsi_start_dev(struct ncsi_dev *nd)\n1847:\t{\n1848:\t\tstruct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);\n1849:\t\n1850:\t\tif (nd-\u003estate != ncsi_dev_state_registered \u0026\u0026\n1851:\t\t nd-\u003estate != ncsi_dev_state_functional)\n1852:\t\t\treturn -ENOTTY;\n1853:\t\n1854:\t\tif (!(ndp-\u003eflags \u0026 NCSI_DEV_PROBED)) {\n1855:\t\t\tndp-\u003epackage_probe_id = 0;\n1856:\t\t\tndp-\u003echannel_probe_id = 0;\n1857:\t\t\tnd-\u003estate = ncsi_dev_state_probe;\n1858:\t\t\tschedule_work(\u0026ndp-\u003ework);\n1859:\t\t\treturn 0;\n"
} |
| 19/2 | 2026/08/30 07:54 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 41135 output: 20 thoughts: 146 Thoughts: **Investigating the Caller of `ncsi_register_dev`** Okay, let's dive into this. My initial thought is to confirm the scope of `ncsi_register_dev`. Is `ftgmac100.c` the *only* place calling this function? I need to be sure. My plan is to thoroughly investigate and trace down all calls to `ncsi_register_dev`. I recall that a previous `grep` search gave me some promising leads. Let me refresh my memory of those results: `drivers/net/ethernet/faraday/ftgmac100.c`, `include/net/ncsi.h`, and `net/ncsi/ncsi-manage.c`. This suggests some related context, but doesn't explicitly confirm the call graph. Now, let's focus on `ftgmac100.c`. I need to understand its relationship to `ncsi_register_dev`. Where else is `ftgmac100.c` used, and how does that influence this connection? I'll need to analyze how and where ftgmac100 itself is referenced. Let's see if it's referenced in the Kconfig. |
| 20/2 | 2026/08/30 07:55 | tool | grepper |
0mArgs:{
"Expression": "FTGMAC100"
}Results: {
"Output": "\nFull output is too long, showing 500 out of 779 lines.\nUse more precise expression if possible.\n\nDocumentation/devicetree/bindings/net/faraday,ftgmac100.yaml=5=$schema: http://devicetree.org/meta-schemas/core.yaml#\nDocumentation/devicetree/bindings/net/faraday,ftgmac100.yaml-6-\nDocumentation/devicetree/bindings/net/faraday,ftgmac100.yaml:7:title: Faraday Technology FTGMAC100 gigabit ethernet controller\nDocumentation/devicetree/bindings/net/faraday,ftgmac100.yaml-8-\n--\narch/arm/configs/aspeed_g4_defconfig=71=CONFIG_NETCONSOLE=y\n--\narch/arm/configs/aspeed_g4_defconfig-81-# CONFIG_NET_VENDOR_EZCHIP is not set\narch/arm/configs/aspeed_g4_defconfig:82:CONFIG_FTGMAC100=y\narch/arm/configs/aspeed_g4_defconfig-83-# CONFIG_NET_VENDOR_HISILICON is not set\n--\narch/arm/configs/aspeed_g5_defconfig=89=CONFIG_NETCONSOLE=y\n--\narch/arm/configs/aspeed_g5_defconfig-99-# CONFIG_NET_VENDOR_EZCHIP is not set\narch/arm/configs/aspeed_g5_defconfig:100:CONFIG_FTGMAC100=y\narch/arm/configs/aspeed_g5_defconfig-101-# CONFIG_NET_VENDOR_HISILICON is not set\n--\narch/arm/configs/multi_v5_defconfig=90=CONFIG_DM9000=y\narch/arm/configs/multi_v5_defconfig:91:CONFIG_FTGMAC100=m\narch/arm/configs/multi_v5_defconfig-92-CONFIG_MV643XX_ETH=y\n--\narch/arm/configs/multi_v7_defconfig=261=CONFIG_NET_CALXEDA_XGMAC=y\narch/arm/configs/multi_v7_defconfig:262:CONFIG_FTGMAC100=m\narch/arm/configs/multi_v7_defconfig-263-CONFIG_GIANFAR=y\n--\ndrivers/net/ethernet/faraday/Kconfig=20=config FTMAC100\n--\ndrivers/net/ethernet/faraday/Kconfig-28-\ndrivers/net/ethernet/faraday/Kconfig:29:config FTGMAC100\ndrivers/net/ethernet/faraday/Kconfig:30:\ttristate \"Faraday FTGMAC100 Gigabit Ethernet support\"\ndrivers/net/ethernet/faraday/Kconfig-31-\tdepends on ARM || COMPILE_TEST\n--\ndrivers/net/ethernet/faraday/Kconfig-37-\thelp\ndrivers/net/ethernet/faraday/Kconfig:38:\t This driver supports the FTGMAC100 Gigabit Ethernet controller\ndrivers/net/ethernet/faraday/Kconfig-39-\t from Faraday. It is used on Faraday A369 and some other ARM SoC's.\n--\ndrivers/net/ethernet/faraday/Makefile-5-\ndrivers/net/ethernet/faraday/Makefile:6:obj-$(CONFIG_FTGMAC100) += ftgmac100.o\ndrivers/net/ethernet/faraday/Makefile-7-obj-$(CONFIG_FTMAC100) += ftmac100.o\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2-/*\ndrivers/net/ethernet/faraday/ftgmac100.c:3: * Faraday FTGMAC100 Gigabit Ethernet\ndrivers/net/ethernet/faraday/ftgmac100.c-4- *\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=36=enum ftgmac100_mac_id {\ndrivers/net/ethernet/faraday/ftgmac100.c:37:\tFTGMAC100_FARADAY = 1,\ndrivers/net/ethernet/faraday/ftgmac100.c:38:\tFTGMAC100_AST2400,\ndrivers/net/ethernet/faraday/ftgmac100.c:39:\tFTGMAC100_AST2500,\ndrivers/net/ethernet/faraday/ftgmac100.c:40:\tFTGMAC100_AST2600\ndrivers/net/ethernet/faraday/ftgmac100.c-41-};\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=140=static int ftgmac100_reset_mac(struct ftgmac100 *priv, u32 maccr)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-145-\t/* NOTE: reset clears all registers */\ndrivers/net/ethernet/faraday/ftgmac100.c:146:\tiowrite32(maccr, priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c:147:\tiowrite32(maccr | FTGMAC100_MACCR_SW_RST,\ndrivers/net/ethernet/faraday/ftgmac100.c:148:\t\t priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-149-\tfor (i = 0; i \u003c 200; i++) {\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-151-\ndrivers/net/ethernet/faraday/ftgmac100.c:152:\t\tmaccr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c:153:\t\tif (!(maccr \u0026 FTGMAC100_MACCR_SW_RST))\ndrivers/net/ethernet/faraday/ftgmac100.c-154-\t\t\treturn 0;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=163=static int ftgmac100_reset_and_config_mac(struct ftgmac100 *priv)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-189-\tcase SPEED_100:\ndrivers/net/ethernet/faraday/ftgmac100.c:190:\t\tmaccr |= FTGMAC100_MACCR_FAST_MODE;\ndrivers/net/ethernet/faraday/ftgmac100.c-191-\t\tbreak;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-193-\tcase SPEED_1000:\ndrivers/net/ethernet/faraday/ftgmac100.c:194:\t\tmaccr |= FTGMAC100_MACCR_GIGA_MODE;\ndrivers/net/ethernet/faraday/ftgmac100.c-195-\t\tbreak;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=214=static void ftgmac100_write_mac_addr(struct ftgmac100 *priv, const u8 *mac)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-218-\ndrivers/net/ethernet/faraday/ftgmac100.c:219:\tiowrite32(maddr, priv-\u003ebase + FTGMAC100_OFFSET_MAC_MADR);\ndrivers/net/ethernet/faraday/ftgmac100.c:220:\tiowrite32(laddr, priv-\u003ebase + FTGMAC100_OFFSET_MAC_LADR);\ndrivers/net/ethernet/faraday/ftgmac100.c-221-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=223=static int ftgmac100_initial_mac(struct ftgmac100 *priv)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-238-\ndrivers/net/ethernet/faraday/ftgmac100.c:239:\tm = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_MAC_MADR);\ndrivers/net/ethernet/faraday/ftgmac100.c:240:\tl = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_MAC_LADR);\ndrivers/net/ethernet/faraday/ftgmac100.c-241-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=275=static void ftgmac100_config_pause(struct ftgmac100 *priv)\ndrivers/net/ethernet/faraday/ftgmac100.c-276-{\ndrivers/net/ethernet/faraday/ftgmac100.c:277:\tu32 fcr = FTGMAC100_FCR_PAUSE_TIME(16);\ndrivers/net/ethernet/faraday/ftgmac100.c-278-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-280-\tif (priv-\u003erx_pause)\ndrivers/net/ethernet/faraday/ftgmac100.c:281:\t\tfcr |= FTGMAC100_FCR_FC_EN;\ndrivers/net/ethernet/faraday/ftgmac100.c-282-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-286-\tif (priv-\u003etx_pause)\ndrivers/net/ethernet/faraday/ftgmac100.c:287:\t\tfcr |= FTGMAC100_FCR_FCTHR_EN;\ndrivers/net/ethernet/faraday/ftgmac100.c-288-\ndrivers/net/ethernet/faraday/ftgmac100.c:289:\tiowrite32(fcr, priv-\u003ebase + FTGMAC100_OFFSET_FCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-290-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=292=static void ftgmac100_init_hw(struct ftgmac100 *priv)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-296-\t/* Clear stale interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:297:\treg = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c:298:\tiowrite32(reg, priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c-299-\ndrivers/net/ethernet/faraday/ftgmac100.c-300-\t/* Setup RX ring buffer base */\ndrivers/net/ethernet/faraday/ftgmac100.c:301:\tiowrite32(priv-\u003erxdes_dma, priv-\u003ebase + FTGMAC100_OFFSET_RXR_BADR);\ndrivers/net/ethernet/faraday/ftgmac100.c-302-\ndrivers/net/ethernet/faraday/ftgmac100.c-303-\t/* Setup TX ring buffer base */\ndrivers/net/ethernet/faraday/ftgmac100.c:304:\tiowrite32(priv-\u003etxdes_dma, priv-\u003ebase + FTGMAC100_OFFSET_NPTXR_BADR);\ndrivers/net/ethernet/faraday/ftgmac100.c-305-\ndrivers/net/ethernet/faraday/ftgmac100.c-306-\t/* Configure RX buffer size */\ndrivers/net/ethernet/faraday/ftgmac100.c:307:\tiowrite32(FTGMAC100_RBSR_SIZE(RX_BUF_SIZE),\ndrivers/net/ethernet/faraday/ftgmac100.c:308:\t\t priv-\u003ebase + FTGMAC100_OFFSET_RBSR);\ndrivers/net/ethernet/faraday/ftgmac100.c-309-\ndrivers/net/ethernet/faraday/ftgmac100.c-310-\t/* Set RX descriptor autopoll */\ndrivers/net/ethernet/faraday/ftgmac100.c:311:\tiowrite32(FTGMAC100_APTC_RXPOLL_CNT(1),\ndrivers/net/ethernet/faraday/ftgmac100.c:312:\t\t priv-\u003ebase + FTGMAC100_OFFSET_APTC);\ndrivers/net/ethernet/faraday/ftgmac100.c-313-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-317-\t/* Write multicast filter */\ndrivers/net/ethernet/faraday/ftgmac100.c:318:\tiowrite32(priv-\u003emaht0, priv-\u003ebase + FTGMAC100_OFFSET_MAHT0);\ndrivers/net/ethernet/faraday/ftgmac100.c:319:\tiowrite32(priv-\u003emaht1, priv-\u003ebase + FTGMAC100_OFFSET_MAHT1);\ndrivers/net/ethernet/faraday/ftgmac100.c-320-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-325-\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:326:\tiowrite32(FTGMAC100_DBLAC_RXDES_SIZE(2) | /* 2*8 bytes RX descs */\ndrivers/net/ethernet/faraday/ftgmac100.c:327:\t\t FTGMAC100_DBLAC_TXDES_SIZE(2) | /* 2*8 bytes TX descs */\ndrivers/net/ethernet/faraday/ftgmac100.c:328:\t\t FTGMAC100_DBLAC_RXBURST_SIZE(3) | /* 512 bytes max RX bursts */\ndrivers/net/ethernet/faraday/ftgmac100.c:329:\t\t FTGMAC100_DBLAC_TXBURST_SIZE(3) | /* 512 bytes max TX bursts */\ndrivers/net/ethernet/faraday/ftgmac100.c:330:\t\t FTGMAC100_DBLAC_RX_THR_EN | /* Enable fifo threshold arb */\ndrivers/net/ethernet/faraday/ftgmac100.c:331:\t\t FTGMAC100_DBLAC_RXFIFO_HTHR(6) | /* 6/8 of FIFO high threshold */\ndrivers/net/ethernet/faraday/ftgmac100.c:332:\t\t FTGMAC100_DBLAC_RXFIFO_LTHR(2), /* 2/8 of FIFO low threshold */\ndrivers/net/ethernet/faraday/ftgmac100.c:333:\t\t priv-\u003ebase + FTGMAC100_OFFSET_DBLAC);\ndrivers/net/ethernet/faraday/ftgmac100.c-334-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-338-\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:339:\tiowrite32(FTGMAC100_ITC_RXINT_THR(1) |\ndrivers/net/ethernet/faraday/ftgmac100.c:340:\t\t FTGMAC100_ITC_TXINT_THR(1),\ndrivers/net/ethernet/faraday/ftgmac100.c:341:\t\t priv-\u003ebase + FTGMAC100_OFFSET_ITC);\ndrivers/net/ethernet/faraday/ftgmac100.c-342-\ndrivers/net/ethernet/faraday/ftgmac100.c-343-\t/* Configure FIFO sizes in the TPAFCR register */\ndrivers/net/ethernet/faraday/ftgmac100.c:344:\treg = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_FEAR);\ndrivers/net/ethernet/faraday/ftgmac100.c-345-\trfifo_sz = reg \u0026 0x00000007;\ndrivers/net/ethernet/faraday/ftgmac100.c-346-\ttfifo_sz = (reg \u003e\u003e 3) \u0026 0x00000007;\ndrivers/net/ethernet/faraday/ftgmac100.c:347:\treg = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_TPAFCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-348-\treg \u0026= ~0x3f000000;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-350-\treg |= (rfifo_sz \u003c\u003c 24);\ndrivers/net/ethernet/faraday/ftgmac100.c:351:\tiowrite32(reg, priv-\u003ebase + FTGMAC100_OFFSET_TPAFCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-352-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=354=static void ftgmac100_start_hw(struct ftgmac100 *priv)\ndrivers/net/ethernet/faraday/ftgmac100.c-355-{\ndrivers/net/ethernet/faraday/ftgmac100.c:356:\tu32 maccr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-357-\ndrivers/net/ethernet/faraday/ftgmac100.c-358-\t/* Keep the original GMAC and FAST bits */\ndrivers/net/ethernet/faraday/ftgmac100.c:359:\tmaccr \u0026= (FTGMAC100_MACCR_FAST_MODE | FTGMAC100_MACCR_GIGA_MODE);\ndrivers/net/ethernet/faraday/ftgmac100.c-360-\ndrivers/net/ethernet/faraday/ftgmac100.c-361-\t/* Add all the main enable bits */\ndrivers/net/ethernet/faraday/ftgmac100.c:362:\tmaccr |= FTGMAC100_MACCR_TXDMA_EN\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:363:\t\t FTGMAC100_MACCR_RXDMA_EN\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:364:\t\t FTGMAC100_MACCR_TXMAC_EN\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:365:\t\t FTGMAC100_MACCR_RXMAC_EN\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:366:\t\t FTGMAC100_MACCR_CRC_APD\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:367:\t\t FTGMAC100_MACCR_PHY_LINK_LEVEL\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:368:\t\t FTGMAC100_MACCR_RX_RUNT\t|\ndrivers/net/ethernet/faraday/ftgmac100.c:369:\t\t FTGMAC100_MACCR_RX_BROADPKT;\ndrivers/net/ethernet/faraday/ftgmac100.c-370-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-372-\tif (priv-\u003ecur_duplex == DUPLEX_FULL)\ndrivers/net/ethernet/faraday/ftgmac100.c:373:\t\tmaccr |= FTGMAC100_MACCR_FULLDUP;\ndrivers/net/ethernet/faraday/ftgmac100.c-374-\tif (priv-\u003enetdev-\u003eflags \u0026 IFF_PROMISC)\ndrivers/net/ethernet/faraday/ftgmac100.c:375:\t\tmaccr |= FTGMAC100_MACCR_RX_ALL;\ndrivers/net/ethernet/faraday/ftgmac100.c-376-\tif (priv-\u003enetdev-\u003eflags \u0026 IFF_ALLMULTI)\ndrivers/net/ethernet/faraday/ftgmac100.c:377:\t\tmaccr |= FTGMAC100_MACCR_RX_MULTIPKT;\ndrivers/net/ethernet/faraday/ftgmac100.c-378-\telse if (netdev_mc_count(priv-\u003enetdev))\ndrivers/net/ethernet/faraday/ftgmac100.c:379:\t\tmaccr |= FTGMAC100_MACCR_HT_MULTI_EN;\ndrivers/net/ethernet/faraday/ftgmac100.c-380-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-382-\tif (priv-\u003enetdev-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_RX)\ndrivers/net/ethernet/faraday/ftgmac100.c:383:\t\tmaccr |= FTGMAC100_MACCR_RM_VLAN;\ndrivers/net/ethernet/faraday/ftgmac100.c-384-\ndrivers/net/ethernet/faraday/ftgmac100.c-385-\t/* Hit the HW */\ndrivers/net/ethernet/faraday/ftgmac100.c:386:\tiowrite32(maccr, priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-387-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=389=static void ftgmac100_stop_hw(struct ftgmac100 *priv)\ndrivers/net/ethernet/faraday/ftgmac100.c-390-{\ndrivers/net/ethernet/faraday/ftgmac100.c:391:\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-392-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=411=static void ftgmac100_set_rx_mode(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-422-\t/* Update the HW */\ndrivers/net/ethernet/faraday/ftgmac100.c:423:\tiowrite32(priv-\u003emaht0, priv-\u003ebase + FTGMAC100_OFFSET_MAHT0);\ndrivers/net/ethernet/faraday/ftgmac100.c:424:\tiowrite32(priv-\u003emaht1, priv-\u003ebase + FTGMAC100_OFFSET_MAHT1);\ndrivers/net/ethernet/faraday/ftgmac100.c-425-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=481=static void ftgmac100_rx_packet_error(struct ftgmac100 *priv, u32 status)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-484-\ndrivers/net/ethernet/faraday/ftgmac100.c:485:\tif (status \u0026 FTGMAC100_RXDES0_RX_ERR)\ndrivers/net/ethernet/faraday/ftgmac100.c-486-\t\tnetdev-\u003estats.rx_errors++;\ndrivers/net/ethernet/faraday/ftgmac100.c-487-\ndrivers/net/ethernet/faraday/ftgmac100.c:488:\tif (status \u0026 FTGMAC100_RXDES0_CRC_ERR)\ndrivers/net/ethernet/faraday/ftgmac100.c-489-\t\tnetdev-\u003estats.rx_crc_errors++;\ndrivers/net/ethernet/faraday/ftgmac100.c-490-\ndrivers/net/ethernet/faraday/ftgmac100.c:491:\tif (status \u0026 (FTGMAC100_RXDES0_FTL |\ndrivers/net/ethernet/faraday/ftgmac100.c:492:\t\t FTGMAC100_RXDES0_RUNT |\ndrivers/net/ethernet/faraday/ftgmac100.c:493:\t\t FTGMAC100_RXDES0_RX_ODD_NB))\ndrivers/net/ethernet/faraday/ftgmac100.c-494-\t\tnetdev-\u003estats.rx_length_errors++;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=497=static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-513-\t/* Do we have a packet ? */\ndrivers/net/ethernet/faraday/ftgmac100.c:514:\tif (!(status \u0026 FTGMAC100_RXDES0_RXPKT_RDY))\ndrivers/net/ethernet/faraday/ftgmac100.c-515-\t\treturn false;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-520-\t/* We don't cope with fragmented RX packets */\ndrivers/net/ethernet/faraday/ftgmac100.c:521:\tif (unlikely(!(status \u0026 FTGMAC100_RXDES0_FRS) ||\ndrivers/net/ethernet/faraday/ftgmac100.c:522:\t\t !(status \u0026 FTGMAC100_RXDES0_LRS)))\ndrivers/net/ethernet/faraday/ftgmac100.c-523-\t\tgoto drop;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-525-\t/* Grab received size and csum vlan field in the descriptor */\ndrivers/net/ethernet/faraday/ftgmac100.c:526:\tsize = status \u0026 FTGMAC100_RXDES0_VDBC;\ndrivers/net/ethernet/faraday/ftgmac100.c-527-\tcsum_vlan = le32_to_cpu(rxdes-\u003erxdes1);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-535-\t\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:536:\t\tif ((status \u0026 FTGMAC100_RXDES0_RUNT) \u0026\u0026\ndrivers/net/ethernet/faraday/ftgmac100.c:537:\t\t (csum_vlan \u0026 FTGMAC100_RXDES1_VLANTAG_AVAIL) \u0026\u0026\ndrivers/net/ethernet/faraday/ftgmac100.c-538-\t\t (size \u003e= 60))\ndrivers/net/ethernet/faraday/ftgmac100.c:539:\t\t\tstatus \u0026= ~FTGMAC100_RXDES0_RUNT;\ndrivers/net/ethernet/faraday/ftgmac100.c-540-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-556-\ndrivers/net/ethernet/faraday/ftgmac100.c:557:\tif (unlikely(status \u0026 FTGMAC100_RXDES0_MULTICAST))\ndrivers/net/ethernet/faraday/ftgmac100.c-558-\t\tnetdev-\u003estats.multicast++;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-566-\tif (netdev-\u003efeatures \u0026 NETIF_F_RXCSUM) {\ndrivers/net/ethernet/faraday/ftgmac100.c:567:\t\tu32 err_bits = FTGMAC100_RXDES1_TCP_CHKSUM_ERR |\ndrivers/net/ethernet/faraday/ftgmac100.c:568:\t\t\tFTGMAC100_RXDES1_UDP_CHKSUM_ERR |\ndrivers/net/ethernet/faraday/ftgmac100.c:569:\t\t\tFTGMAC100_RXDES1_IP_CHKSUM_ERR;\ndrivers/net/ethernet/faraday/ftgmac100.c-570-\t\tif ((csum_vlan \u0026 err_bits) ||\ndrivers/net/ethernet/faraday/ftgmac100.c:571:\t\t !(csum_vlan \u0026 FTGMAC100_RXDES1_PROT_MASK))\ndrivers/net/ethernet/faraday/ftgmac100.c-572-\t\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-581-\tif ((netdev-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_RX) \u0026\u0026\ndrivers/net/ethernet/faraday/ftgmac100.c:582:\t (csum_vlan \u0026 FTGMAC100_RXDES1_VLANTAG_AVAIL))\ndrivers/net/ethernet/faraday/ftgmac100.c-583-\t\t__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=658=static void ftgmac100_free_tx_packet(struct ftgmac100 *priv,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-666-\ndrivers/net/ethernet/faraday/ftgmac100.c:667:\tif (ctl_stat \u0026 FTGMAC100_TXDES0_FTS) {\ndrivers/net/ethernet/faraday/ftgmac100.c-668-\t\tlen = skb_headlen(skb);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-670-\t} else {\ndrivers/net/ethernet/faraday/ftgmac100.c:671:\t\tlen = FTGMAC100_TXDES0_TXBUF_SIZE(ctl_stat);\ndrivers/net/ethernet/faraday/ftgmac100.c-672-\t\tdma_unmap_page(priv-\u003edev, map, len, DMA_TO_DEVICE);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-675-\t/* Free SKB on last segment */\ndrivers/net/ethernet/faraday/ftgmac100.c:676:\tif (ctl_stat \u0026 FTGMAC100_TXDES0_LTS)\ndrivers/net/ethernet/faraday/ftgmac100.c-677-\t\tdev_kfree_skb(skb);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=681=static bool ftgmac100_tx_complete_packet(struct ftgmac100 *priv)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-692-\tctl_stat = le32_to_cpu(txdes-\u003etxdes0);\ndrivers/net/ethernet/faraday/ftgmac100.c:693:\tif (ctl_stat \u0026 FTGMAC100_TXDES0_TXDMA_OWN)\ndrivers/net/ethernet/faraday/ftgmac100.c-694-\t\treturn false;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=736=static bool ftgmac100_prep_tx_csum(struct sk_buff *skb, u32 *csum_vlan)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-740-\ndrivers/net/ethernet/faraday/ftgmac100.c:741:\t\t*csum_vlan |= FTGMAC100_TXDES1_IP_CHKSUM;\ndrivers/net/ethernet/faraday/ftgmac100.c-742-\t\tswitch(ip_proto) {\ndrivers/net/ethernet/faraday/ftgmac100.c-743-\t\tcase IPPROTO_TCP:\ndrivers/net/ethernet/faraday/ftgmac100.c:744:\t\t\t*csum_vlan |= FTGMAC100_TXDES1_TCP_CHKSUM;\ndrivers/net/ethernet/faraday/ftgmac100.c-745-\t\t\treturn true;\ndrivers/net/ethernet/faraday/ftgmac100.c-746-\t\tcase IPPROTO_UDP:\ndrivers/net/ethernet/faraday/ftgmac100.c:747:\t\t\t*csum_vlan |= FTGMAC100_TXDES1_UDP_CHKSUM;\ndrivers/net/ethernet/faraday/ftgmac100.c-748-\t\t\treturn true;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=756=static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-790-\tif (skb_vlan_tag_present(skb)) {\ndrivers/net/ethernet/faraday/ftgmac100.c:791:\t\tcsum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;\ndrivers/net/ethernet/faraday/ftgmac100.c-792-\t\tcsum_vlan |= skb_vlan_tag_get(skb) \u0026 0xffff;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-814-\tf_ctl_stat = ftgmac100_base_tx_ctlstat(priv, pointer);\ndrivers/net/ethernet/faraday/ftgmac100.c:815:\tf_ctl_stat |= FTGMAC100_TXDES0_TXDMA_OWN;\ndrivers/net/ethernet/faraday/ftgmac100.c:816:\tf_ctl_stat |= FTGMAC100_TXDES0_TXBUF_SIZE(len);\ndrivers/net/ethernet/faraday/ftgmac100.c:817:\tf_ctl_stat |= FTGMAC100_TXDES0_FTS;\ndrivers/net/ethernet/faraday/ftgmac100.c-818-\tif (nfrags == 0)\ndrivers/net/ethernet/faraday/ftgmac100.c:819:\t\tf_ctl_stat |= FTGMAC100_TXDES0_LTS;\ndrivers/net/ethernet/faraday/ftgmac100.c-820-\ttxdes-\u003etxdes3 = cpu_to_le32(map);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-841-\t\tctl_stat = ftgmac100_base_tx_ctlstat(priv, pointer);\ndrivers/net/ethernet/faraday/ftgmac100.c:842:\t\tctl_stat |= FTGMAC100_TXDES0_TXDMA_OWN;\ndrivers/net/ethernet/faraday/ftgmac100.c:843:\t\tctl_stat |= FTGMAC100_TXDES0_TXBUF_SIZE(len);\ndrivers/net/ethernet/faraday/ftgmac100.c-844-\t\tif (i == (nfrags - 1))\ndrivers/net/ethernet/faraday/ftgmac100.c:845:\t\t\tctl_stat |= FTGMAC100_TXDES0_LTS;\ndrivers/net/ethernet/faraday/ftgmac100.c-846-\t\ttxdes-\u003etxdes0 = cpu_to_le32(ctl_stat);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-880-\t/* Poke transmitter to read the updated TX descriptors */\ndrivers/net/ethernet/faraday/ftgmac100.c:881:\tiowrite32(1, priv-\u003ebase + FTGMAC100_OFFSET_NPTXPD);\ndrivers/net/ethernet/faraday/ftgmac100.c-882-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1071=static int ftgmac100_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1077-\ndrivers/net/ethernet/faraday/ftgmac100.c:1078:\tphycr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1079-\ndrivers/net/ethernet/faraday/ftgmac100.c-1080-\t/* preserve MDC cycle threshold */\ndrivers/net/ethernet/faraday/ftgmac100.c:1081:\tphycr \u0026= FTGMAC100_PHYCR_MDC_CYCTHR_MASK;\ndrivers/net/ethernet/faraday/ftgmac100.c-1082-\ndrivers/net/ethernet/faraday/ftgmac100.c:1083:\tphycr |= FTGMAC100_PHYCR_PHYAD(phy_addr) |\ndrivers/net/ethernet/faraday/ftgmac100.c:1084:\t\t FTGMAC100_PHYCR_REGAD(regnum) |\ndrivers/net/ethernet/faraday/ftgmac100.c:1085:\t\t FTGMAC100_PHYCR_MIIRD;\ndrivers/net/ethernet/faraday/ftgmac100.c-1086-\ndrivers/net/ethernet/faraday/ftgmac100.c:1087:\tiowrite32(phycr, priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1088-\ndrivers/net/ethernet/faraday/ftgmac100.c-1089-\tfor (i = 0; i \u003c 10; i++) {\ndrivers/net/ethernet/faraday/ftgmac100.c:1090:\t\tphycr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1091-\ndrivers/net/ethernet/faraday/ftgmac100.c:1092:\t\tif ((phycr \u0026 FTGMAC100_PHYCR_MIIRD) == 0) {\ndrivers/net/ethernet/faraday/ftgmac100.c-1093-\t\t\tint data;\ndrivers/net/ethernet/faraday/ftgmac100.c-1094-\ndrivers/net/ethernet/faraday/ftgmac100.c:1095:\t\t\tdata = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_PHYDATA);\ndrivers/net/ethernet/faraday/ftgmac100.c:1096:\t\t\treturn FTGMAC100_PHYDATA_MIIRDATA(data);\ndrivers/net/ethernet/faraday/ftgmac100.c-1097-\t\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1106=static int ftgmac100_mdiobus_write(struct mii_bus *bus, int phy_addr,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1114-\ndrivers/net/ethernet/faraday/ftgmac100.c:1115:\tphycr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1116-\ndrivers/net/ethernet/faraday/ftgmac100.c-1117-\t/* preserve MDC cycle threshold */\ndrivers/net/ethernet/faraday/ftgmac100.c:1118:\tphycr \u0026= FTGMAC100_PHYCR_MDC_CYCTHR_MASK;\ndrivers/net/ethernet/faraday/ftgmac100.c-1119-\ndrivers/net/ethernet/faraday/ftgmac100.c:1120:\tphycr |= FTGMAC100_PHYCR_PHYAD(phy_addr) |\ndrivers/net/ethernet/faraday/ftgmac100.c:1121:\t\t FTGMAC100_PHYCR_REGAD(regnum) |\ndrivers/net/ethernet/faraday/ftgmac100.c:1122:\t\t FTGMAC100_PHYCR_MIIWR;\ndrivers/net/ethernet/faraday/ftgmac100.c-1123-\ndrivers/net/ethernet/faraday/ftgmac100.c:1124:\tdata = FTGMAC100_PHYDATA_MIIWDATA(value);\ndrivers/net/ethernet/faraday/ftgmac100.c-1125-\ndrivers/net/ethernet/faraday/ftgmac100.c:1126:\tiowrite32(data, priv-\u003ebase + FTGMAC100_OFFSET_PHYDATA);\ndrivers/net/ethernet/faraday/ftgmac100.c:1127:\tiowrite32(phycr, priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1128-\ndrivers/net/ethernet/faraday/ftgmac100.c-1129-\tfor (i = 0; i \u003c 10; i++) {\ndrivers/net/ethernet/faraday/ftgmac100.c:1130:\t\tphycr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_PHYCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1131-\ndrivers/net/ethernet/faraday/ftgmac100.c:1132:\t\tif ((phycr \u0026 FTGMAC100_PHYCR_MIIWR) == 0)\ndrivers/net/ethernet/faraday/ftgmac100.c-1133-\t\t\treturn 0;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1231=static irqreturn_t ftgmac100_interrupt(int irq, void *dev_id)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1234-\tstruct ftgmac100 *priv = netdev_priv(netdev);\ndrivers/net/ethernet/faraday/ftgmac100.c:1235:\tunsigned int status, new_mask = FTGMAC100_INT_BAD;\ndrivers/net/ethernet/faraday/ftgmac100.c-1236-\ndrivers/net/ethernet/faraday/ftgmac100.c-1237-\t/* Fetch and clear interrupt bits, process abnormal ones */\ndrivers/net/ethernet/faraday/ftgmac100.c:1238:\tstatus = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c:1239:\tiowrite32(status, priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c:1240:\tif (unlikely(status \u0026 FTGMAC100_INT_BAD)) {\ndrivers/net/ethernet/faraday/ftgmac100.c-1241-\ndrivers/net/ethernet/faraday/ftgmac100.c-1242-\t\t/* RX buffer unavailable */\ndrivers/net/ethernet/faraday/ftgmac100.c:1243:\t\tif (status \u0026 FTGMAC100_INT_NO_RXBUF)\ndrivers/net/ethernet/faraday/ftgmac100.c-1244-\t\t\tnetdev-\u003estats.rx_over_errors++;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1246-\t\t/* received packet lost due to RX FIFO full */\ndrivers/net/ethernet/faraday/ftgmac100.c:1247:\t\tif (status \u0026 FTGMAC100_INT_RPKT_LOST)\ndrivers/net/ethernet/faraday/ftgmac100.c-1248-\t\t\tnetdev-\u003estats.rx_fifo_errors++;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1250-\t\t/* sent packet lost due to excessive TX collision */\ndrivers/net/ethernet/faraday/ftgmac100.c:1251:\t\tif (status \u0026 FTGMAC100_INT_XPKT_LOST)\ndrivers/net/ethernet/faraday/ftgmac100.c-1252-\t\t\tnetdev-\u003estats.tx_fifo_errors++;\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1254-\t\t/* AHB error -\u003e Reset the chip */\ndrivers/net/ethernet/faraday/ftgmac100.c:1255:\t\tif (status \u0026 FTGMAC100_INT_AHB_ERR) {\ndrivers/net/ethernet/faraday/ftgmac100.c-1256-\t\t\tif (net_ratelimit())\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1258-\t\t\t\t\t \"AHB bus error ! Resetting chip.\\n\");\ndrivers/net/ethernet/faraday/ftgmac100.c:1259:\t\t\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1260-\t\t\tschedule_work(\u0026priv-\u003ereset_task);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1273-\t/* Only enable \"bad\" interrupts while NAPI is on */\ndrivers/net/ethernet/faraday/ftgmac100.c:1274:\tiowrite32(new_mask, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1275-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1282=static bool ftgmac100_check_rx(struct ftgmac100 *priv)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1286-\t/* Do we have a packet ? */\ndrivers/net/ethernet/faraday/ftgmac100.c:1287:\treturn !!(rxdes-\u003erxdes0 \u0026 cpu_to_le32(FTGMAC100_RXDES0_RXPKT_RDY));\ndrivers/net/ethernet/faraday/ftgmac100.c-1288-}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1290=static int ftgmac100_poll(struct napi_struct *napi, int budget)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1313-\t\t/* Re-enable \"bad\" interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1314:\t\tiowrite32(FTGMAC100_INT_BAD,\ndrivers/net/ethernet/faraday/ftgmac100.c:1315:\t\t\t priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1316-\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1329-\t\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:1330:\t\tiowrite32(FTGMAC100_INT_RXTX,\ndrivers/net/ethernet/faraday/ftgmac100.c:1331:\t\t\t priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1332-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1335-\t\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:1336:\t\tioread32(priv-\u003ebase + FTGMAC100_OFFSET_ISR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1337-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1346-\t\t/* enable all interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1347:\t\tiowrite32(FTGMAC100_INT_ALL,\ndrivers/net/ethernet/faraday/ftgmac100.c:1348:\t\t\t priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1349-\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1354=static int ftgmac100_init_all(struct ftgmac100 *priv, bool ignore_alloc_err)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1375-\t/* Enable all interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1376:\tiowrite32(FTGMAC100_INT_ALL, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1377-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1436=static void ftgmac100_adjust_link(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1481-\t/* Disable all interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1482:\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1483-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1561=static int ftgmac100_open(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1634-err_hw:\ndrivers/net/ethernet/faraday/ftgmac100.c:1635:\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1636-\tftgmac100_free_rings(priv);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1640=static int ftgmac100_stop(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1652-\t/* disable all interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1653:\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1654-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1671=static void ftgmac100_tx_timeout(struct net_device *netdev, unsigned int txqueue)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1675-\t/* Disable all interrupts */\ndrivers/net/ethernet/faraday/ftgmac100.c:1676:\tiowrite32(0, priv-\u003ebase + FTGMAC100_OFFSET_IER);\ndrivers/net/ethernet/faraday/ftgmac100.c-1677-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1682=static int ftgmac100_set_features(struct net_device *netdev,\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1694-\ndrivers/net/ethernet/faraday/ftgmac100.c:1695:\t\tmaccr = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1696-\t\tif (priv-\u003enetdev-\u003efeatures \u0026 NETIF_F_HW_VLAN_CTAG_RX)\ndrivers/net/ethernet/faraday/ftgmac100.c:1697:\t\t\tmaccr |= FTGMAC100_MACCR_RM_VLAN;\ndrivers/net/ethernet/faraday/ftgmac100.c-1698-\t\telse\ndrivers/net/ethernet/faraday/ftgmac100.c:1699:\t\t\tmaccr \u0026= ~FTGMAC100_MACCR_RM_VLAN;\ndrivers/net/ethernet/faraday/ftgmac100.c:1700:\t\tiowrite32(maccr, priv-\u003ebase + FTGMAC100_OFFSET_MACCR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1701-\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1734=static int ftgmac100_setup_mdio(struct net_device *netdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1747-\ndrivers/net/ethernet/faraday/ftgmac100.c:1748:\tif (priv-\u003emac_id == FTGMAC100_AST2400 ||\ndrivers/net/ethernet/faraday/ftgmac100.c:1749:\t priv-\u003emac_id == FTGMAC100_AST2500) {\ndrivers/net/ethernet/faraday/ftgmac100.c-1750-\t\t/* The AST2600 has a separate MDIO controller */\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1754-\t\t */\ndrivers/net/ethernet/faraday/ftgmac100.c:1755:\t\treg = ioread32(priv-\u003ebase + FTGMAC100_OFFSET_REVR);\ndrivers/net/ethernet/faraday/ftgmac100.c:1756:\t\treg \u0026= ~FTGMAC100_REVR_NEW_MDIO_INTERFACE;\ndrivers/net/ethernet/faraday/ftgmac100.c:1757:\t\tiowrite32(reg, priv-\u003ebase + FTGMAC100_OFFSET_REVR);\ndrivers/net/ethernet/faraday/ftgmac100.c-1758-\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c=1942=static int ftgmac100_probe(struct platform_device *pdev)\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-1959-\t} else {\ndrivers/net/ethernet/faraday/ftgmac100.c:1960:\t\tmac_id = FTGMAC100_FARADAY;\ndrivers/net/ethernet/faraday/ftgmac100.c-1961-\t}\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2017-\ndrivers/net/ethernet/faraday/ftgmac100.c:2018:\tif (priv-\u003emac_id == FTGMAC100_AST2400 ||\ndrivers/net/ethernet/faraday/ftgmac100.c:2019:\t priv-\u003emac_id == FTGMAC100_AST2500 ||\ndrivers/net/ethernet/faraday/ftgmac100.c:2020:\t priv-\u003emac_id == FTGMAC100_AST2600) {\ndrivers/net/ethernet/faraday/ftgmac100.c-2021-\t\tpriv-\u003erxdes0_edorr_mask = BIT(30);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2028-\ndrivers/net/ethernet/faraday/ftgmac100.c:2029:\tif (priv-\u003emac_id == FTGMAC100_FARADAY ||\ndrivers/net/ethernet/faraday/ftgmac100.c:2030:\t priv-\u003emac_id == FTGMAC100_AST2400 ||\ndrivers/net/ethernet/faraday/ftgmac100.c:2031:\t priv-\u003emac_id == FTGMAC100_AST2500) {\ndrivers/net/ethernet/faraday/ftgmac100.c-2032-\t\terr = ftgmac100_setup_mdio(netdev);\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2055-\t/* Disable ast2600 problematic HW arbitration */\ndrivers/net/ethernet/faraday/ftgmac100.c:2056:\tif (priv-\u003emac_id == FTGMAC100_AST2600)\ndrivers/net/ethernet/faraday/ftgmac100.c:2057:\t\tiowrite32(FTGMAC100_TM_DEFAULT,\ndrivers/net/ethernet/faraday/ftgmac100.c:2058:\t\t\t priv-\u003ebase + FTGMAC100_OFFSET_TM);\ndrivers/net/ethernet/faraday/ftgmac100.c-2059-\n--\ndrivers/net/ethernet/faraday/ftgmac100.c-2072-\t/* AST2400 doesn't have working HW checksum generation */\ndrivers/net/ethernet/faraday/ftgmac100.c:2073:\tif (priv-\u003emac_id == FTGMAC100_AST2400)\n\n"
} |
| 21/2 | 2026/08/30 07:55 | llm | patch-evaluator |
3mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 57283 output: 40 thoughts: 116 Thoughts: **NCSI Netlink Interface Analysis** Okay, hold on a second. I need to dig into this NCSI situation a bit deeper. Let's start by examining `ncsi-netlink.c`. Right, so `ncsi_init_netlink()` is getting called during boot, specifically via `subsys_initcall` or potentially `module_init`, right? This immediately raises a question in my mind: can a userspace application potentially communicate with the NCSI interface directly through Netlink, even if there's *no* associated `ftgmac100` device registered, or indeed, *any* network interface present at that stage? This feels like a potential area of risk or at least a powerful alternative configuration path. I need to confirm this quickly. So, let's carefully review the `net/ncsi/ncsi-netlink.c` source code file. I need to understand the specifics of this implementation. Let's read this code very, very carefully. |
| 22/2 | 2026/08/30 07:58 | tool | read-file |
0mArgs:{
"File": "net/ncsi/ncsi-netlink.c",
"FirstLine": 1,
"LineCount": 80
}Results: {
"Contents": " 1:\t// SPDX-License-Identifier: GPL-2.0-or-later\n 2:\t/*\n 3:\t * Copyright Samuel Mendoza-Jonas, IBM Corporation 2018.\n 4:\t */\n 5:\t\n 6:\t#include \u003clinux/module.h\u003e\n 7:\t#include \u003clinux/kernel.h\u003e\n 8:\t#include \u003clinux/if_arp.h\u003e\n 9:\t#include \u003clinux/rtnetlink.h\u003e\n 10:\t#include \u003clinux/etherdevice.h\u003e\n 11:\t#include \u003cnet/genetlink.h\u003e\n 12:\t#include \u003cnet/ncsi.h\u003e\n 13:\t#include \u003clinux/skbuff.h\u003e\n 14:\t#include \u003cnet/sock.h\u003e\n 15:\t#include \u003cuapi/linux/ncsi.h\u003e\n 16:\t\n 17:\t#include \"internal.h\"\n 18:\t#include \"ncsi-pkt.h\"\n 19:\t#include \"ncsi-netlink.h\"\n 20:\t\n 21:\tstatic struct genl_family ncsi_genl_family;\n 22:\t\n 23:\tstatic const struct nla_policy ncsi_genl_policy[NCSI_ATTR_MAX + 1] = {\n 24:\t\t[NCSI_ATTR_IFINDEX] =\t\t{ .type = NLA_U32 },\n 25:\t\t[NCSI_ATTR_PACKAGE_LIST] =\t{ .type = NLA_NESTED },\n 26:\t\t[NCSI_ATTR_PACKAGE_ID] =\t{ .type = NLA_U32 },\n 27:\t\t[NCSI_ATTR_CHANNEL_ID] =\t{ .type = NLA_U32 },\n 28:\t\t[NCSI_ATTR_DATA] =\t\t{ .type = NLA_BINARY, .len = 2048 },\n 29:\t\t[NCSI_ATTR_MULTI_FLAG] =\t{ .type = NLA_FLAG },\n 30:\t\t[NCSI_ATTR_PACKAGE_MASK] =\t{ .type = NLA_U32 },\n 31:\t\t[NCSI_ATTR_CHANNEL_MASK] =\t{ .type = NLA_U32 },\n 32:\t};\n 33:\t\n 34:\tstatic struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)\n 35:\t{\n 36:\t\tstruct ncsi_dev_priv *ndp;\n 37:\t\tstruct net_device *dev;\n 38:\t\n 39:\t\tif (!net)\n 40:\t\t\treturn NULL;\n 41:\t\n 42:\t\tdev = dev_get_by_index(net, ifindex);\n 43:\t\tif (!dev) {\n 44:\t\t\tpr_err(\"NCSI netlink: No device for ifindex %u\\n\", ifindex);\n 45:\t\t\treturn NULL;\n 46:\t\t}\n 47:\t\n 48:\t\tndp = ncsi_dev_get(dev);\n 49:\t\tdev_put(dev);\n 50:\t\treturn ndp;\n 51:\t}\n 52:\t\n 53:\tstatic int ncsi_write_channel_info(struct sk_buff *skb,\n 54:\t\t\t\t\t struct ncsi_dev_priv *ndp,\n 55:\t\t\t\t\t struct ncsi_channel *nc)\n 56:\t{\n 57:\t\tstruct ncsi_channel_vlan_filter *ncf;\n 58:\t\tstruct ncsi_channel_mode *m;\n 59:\t\tstruct nlattr *vid_nest;\n 60:\t\tint i;\n 61:\t\n 62:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_ID, nc-\u003eid);\n 63:\t\tm = \u0026nc-\u003emodes[NCSI_MODE_LINK];\n 64:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_LINK_STATE, m-\u003edata[2]);\n 65:\t\tif (nc-\u003estate == NCSI_CHANNEL_ACTIVE)\n 66:\t\t\tnla_put_flag(skb, NCSI_CHANNEL_ATTR_ACTIVE);\n 67:\t\tif (nc == nc-\u003epackage-\u003epreferred_channel)\n 68:\t\t\tnla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED);\n 69:\t\n 70:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc-\u003eversion.major);\n 71:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc-\u003eversion.minor);\n 72:\t\tnla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc-\u003eversion.fw_name);\n 73:\t\n 74:\t\tvid_nest = nla_nest_start_noflag(skb, NCSI_CHANNEL_ATTR_VLAN_LIST);\n 75:\t\tif (!vid_nest)\n 76:\t\t\treturn -ENOMEM;\n 77:\t\tncf = \u0026nc-\u003evlan_filter;\n 78:\t\ti = -1;\n 79:\t\twhile ((i = find_next_bit((void *)\u0026ncf-\u003ebitmap, ncf-\u003en_vids,\n 80:\t\t\t\t\t i + 1)) \u003c ncf-\u003en_vids) {\n"
} |
| 23/2 | 2026/08/30 07:58 | llm | patch-evaluator |
4mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 59060 output: 47 thoughts: 558 Thoughts: **NCSI Netlink Message Analysis** Okay, let's break this down. My initial thought is to explore the interaction with the "NCSI" generic netlink family. Specifically, what happens if someone starts sending netlink messages to it? I see the code calls `ndp_from_ifindex`, which is pretty straightforward: it gets the network device using `dev_get_by_index` and then retrieves the NCSI-specific private data using `ncsi_dev_get`. `ncsi_dev_get`, however, is where the potential issue arises. It looks for a registered device via `ncsi_find_dev` under an RCU read lock. It then grabs a reference using `kref_get_unless_zero` if it finds one. Here's the critical bit: what if `ncsi_find_dev` returns NULL, meaning no NCSI device is registered? This would cause `ncsi_dev_get` to return NULL. Now, I need to check how that NULL value propagates. Looking at `ncsi_pkg_info_nl`, it seems to handle this. It checks for the presence of the `NCSI_ATTR_IFINDEX` and `NCSI_ATTR_PACKAGE_ID` attributes, and if it finds them, it then calls `ndp_from_ifindex`. The all important check happens: if `ndp` is NULL (i.e., no device found), it returns `-ENODEV`, which seems like the correct behavior. That's good, it handles the null case. Now, a couple of follow-up questions: can NCSI devices even be registered in environments like QEMU or GCE? Or is this limited to specific hardware? How does the `ftgmac100` driver probe for NCSI? I need to check its probe function to understand if and how devices register with NCSI. It's time to dig into the `ftgmac100_probe` and `ftgmac100_probe_ncsi` functions and look at `drivers/net/ethernet/faraday/ftgmac100.c` to see how it handles this registration process. |
| 24/2 | 2026/08/30 08:02 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/faraday/ftgmac100.c",
"FirstLine": 1845,
"LineCount": 80
}Results: {
"Contents": "1845:\t\treturn ret;\n1846:\t}\n1847:\t\n1848:\tstatic int ftgmac100_probe_ncsi(struct net_device *netdev,\n1849:\t\t\t\t\tstruct ftgmac100 *priv,\n1850:\t\t\t\t\tstruct platform_device *pdev)\n1851:\t{\n1852:\t\tstruct device_node *np = pdev-\u003edev.of_node;\n1853:\t\tstruct phy_device *phydev;\n1854:\t\tint err;\n1855:\t\n1856:\t\tif (!IS_ENABLED(CONFIG_NET_NCSI)) {\n1857:\t\t\tdev_err(\u0026pdev-\u003edev, \"NCSI stack not enabled\\n\");\n1858:\t\t\treturn -EINVAL;\n1859:\t\t}\n1860:\t\n1861:\t\tdev_info(\u0026pdev-\u003edev, \"Using NCSI interface\\n\");\n1862:\t\tpriv-\u003euse_ncsi = true;\n1863:\t\tpriv-\u003endev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);\n1864:\t\tif (!priv-\u003endev)\n1865:\t\t\treturn -EINVAL;\n1866:\t\n1867:\t\tphydev = fixed_phy_register(\u0026ncsi_phy_status, np);\n1868:\t\tif (IS_ERR(phydev)) {\n1869:\t\t\tdev_err(\u0026pdev-\u003edev, \"failed to register fixed PHY device\\n\");\n1870:\t\t\terr = PTR_ERR(phydev);\n1871:\t\t\tgoto err_register_ndev;\n1872:\t\t}\n1873:\t\terr = phy_connect_direct(netdev, phydev, ftgmac100_adjust_link,\n1874:\t\t\t\t\t PHY_INTERFACE_MODE_RMII);\n1875:\t\tif (err) {\n1876:\t\t\tdev_err(\u0026pdev-\u003edev, \"Connecting PHY failed\\n\");\n1877:\t\t\tgoto err_register_phy;\n1878:\t\t}\n1879:\t\n1880:\t\treturn 0;\n1881:\terr_register_phy:\n1882:\t\tfixed_phy_unregister(phydev);\n1883:\terr_register_ndev:\n1884:\t\tif (priv-\u003endev)\n1885:\t\t\tncsi_unregister_dev(priv-\u003endev);\n1886:\t\tpriv-\u003endev = NULL;\n1887:\t\treturn err;\n1888:\t}\n1889:\t\n1890:\tstatic int ftgmac100_probe_dt(struct net_device *netdev,\n1891:\t\t\t\t struct platform_device *pdev,\n1892:\t\t\t\t struct ftgmac100 *priv,\n1893:\t\t\t\t struct device_node *np)\n1894:\t{\n1895:\t\tstruct phy_device *phy;\n1896:\t\tint err;\n1897:\t\n1898:\t\tif (of_get_property(np, \"use-ncsi\", NULL))\n1899:\t\t\treturn ftgmac100_probe_ncsi(netdev, priv, pdev);\n1900:\t\n1901:\t\tif (of_phy_is_fixed_link(np) ||\n1902:\t\t of_get_property(np, \"phy-handle\", NULL)) {\n1903:\t\t\t/* Support \"mdio\"/\"phy\" child nodes for ast2400/2500\n1904:\t\t\t * with an embedded MDIO controller. Automatically\n1905:\t\t\t * scan the DTS for available PHYs and register\n1906:\t\t\t * them. 2600 has an independent MDIO controller, not\n1907:\t\t\t * part of the MAC.\n1908:\t\t\t */\n1909:\t\t\tphy = of_phy_get_and_connect(priv-\u003enetdev, np,\n1910:\t\t\t\t\t\t \u0026ftgmac100_adjust_link);\n1911:\t\t\tif (!phy) {\n1912:\t\t\t\tdev_err(\u0026pdev-\u003edev, \"Failed to connect to phy\\n\");\n1913:\t\t\t\treturn -EINVAL;\n1914:\t\t\t}\n1915:\t\n1916:\t\t\t/* Indicate that we support PAUSE frames (see comment in\n1917:\t\t\t * Documentation/networking/phy.rst)\n1918:\t\t\t */\n1919:\t\t\tphy_support_asym_pause(phy);\n1920:\t\n1921:\t\t\t/* Display what we found */\n1922:\t\t\tphy_attached_info(phy);\n1923:\t\t\treturn 0;\n1924:\t\t}\n"
} |
| 25/2 | 2026/08/30 08:02 | llm | patch-evaluator |
3mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 61389 output: 30 thoughts: 2826 Thoughts: **NCSI Concurrency Overhaul: Worthy of Fuzzing** Okay, so `ftgmac100` is an ARM platform device, likely ASPEED BMC. The first question is always emulation: can QEMU handle this? It has models for similar ASPEED machines, so that's a good starting point. The real question is whether NCSI, `ftgmac100`, or NCSI netlink interactions are being fuzzed in standard environments. Let's dig into syzkaller's documentation. The key to finding a vulnerability here is understanding the context that Syzkaller will run in. There are some automatic reasons that Syzkaller will choose not to fuzz a patch, or to flag it as not worth fuzzing. The instructions have some clear criteria: modifications to documentation or Kconfig, cosmetic changes like logging, changes to constants without impacting flow, unreachable code in a virtualized environment, and vendor-specific or driver teardown callbacks. We need to assess if this patch falls into any of those categories. Now, is NCSI part of the core network stack (`net/`)? Indeed, it's `net/ncsi/` and provides the generic netlink family "NCSI". Can it be reached from userspace via netlink? Crucially, we need to know if it's reachable via netlink. Let's see if syzkaller has descriptions for the NCSI family or generic netlink! Even if no NCSI device is currently registered, what happens when generic netlink messages for NCSI are sent? I see a series of netlink handlers that can be triggered: `ncsi_pkg_info_nl`, `ncsi_pkg_info_all_nl`, `ncsi_set_interface_nl`, `ncsi_clear_interface_nl`, `ncsi_send_cmd_nl`, `ncsi_set_package_mask_nl`, and `ncsi_set_channel_mask_nl`. A deeper look at `ncsi-netlink.c` reveals this patch is about more than just simple modifications. The `ndp_from_ifindex` function is changed to use `ncsi_dev_get` instead of directly searching. `ncsi_dev_get` uses RCU and a kref to safely manage device references. The critical netlink functions like `ncsi_pkg_info_nl` are also updated to make use of `ncsi_dev_get` and `ncsi_dev_put`. So, what's this patch *actually* doing? Let's break it down by examining the commit changes. The patch adds RCU and kref members to multiple `struct`s like `ncsi_dev_priv` , `ncsi_channel` and `ncsi_package`. `ncsi_dev_get` and `ncsi_dev_put` are declared. Then, in `ncsi-manage.c`, we see a full concurrency overhaul: RCU reads are added around several functions like `ncsi_channel_is_last` and `ncsi_report_link`. Channels are freed using RCU callbacks. `kfree_rcu` is used, and work is cancelled safely. And finally, in `ncsi-netlink.c` `ncsi_dev_get` and `ncsi_dev_put` are used everywhere to safely grab and put the device private data. This is a comprehensive refactoring to manage concurrency, reference counting, and prevent use-after-free and race conditions between Netlink handlers and device unregistration or channel removal. Now, does this mean NCSI is worthy of fuzzing? It's in the core network subsystem, and affects a Netlink interface reachable by userspace. It also touches network interface state and packet handlers, and undergoes substantial concurrency logic changes. This is *exactly* the kind of patch that Syzkaller should target. Let's quickly check the not-worth-fuzzing conditions: - No documentation or Kconfig changes. - Not just cosmetic changes. This is about refcounting, RCU locking, work synchronization. - No changes to numeric constants. - The most important thing here: Generic netlink is registered on boot, so any userspace program can send messages to the NCSI family, which will trigger those netlink handlers. The other thing is `ncsi_register_dev` can be used by drivers and test harnesses and `ETH_P_NCSI` receives raw ethernet frames. - No vendor-specific drivers. - No .remove/.shutdown calls. Given all of this, WorthFuzzing is TRUE. Now, focus symbols. Which symbols are modified here |
| 26/2 | 2026/08/30 08:06 | tool | grepper |
0mArgs:{
"Expression": "ncsi_ops",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/ncsi-netlink.c=673=static int ncsi_set_channel_mask_nl(struct sk_buff *msg,\n--\nnet/ncsi/ncsi-netlink.c-760-\nnet/ncsi/ncsi-netlink.c:761:static const struct genl_small_ops ncsi_ops[] = {\nnet/ncsi/ncsi-netlink.c-762-\t{\n--\nnet/ncsi/ncsi-netlink.c=801=static struct genl_family ncsi_genl_family __ro_after_init = {\n--\nnet/ncsi/ncsi-netlink.c-806-\t.module = THIS_MODULE,\nnet/ncsi/ncsi-netlink.c:807:\t.small_ops = ncsi_ops,\nnet/ncsi/ncsi-netlink.c:808:\t.n_small_ops = ARRAY_SIZE(ncsi_ops),\nnet/ncsi/ncsi-netlink.c-809-\t.resv_start_op = NCSI_CMD_SET_CHANNEL_MASK + 1,\n"
} |
| 27/2 | 2026/08/30 08:06 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 65591 output: 25 thoughts: 265 Thoughts: **Analyzing the NCSI Driver Architecture** Okay, let's break this down. From what I'm seeing, `ncsi_ops` is the key structure here, and it’s storing function pointers. The critical part is that these function pointers are pointing to functions like `ncsi_pkg_info_nl`, `ncsi_pkg_info_all_nl`, and the others. Because these addresses are explicitly referenced within `ncsi_ops`, the compiler *can't* inline them – that's a key optimization that's off the table. Each of those functions has its own distinct symbol address, as we'd expect in `vmlinux`. Then, we've got a set of non-static functions as well: `ncsi_dev_get`, `ncsi_dev_put`, `ncsi_unregister_dev`, `ncsi_register_dev`, `ncsi_update_tx_channel`, `ncsi_free_request`, and `ncsi_channel_is_last`. Now, let's shift gears and check the Kconfig options, I need to get a clear picture of what configurations are needed for the `net/ncsi/` subsystem. Time to dig back into `net/Kconfig` and `net/ncsi/Kconfig` to refresh my memory and verify the dependencies. |
| 28/2 | 2026/08/30 08:07 | tool | grepper |
0mArgs:{
"Expression": "NET_NCSI",
"PathPrefix": "net"
}Results: {
"Output": "net/Makefile=71=obj-$(CONFIG_QRTR)\t\t+= qrtr/\nnet/Makefile:72:obj-$(CONFIG_NET_NCSI)\t\t+= ncsi/\nnet/Makefile-73-obj-$(CONFIG_XDP_SOCKETS)\t+= xdp/\n--\nnet/ncsi/Kconfig-5-\nnet/ncsi/Kconfig:6:config NET_NCSI\nnet/ncsi/Kconfig-7-\tbool \"NCSI interface support\"\n--\nnet/ncsi/Kconfig=14=config NCSI_OEM_CMD_GET_MAC\nnet/ncsi/Kconfig-15-\tbool \"Get NCSI OEM MAC Address\"\nnet/ncsi/Kconfig:16:\tdepends on NET_NCSI\nnet/ncsi/Kconfig-17-\thelp\n--\nnet/ncsi/Kconfig=20=config NCSI_OEM_CMD_KEEP_PHY\nnet/ncsi/Kconfig-21-\tbool \"Keep PHY Link up\"\nnet/ncsi/Kconfig:22:\tdepends on NET_NCSI\nnet/ncsi/Kconfig-23-\thelp\n--\nnet/ncsi/Makefile-4-#\nnet/ncsi/Makefile:5:obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-aen.o ncsi-manage.o ncsi-netlink.o\n"
} |
| 29/2 | 2026/08/30 08:07 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 66553 output: 32 thoughts: 83 Thoughts: **NCSI Interface Support - A Quick Investigation** Alright, let's dive into this NCSI interface support. First things first, I need to confirm the configuration's dependencies. A quick peek at `net/ncsi/Kconfig` is in order. Aha! `NET_NCSI` depends on `INET` – that's expected, given its nature. Now, I need to make sure there aren't any other subtle dependencies or configs I'm missing. I'll need to expand my search. The kernel's `net/Kconfig` file should hold the answers; I'll start browsing around line 280 to see what else might be relevant. |
| 30/2 | 2026/08/30 08:07 | tool | read-file |
0mArgs:{
"File": "net/Kconfig",
"FirstLine": 275,
"LineCount": 20
}Results: {
"Contents": " 275:\tsource \"net/vmw_vsock/Kconfig\"\n 276:\tsource \"net/netlink/Kconfig\"\n 277:\tsource \"net/mpls/Kconfig\"\n 278:\tsource \"net/nsh/Kconfig\"\n 279:\tsource \"net/hsr/Kconfig\"\n 280:\tsource \"net/switchdev/Kconfig\"\n 281:\tsource \"net/l3mdev/Kconfig\"\n 282:\tsource \"net/qrtr/Kconfig\"\n 283:\tsource \"net/ncsi/Kconfig\"\n 284:\t\n 285:\tconfig PCPU_DEV_REFCNT\n 286:\t\tbool \"Use percpu variables to maintain network device refcount\"\n 287:\t\tdepends on SMP\n 288:\t\tdefault y\n 289:\t\thelp\n 290:\t\t network device refcount are using per cpu variables if this option is set.\n 291:\t\t This can be forced to N to detect underflows (with a performance drop).\n 292:\t\n 293:\tconfig MAX_SKB_FRAGS\n 294:\t\tint \"Maximum number of fragments per skb_shared_info\"\n"
} |
| 31/2 | 2026/08/30 08:07 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 67146 output: 31 thoughts: 103 Thoughts: **NCSI Configuration Investigation** Okay, so I'm diving into this NCSI configuration stuff. First, I need to make sure I've got the lay of the land, so let's start by quickly verifying that `CONFIG_NET_NCSI` is enabled. Then, since this is networking-related, let's confirm the broader infrastructure by checking `CONFIG_INET` and its parent, `CONFIG_NET`. Got it. Now, the real meat of this seems to be around OEM commands, so I need to check `CONFIG_NCSI_OEM_CMD_GET_MAC` and `CONFIG_NCSI_OEM_CMD_KEEP_PHY`. I'll run a quick grep for `NCSI_OEM_CMD` within the `net/ncsi/` directory to get a comprehensive view of all the relevant defines and usage. That should give me a solid foundation for understanding the NCSI OEM command configuration. |
| 32/2 | 2026/08/30 08:08 | tool | grepper |
0mArgs:{
"Expression": "NCSI_OEM_CMD",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/Kconfig=6=config NET_NCSI\n--\nnet/ncsi/Kconfig-13-\t the protocol explicitly.\nnet/ncsi/Kconfig:14:config NCSI_OEM_CMD_GET_MAC\nnet/ncsi/Kconfig-15-\tbool \"Get NCSI OEM MAC Address\"\n--\nnet/ncsi/Kconfig-19-\t\tcontroller.\nnet/ncsi/Kconfig:20:config NCSI_OEM_CMD_KEEP_PHY\nnet/ncsi/Kconfig-21-\tbool \"Keep PHY Link up\"\n--\nnet/ncsi/ncsi-manage.c=1010=static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)\n--\nnet/ncsi/ncsi-manage.c-1059-\nnet/ncsi/ncsi-manage.c:1060:\t\tnd-\u003estate = IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)\nnet/ncsi/ncsi-manage.c-1061-\t\t\t ? ncsi_dev_state_config_oem_gma\n--\nnet/ncsi/ncsi-manage.c=1386=static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)\n--\nnet/ncsi/ncsi-manage.c-1442-\t\tnd-\u003estate = ncsi_dev_state_probe_cis;\nnet/ncsi/ncsi-manage.c:1443:\t\tif (IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) \u0026\u0026\nnet/ncsi/ncsi-manage.c-1444-\t\t ndp-\u003emlx_multi_host)\n--\nnet/ncsi/ncsi-manage.c-1510-\t\t\tnd-\u003estate = ncsi_dev_state_probe_gvi;\nnet/ncsi/ncsi-manage.c:1511:\t\t\tif (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) \u0026\u0026 ndp-\u003echannel_probe_id == 0)\nnet/ncsi/ncsi-manage.c-1512-\t\t\t\tnd-\u003estate = ncsi_dev_state_probe_keep_phy;\n"
} |
| 33/2 | 2026/08/30 08:08 | llm | patch-evaluator |
1mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 68071 output: 288 thoughts: 361 Thoughts: **NCSI Driver Analysis: Configuration and Focus Symbol Verification** Okay, let's take a look at the NCSI driver. First, I need to confirm the relevant configuration options. I'll check `net/ncsi/Makefile` to confirm the required dependencies for `CONFIG_NET_NCSI`. Based on the makefile rule, it looks like `NET_NCSI`, `INET`, and, implicitly, `NET` are the key configs. That's good to know. Now, I'll review the focus symbols identified for this component. The list includes functions like `ncsi_dev_get`, `ncsi_dev_put`, `ncsi_unregister_dev`, `ncsi_register_dev`, various netlink handlers ( `ncsi_pkg_info_nl`, `ncsi_set_interface_nl`, etc.), and some internal channel management functions (`ncsi_update_tx_channel`, `ncsi_channel_is_last`). This seems like a reasonable set of entry points and modified functions, covering device management and netlink interface interactions. This is what I expect to see. I've reviewed the guidelines. I've confirmed that `WorthFuzzing` should be a boolean, `FocusSymbols` is a list of strings and that we don't have any generic hot paths here. It looks like we have entrypoints/modified functions. Also, `EnableConfigs` is a list of strings without the `CONFIG_` prefix. The `Reasoning` should be a concise explanation of the verdict. I've checked the code search and everything seems to be in order. Alright, I'm satisfied. Time to call `set-results`. |
| 34/2 | 2026/08/30 08:10 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"NET_NCSI",
"INET"
],
"FocusSymbols": [
"ncsi_dev_get",
"ncsi_dev_put",
"ncsi_unregister_dev",
"ncsi_register_dev",
"ncsi_pkg_info_nl",
"ncsi_pkg_info_all_nl",
"ncsi_set_interface_nl",
"ncsi_clear_interface_nl",
"ncsi_send_cmd_nl",
"ncsi_set_package_mask_nl",
"ncsi_set_channel_mask_nl",
"ncsi_update_tx_channel",
"ncsi_channel_is_last",
"ncsi_free_request"
],
"Reasoning": "The patch introduces RCU-based synchronization, reference counting (kref), and work cancellation handling across NCSI (Network Controller Sideband Interface) core management and Generic Netlink interfaces. It fixes potential race conditions and use-after-free bugs between device deregistration, channel removal, and user-initiated Netlink operations. These changes affect reachable kernel networking code accessible via generic netlink sockets and are worth fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"NET_NCSI",
"INET"
],
"FocusSymbols": [
"ncsi_dev_get",
"ncsi_dev_put",
"ncsi_unregister_dev",
"ncsi_register_dev",
"ncsi_pkg_info_nl",
"ncsi_pkg_info_all_nl",
"ncsi_set_interface_nl",
"ncsi_clear_interface_nl",
"ncsi_send_cmd_nl",
"ncsi_set_package_mask_nl",
"ncsi_set_channel_mask_nl",
"ncsi_update_tx_channel",
"ncsi_channel_is_last",
"ncsi_free_request"
],
"Reasoning": "The patch introduces RCU-based synchronization, reference counting (kref), and work cancellation handling across NCSI (Network Controller Sideband Interface) core management and Generic Netlink interfaces. It fixes potential race conditions and use-after-free bugs between device deregistration, channel removal, and user-initiated Netlink operations. These changes affect reachable kernel networking code accessible via generic netlink sockets and are worth fuzzing.",
"WorthFuzzing": true
} |
| 35/1 | 2026/08/30 08:10 | action | If |
10mArgs:{
"WorthFuzzing": true
}Results: null |
| 36/2 | 2026/08/30 08:10 | agent | kmsan-evaluator |
10mModel:core Args: null Results: {
"KMSANReasoning": "The patch refactors memory management and concurrency synchronization for NCSI (Network Controller Sideband Interface) devices, packages, and channels by introducing RCU-protected lists and reference counting (kref) along with deferred RCU frees (call_rcu/kfree_rcu). \n\nThese modifications aim to fix race conditions and use-after-free (UAF) hazards during device unregistration and concurrent netlink operations. All involved structures (such as `struct ncsi_dev_priv`, `struct ncsi_package`, `struct ncsi_channel`) continue to be allocated using `kzalloc_obj` (zero-initialized), and local variables in altered paths are explicitly initialized. No new uninitialized data paths, padding leaks, or uninitialized buffer operations are introduced or exposed. Potential issues arising from these changes (such as lifetime/UAF bugs, RCU locking imbalance, or reference counting bugs) are covered by KASAN and LOCKDEP/PROVE_RCU rather than KMSAN. Thus, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: For your convenience, here is the diff of the changes:
commit c66bd73b2eb7d3d1fcc1847d455a8306933c93d1
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Aug 30 07:40:41 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index adee6dcabdc3f..fbd90f270f5ee 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -239,6 +239,7 @@ struct ncsi_channel {
} monitor;
struct list_head node;
struct list_head link;
+ struct rcu_head rcu; /* RCU cleanup */
};
struct ncsi_package {
@@ -253,6 +254,7 @@ struct ncsi_package {
bool multi_channel; /* Enable multiple channels */
u32 channel_whitelist; /* Channels to configure */
struct ncsi_channel *preferred_channel; /* Primary channel */
+ struct rcu_head rcu; /* RCU cleanup */
};
struct ncsi_request {
@@ -315,6 +317,8 @@ struct vlan_vid {
};
struct ncsi_dev_priv {
+ struct rcu_head rcu; /* RCU cleanup */
+ struct kref ref;
struct ncsi_dev ndev; /* Associated NCSI device */
unsigned int flags; /* NCSI device flags */
#define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */
@@ -337,6 +341,7 @@ struct ncsi_dev_priv {
struct ncsi_channel *active_channel; /* Currently handled channel */
struct list_head channel_queue; /* Config queue of channels */
struct work_struct work; /* For channel management */
+ bool work_cancelled; /* Work has been cancelled */
struct packet_type ptype; /* NCSI packet Rx handler */
struct list_head node; /* Form NCSI device list */
#define NCSI_MAX_VLAN_VIDS 15
@@ -406,7 +411,8 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
struct ncsi_package *np,
struct ncsi_channel *disable,
struct ncsi_channel *enable);
-
+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev);
+void ncsi_dev_put(struct ncsi_dev_priv *ndp);
/* Packet handlers */
u32 ncsi_calculate_checksum(unsigned char *data, int len);
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 54d0df0a9efe6..afc34c2b36136 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -10,6 +10,7 @@
#include <linux/skbuff.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/rcupdate.h>
#include <net/ncsi.h>
#include <net/net_namespace.h>
@@ -35,17 +36,23 @@ bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,
{
struct ncsi_package *np;
struct ncsi_channel *nc;
+ bool is_last = true;
- NCSI_FOR_EACH_PACKAGE(ndp, np)
+ rcu_read_lock();
+ NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
if (nc == channel)
continue;
if (nc->state == NCSI_CHANNEL_ACTIVE &&
- ncsi_channel_has_link(nc))
- return false;
+ ncsi_channel_has_link(nc)) {
+ is_last = false;
+ goto out;
+ }
}
-
- return true;
+ }
+ out:
+ rcu_read_unlock();
+ return is_last;
}
static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
@@ -62,6 +69,7 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
}
nd->link_up = 0;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
spin_lock_irqsave(&nc->lock, flags);
@@ -75,12 +83,14 @@ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down)
if (ncsi_channel_has_link(nc)) {
spin_unlock_irqrestore(&nc->lock, flags);
nd->link_up = 1;
+ rcu_read_unlock();
goto report;
}
spin_unlock_irqrestore(&nc->lock, flags);
}
}
+ rcu_read_unlock();
report:
nd->handler(nd);
@@ -242,28 +252,37 @@ struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id)
return nc;
}
+static void ncsi_channel_rcu_free(struct rcu_head *head)
+{
+ struct ncsi_channel *nc = container_of(head, struct ncsi_channel, rcu);
+
+ kfree(nc->mac_filter.addrs);
+ kfree(nc->vlan_filter.vids);
+ kfree(nc);
+}
+
static void ncsi_remove_channel(struct ncsi_channel *nc)
{
struct ncsi_package *np = nc->package;
+ struct ncsi_dev_priv *ndp = np->ndp;
unsigned long flags;
- spin_lock_irqsave(&nc->lock, flags);
-
- /* Release filters */
- kfree(nc->mac_filter.addrs);
- kfree(nc->vlan_filter.vids);
+ ncsi_stop_channel_monitor(nc);
+ spin_lock_irqsave(&nc->lock, flags);
nc->state = NCSI_CHANNEL_INACTIVE;
spin_unlock_irqrestore(&nc->lock, flags);
- ncsi_stop_channel_monitor(nc);
- /* Remove and free channel */
+ spin_lock_irqsave(&ndp->lock, flags);
+ list_del_rcu(&nc->link);
+ spin_unlock_irqrestore(&ndp->lock, flags);
+
spin_lock_irqsave(&np->lock, flags);
list_del_rcu(&nc->node);
np->channel_num--;
spin_unlock_irqrestore(&np->lock, flags);
- kfree(nc);
+ call_rcu(&nc->rcu, ncsi_channel_rcu_free);
}
struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,
@@ -326,7 +345,7 @@ void ncsi_remove_package(struct ncsi_package *np)
ndp->package_num--;
spin_unlock_irqrestore(&ndp->lock, flags);
- kfree(np);
+ kfree_rcu(np, rcu);
}
void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
@@ -409,7 +428,8 @@ void ncsi_free_request(struct ncsi_request *nr)
spin_unlock_irqrestore(&ndp->lock, flags);
if (driven && cmd && --ndp->pending_req_num == 0)
- schedule_work(&ndp->work);
+ if (!READ_ONCE(ndp->work_cancelled))
+ schedule_work(&ndp->work);
/* Release command and response */
consume_skb(cmd);
@@ -912,6 +932,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
nca.req_flags = 0;
/* Find current channel with Tx enabled */
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (disable)
break;
@@ -924,8 +945,10 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
break;
}
}
+ rcu_read_unlock();
/* Find a suitable channel for Tx */
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (enable)
break;
@@ -951,6 +974,7 @@ int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
}
}
}
+ rcu_read_unlock();
if (disable == enable)
return -1;
@@ -1253,6 +1277,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
*/
found = NULL;
with_link = false;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
if (!(ndp->package_whitelist & (0x1 << np->id)))
continue;
@@ -1304,6 +1329,7 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
if (with_link && !ndp->multi_package)
break;
}
+ rcu_read_unlock();
if (list_empty(&ndp->channel_queue) && found) {
netdev_info(ndp->ndev.dev,
@@ -1332,6 +1358,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
/* The hardware arbitration is disabled if any one channel
* doesn't support explicitly.
*/
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
NCSI_FOR_EACH_CHANNEL(np, nc) {
has_channel = true;
@@ -1345,6 +1372,7 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
}
}
}
+ rcu_read_unlock();
if (has_channel) {
ndp->flags |= NCSI_DEV_HWA;
@@ -1782,6 +1810,7 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
ndp->package_whitelist = UINT_MAX;
/* Initialize private NCSI device */
+ kref_init(&ndp->ref);
spin_lock_init(&ndp->lock);
INIT_LIST_HEAD(&ndp->packages);
ndp->request_id = NCSI_REQ_START_IDX;
@@ -1952,23 +1981,65 @@ int ncsi_reset_dev(struct ncsi_dev *nd)
return 0;
}
+static void ncsi_dev_release(struct kref *ref)
+{
+ struct ncsi_dev_priv *ndp;
+
+ ndp = container_of(ref, struct ncsi_dev_priv, ref);
+ kfree_rcu(ndp, rcu);
+}
+
+struct ncsi_dev_priv *ncsi_dev_get(struct net_device *dev)
+{
+ struct ncsi_dev_priv *ndp = NULL;
+ struct ncsi_dev *nd;
+
+ rcu_read_lock();
+ nd = ncsi_find_dev(dev);
+ if (nd) {
+ ndp = TO_NCSI_DEV_PRIV(nd);
+ /* Safely grab a reference while under RCU lock */
+ if (!kref_get_unless_zero(&ndp->ref))
+ ndp = NULL;
+ }
+ rcu_read_unlock();
+
+ return ndp;
+}
+
+void ncsi_dev_put(struct ncsi_dev_priv *ndp)
+{
+ if (ndp)
+ kref_put(&ndp->ref, ncsi_dev_release);
+}
+
void ncsi_unregister_dev(struct ncsi_dev *nd)
{
struct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);
struct ncsi_package *np, *tmp;
unsigned long flags;
- dev_remove_pack(&ndp->ptype);
-
- list_for_each_entry_safe(np, tmp, &ndp->packages, node)
- ncsi_remove_package(np);
-
spin_lock_irqsave(&ncsi_dev_lock, flags);
list_del_rcu(&ndp->node);
spin_unlock_irqrestore(&ncsi_dev_lock, flags);
+ spin_lock_irqsave(&ndp->lock, flags);
+ ndp->work_cancelled = true;
+ spin_unlock_irqrestore(&ndp->lock, flags);
+
+ for (int i = 0; i < ARRAY_SIZE(ndp->requests); i++) {
+ struct ncsi_request *nr = &ndp->requests[i];
+
+ if (nr->enabled)
+ ncsi_free_request(nr);
+ }
+
+ dev_remove_pack(&ndp->ptype);
disable_work_sync(&ndp->work);
- kfree(ndp);
+ list_for_each_entry_safe(np, tmp, &ndp->packages, node)
+ ncsi_remove_package(np);
+
+ kref_put(&ndp->ref, ncsi_dev_release);
}
EXPORT_SYMBOL_GPL(ncsi_unregister_dev);
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
index 8cc538358f6a3..59fd735c367ad 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -35,8 +35,6 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)
{
struct ncsi_dev_priv *ndp;
struct net_device *dev;
- struct ncsi_dev *nd;
- struct ncsi_dev;
if (!net)
return NULL;
@@ -47,9 +45,7 @@ static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex)
return NULL;
}
- nd = ncsi_find_dev(dev);
- ndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL;
-
+ ndp = ncsi_dev_get(dev);
dev_put(dev);
return ndp;
}
@@ -175,13 +171,16 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
return -ENODEV;
skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (!skb)
+ if (!skb) {
+ ncsi_dev_put(ndp);
return -ENOMEM;
+ }
hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq,
&ncsi_genl_family, 0, NCSI_CMD_PKG_INFO);
if (!hdr) {
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return -EMSGSIZE;
}
@@ -190,9 +189,13 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
attr = nla_nest_start_noflag(skb, NCSI_ATTR_PACKAGE_LIST);
if (!attr) {
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return -EMSGSIZE;
}
+
+ rcu_read_lock();
rc = ncsi_write_package_info(skb, ndp, package_id);
+ rcu_read_unlock();
if (rc) {
nla_nest_cancel(skb, attr);
@@ -202,10 +205,12 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)
nla_nest_end(skb, attr);
genlmsg_end(skb, hdr);
+ ncsi_dev_put(ndp);
return genlmsg_reply(skb, info);
err:
kfree_skb(skb);
+ ncsi_dev_put(ndp);
return rc;
}
@@ -235,14 +240,17 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
return -ENODEV;
package_id = cb->args[0];
+ rcu_read_lock();
package = NULL;
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id)
package = np;
- if (!package)
+ if (!package) {
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return 0; /* done */
-
+ }
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
&ncsi_genl_family, NLM_F_MULTI, NCSI_CMD_PKG_INFO);
if (!hdr) {
@@ -255,7 +263,9 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
rc = -EMSGSIZE;
goto err;
}
+
rc = ncsi_write_package_info(skb, ndp, package->id);
+
if (rc) {
nla_nest_cancel(skb, attr);
goto err;
@@ -266,9 +276,13 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
cb->args[0] = package_id + 1;
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return skb->len;
err:
+ rcu_read_unlock();
genlmsg_cancel(skb, hdr);
+ ncsi_dev_put(ndp);
return rc;
}
@@ -297,11 +311,15 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]);
package = NULL;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id)
package = np;
+
if (!package) {
/* The user has set a package that does not exist */
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
}
@@ -317,6 +335,8 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
netdev_info(ndp->ndev.dev,
"NCSI: Channel %u does not exist!\n",
channel_id);
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
}
}
@@ -337,6 +357,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
package->preferred_channel = NULL;
}
spin_unlock_irqrestore(&package->lock, flags);
+ rcu_read_unlock();
if (channel)
netdev_info(ndp->ndev.dev,
@@ -350,6 +371,7 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info)
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
@@ -376,6 +398,7 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)
ndp->multi_package = false;
spin_unlock_irqrestore(&ndp->lock, flags);
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np) {
spin_lock_irqsave(&np->lock, flags);
np->multi_channel = false;
@@ -383,18 +406,21 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)
np->preferred_channel = NULL;
spin_unlock_irqrestore(&np->lock, flags);
}
+ rcu_read_unlock();
+
netdev_info(ndp->ndev.dev, "NCSI: Cleared preferred package/channel\n");
/* Update channel configuration */
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
{
- struct ncsi_dev_priv *ndp;
+ struct ncsi_dev_priv *ndp = NULL;
struct ncsi_pkt_hdr *hdr;
struct ncsi_cmd_arg nca;
unsigned char *data;
@@ -480,6 +506,7 @@ static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
ret);
}
out:
+ ncsi_dev_put(ndp);
return ret;
}
@@ -639,6 +666,7 @@ static int ncsi_set_package_mask_nl(struct sk_buff *msg,
ncsi_reset_dev(&ndp->ndev);
}
+ ncsi_dev_put(ndp);
return rc;
}
@@ -670,14 +698,17 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]);
package = NULL;
+ rcu_read_lock();
NCSI_FOR_EACH_PACKAGE(ndp, np)
if (np->id == package_id) {
package = np;
break;
}
- if (!package)
+ if (!package) {
+ rcu_read_unlock();
+ ncsi_dev_put(ndp);
return -ERANGE;
-
+ }
spin_lock_irqsave(&package->lock, flags);
channel = NULL;
@@ -690,6 +721,7 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
}
if (!channel) {
spin_unlock_irqrestore(&package->lock, flags);
+ ncsi_dev_put(ndp);
return -ERANGE;
}
netdev_dbg(ndp->ndev.dev,
@@ -716,11 +748,13 @@ static int ncsi_set_channel_mask_nl(struct sk_buff *msg,
}
spin_unlock_irqrestore(&package->lock, flags);
+ rcu_read_unlock();
/* Update channel configuration */
if (!(ndp->flags & NCSI_DEV_RESET))
ncsi_reset_dev(&ndp->ndev);
+ ncsi_dev_put(ndp);
return 0;
}
|
| 37/3 | 2026/08/30 08:10 | llm | kmsan-evaluator |
2mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 8775 output: 34 thoughts: 1139 Thoughts: **KMSAN Fuzzing Session Assessment** Okay, let's break down this patch and see if it warrants a dedicated KMSAN fuzzing session. My initial thought is to quickly analyze the changes and identify potential areas where uninitialized memory access might be introduced or exposed, especially since it deals with concurrency primitives like RCU and reference counting. First, I'll identify the scope of the changes. The patch is clearly focused on RCU-based protection and kref reference counting within the NCSI data structures. I see new `rcu_head` members added to `ncsi_channel`, `ncsi_package`, and `ncsi_dev_priv`. The last one also receives a `kref` and a `work_cancelled` boolean. The associated function updates are critical here. I notice the ubiquitous `rcu_read_lock()`/`rcu_read_unlock()` calls appearing, which immediately flags the concurrent access as the core concern. The changes in the free functions (`ncsi_remove_channel`, `ncsi_remove_package`, `ncsi_dev_release`, etc.) are also worth close inspection, as these are frequent sites of concurrency issues. The netlink handlers in `ncsi-netlink.c` also get a close once over - specifically how `ncsi_dev_get` and `ncsi_dev_put` are used. Now, the lock imbalance in `ncsi_set_channel_mask_nl` stands out. The code block with the missing `rcu_read_unlock()` is a glaring red flag. That's a textbook lock imbalance, and I'd expect it to trigger LOCKDEP or some RCU debugger. This is not a KMSAN issue, but it does indicate a serious bug, and I'd prioritize this for debugging and a bug fix. Next, I'll shift gears. While this imbalance suggests a more basic bug, the focus of KMSAN is uninitialized memory. I need to be methodical in assessing whether this patch introduces any new uninitialized memory reads or information leaks. I'll need to look very closely at any structures being copied to user space. I'll focus on functions like `ncsi_write_package_info` (or anything involving `genlmsg_reply` in `ncsi-netlink.c`). I'll use tools like `grepper` or `read-file` to efficiently comb through the code and identify potential issues, checking touched functions for anything that could introduce new or newly exposed uninitialized memory access paths. From what I see the patch adds new structures and locks that could introduce the problem, so a targeted review is required. |
| 38/3 | 2026/08/30 08:13 | tool | grepper |
0mArgs:{
"Expression": "ncsi_write_package_info",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/ncsi-netlink.c=53=static int ncsi_write_channel_info(struct sk_buff *skb,\n--\nnet/ncsi/ncsi-netlink.c-89-\nnet/ncsi/ncsi-netlink.c:90:static int ncsi_write_package_info(struct sk_buff *skb,\nnet/ncsi/ncsi-netlink.c-91-\t\t\t\t struct ncsi_dev_priv *ndp, unsigned int id)\n--\nnet/ncsi/ncsi-netlink.c=150=static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info)\n--\nnet/ncsi/ncsi-netlink.c-196-\trcu_read_lock();\nnet/ncsi/ncsi-netlink.c:197:\trc = ncsi_write_package_info(skb, ndp, package_id);\nnet/ncsi/ncsi-netlink.c-198-\trcu_read_unlock();\n--\nnet/ncsi/ncsi-netlink.c=217=static int ncsi_pkg_info_all_nl(struct sk_buff *skb,\n--\nnet/ncsi/ncsi-netlink.c-266-\nnet/ncsi/ncsi-netlink.c:267:\trc = ncsi_write_package_info(skb, ndp, package-\u003eid);\nnet/ncsi/ncsi-netlink.c-268-\n"
} |
| 39/3 | 2026/08/30 08:13 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 10948 output: 41 thoughts: 34 Thoughts: Here's my take on the process, playing the role of an expert: **Diving into the NCSI Netlink Implementation** Alright, time to dig into the NCSI netlink implementation. I'm going to start by focusing on `net/ncsi/ncsi-netlink.c`, specifically lines 50 through 150. That should give me a good initial overview of how the netlink interface for NCSI is set up. I'll use `read-file` to grab those lines directly. I'm looking for the core data structures, message types, and any initial registration or initialization code related to the netlink family. Based on my experience, this section is likely to contain the crucial bits that define the communication channel with the NCSI controller, whether it's setting up sockets, handling attribute parsing, or defining the netlink message headers and payload structures. I’m hoping to quickly identify the key functions involved in sending and receiving NCSI commands and responses through netlink. Understanding this part is foundational to debugging or extending the NCSI support, so a focused read here is the best place to start. |
| 40/3 | 2026/08/30 08:14 | tool | read-file |
0mArgs:{
"File": "net/ncsi/ncsi-netlink.c",
"FirstLine": 50,
"LineCount": 80
}Results: {
"Contents": " 50:\t\treturn ndp;\n 51:\t}\n 52:\t\n 53:\tstatic int ncsi_write_channel_info(struct sk_buff *skb,\n 54:\t\t\t\t\t struct ncsi_dev_priv *ndp,\n 55:\t\t\t\t\t struct ncsi_channel *nc)\n 56:\t{\n 57:\t\tstruct ncsi_channel_vlan_filter *ncf;\n 58:\t\tstruct ncsi_channel_mode *m;\n 59:\t\tstruct nlattr *vid_nest;\n 60:\t\tint i;\n 61:\t\n 62:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_ID, nc-\u003eid);\n 63:\t\tm = \u0026nc-\u003emodes[NCSI_MODE_LINK];\n 64:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_LINK_STATE, m-\u003edata[2]);\n 65:\t\tif (nc-\u003estate == NCSI_CHANNEL_ACTIVE)\n 66:\t\t\tnla_put_flag(skb, NCSI_CHANNEL_ATTR_ACTIVE);\n 67:\t\tif (nc == nc-\u003epackage-\u003epreferred_channel)\n 68:\t\t\tnla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED);\n 69:\t\n 70:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc-\u003eversion.major);\n 71:\t\tnla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc-\u003eversion.minor);\n 72:\t\tnla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc-\u003eversion.fw_name);\n 73:\t\n 74:\t\tvid_nest = nla_nest_start_noflag(skb, NCSI_CHANNEL_ATTR_VLAN_LIST);\n 75:\t\tif (!vid_nest)\n 76:\t\t\treturn -ENOMEM;\n 77:\t\tncf = \u0026nc-\u003evlan_filter;\n 78:\t\ti = -1;\n 79:\t\twhile ((i = find_next_bit((void *)\u0026ncf-\u003ebitmap, ncf-\u003en_vids,\n 80:\t\t\t\t\t i + 1)) \u003c ncf-\u003en_vids) {\n 81:\t\t\tif (ncf-\u003evids[i])\n 82:\t\t\t\tnla_put_u16(skb, NCSI_CHANNEL_ATTR_VLAN_ID,\n 83:\t\t\t\t\t ncf-\u003evids[i]);\n 84:\t\t}\n 85:\t\tnla_nest_end(skb, vid_nest);\n 86:\t\n 87:\t\treturn 0;\n 88:\t}\n 89:\t\n 90:\tstatic int ncsi_write_package_info(struct sk_buff *skb,\n 91:\t\t\t\t\t struct ncsi_dev_priv *ndp, unsigned int id)\n 92:\t{\n 93:\t\tstruct nlattr *pnest, *cnest, *nest;\n 94:\t\tstruct ncsi_package *np;\n 95:\t\tstruct ncsi_channel *nc;\n 96:\t\tbool found;\n 97:\t\tint rc;\n 98:\t\n 99:\t\tif (id \u003e ndp-\u003epackage_num - 1) {\n 100:\t\t\tnetdev_info(ndp-\u003endev.dev, \"NCSI: No package with id %u\\n\", id);\n 101:\t\t\treturn -ENODEV;\n 102:\t\t}\n 103:\t\n 104:\t\tfound = false;\n 105:\t\tNCSI_FOR_EACH_PACKAGE(ndp, np) {\n 106:\t\t\tif (np-\u003eid != id)\n 107:\t\t\t\tcontinue;\n 108:\t\t\tpnest = nla_nest_start_noflag(skb, NCSI_PKG_ATTR);\n 109:\t\t\tif (!pnest)\n 110:\t\t\t\treturn -ENOMEM;\n 111:\t\t\trc = nla_put_u32(skb, NCSI_PKG_ATTR_ID, np-\u003eid);\n 112:\t\t\tif (rc) {\n 113:\t\t\t\tnla_nest_cancel(skb, pnest);\n 114:\t\t\t\treturn rc;\n 115:\t\t\t}\n 116:\t\t\tif ((0x1 \u003c\u003c np-\u003eid) == ndp-\u003epackage_whitelist)\n 117:\t\t\t\tnla_put_flag(skb, NCSI_PKG_ATTR_FORCED);\n 118:\t\t\tcnest = nla_nest_start_noflag(skb, NCSI_PKG_ATTR_CHANNEL_LIST);\n 119:\t\t\tif (!cnest) {\n 120:\t\t\t\tnla_nest_cancel(skb, pnest);\n 121:\t\t\t\treturn -ENOMEM;\n 122:\t\t\t}\n 123:\t\t\tNCSI_FOR_EACH_CHANNEL(np, nc) {\n 124:\t\t\t\tnest = nla_nest_start_noflag(skb, NCSI_CHANNEL_ATTR);\n 125:\t\t\t\tif (!nest) {\n 126:\t\t\t\t\tnla_nest_cancel(skb, cnest);\n 127:\t\t\t\t\tnla_nest_cancel(skb, pnest);\n 128:\t\t\t\t\treturn -ENOMEM;\n 129:\t\t\t\t}\n"
} |
| 41/3 | 2026/08/30 08:14 | llm | kmsan-evaluator |
2mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 12657 output: 27 thoughts: 73 Thoughts: **NCSI Structure Allocation Deep Dive** Okay, let's get down to brass tacks. I need to make absolutely sure the NCSI data structures are being handled correctly. Specifically, I'm thinking about memory allocation and initialization within the `net/ncsi/` directory. Are there any potential gotchas with `struct ncsi_dev_priv`, `struct ncsi_channel`, or `struct ncsi_package`? I have a feeling there might be some subtle bugs lurking in how those fields are being handled, which could lead to resource leaks or subtle corruption down the line. I know the code pretty well, but a focused review can't hurt. First, I'm going to quickly grep through `net/ncsi/` for any instances of `kzalloc`. That's a good starting point for identifying where memory is being allocated. I want to make sure the allocations are the right size and that the structures are zeroed appropriately. A quick scan of those allocation points should reveal any immediate red flags. This will give me a baseline to work from before diving deeper into the initialization and potential use-after-free or double-free scenarios. |
| 42/3 | 2026/08/30 08:16 | tool | grepper |
0mArgs:{
"Expression": "kzalloc",
"PathPrefix": "net/ncsi"
}Results: {
"Output": "net/ncsi/ncsi-manage.c=218=struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id)\n--\nnet/ncsi/ncsi-manage.c-223-\nnet/ncsi/ncsi-manage.c:224:\tnc = kzalloc_obj(*nc, GFP_ATOMIC);\nnet/ncsi/ncsi-manage.c-225-\tif (!nc)\n--\nnet/ncsi/ncsi-manage.c=301=struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,\n--\nnet/ncsi/ncsi-manage.c-306-\nnet/ncsi/ncsi-manage.c:307:\tnp = kzalloc_obj(*np, GFP_ATOMIC);\nnet/ncsi/ncsi-manage.c-308-\tif (!np)\n--\nnet/ncsi/ncsi-manage.c=1693=int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)\n--\nnet/ncsi/ncsi-manage.c-1727-\nnet/ncsi/ncsi-manage.c:1728:\tvlan = kzalloc_obj(*vlan);\nnet/ncsi/ncsi-manage.c-1729-\tif (!vlan)\n--\nnet/ncsi/ncsi-manage.c=1782=struct ncsi_dev *ncsi_register_dev(struct net_device *dev,\n--\nnet/ncsi/ncsi-manage.c-1797-\t/* Create NCSI device */\nnet/ncsi/ncsi-manage.c:1798:\tndp = kzalloc_obj(*ndp, GFP_ATOMIC);\nnet/ncsi/ncsi-manage.c-1799-\tif (!ndp)\n--\nnet/ncsi/ncsi-rsp.c=787=static int ncsi_rsp_handler_gc(struct ncsi_request *nr)\n--\nnet/ncsi/ncsi-rsp.c-815-\tsize = (rsp-\u003euc_cnt + rsp-\u003emc_cnt + rsp-\u003emixed_cnt) * ETH_ALEN;\nnet/ncsi/ncsi-rsp.c:816:\tnc-\u003emac_filter.addrs = kzalloc(size, GFP_ATOMIC);\nnet/ncsi/ncsi-rsp.c-817-\tif (!nc-\u003emac_filter.addrs)\n"
} |
| 43/3 | 2026/08/30 08:16 | llm | kmsan-evaluator |
3mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 13701 output: 249 thoughts: 982 Thoughts: **NCSI Patch Analysis: KMSAN Determination**
Okay, let's break this down. First, I see that this patch is all about bolstering the NCSI driver's concurrency and memory safety. Allocations are handled using `kzalloc_obj` or `kzalloc`, which is standard practice. The focus here is on protecting data structures (`nc`, `np`, `ndp`) from use-after-free conditions and race conditions arising from device removal during netlink operations or background tasks.
I've examined the code in `ncsi-manage.c` and `ncsi-netlink.c`, specifically looking for uninitialized reads and writes. The checks confirmed proper initialization of variables like `is_last`, `ndp`, and the addition of `rcu_read_lock()`/`unlock()` around critical sections. The use of `call_rcu`, `kfree_rcu`, and associated reference counting (`ncsi_dev_get`, `ncsi_dev_put`) also gives me confidence. All `ndp` instances are either initialized to `NULL` or retrieved via functions that handle reference counting.
The primary bug class this patch addresses is Use-After-Free (UAF) and race conditions when dealing with NCSI device, package, and channel removals. It appears that it does this by converting direct pointer accesses to safer RCU-protected traversals and kref reference counting. The introduction of bugs in reference counting, RCU locking, or work cancellation represents concurrency / use-after-free / lockdep bugs.
Now, the crucial question: Does this patch necessitate KMSAN? Given that KASAN, LOCKDEP, and other standard bug detectors will catch out-of-bounds accesses, use-after-frees, locking issues, and memory corruption, I need to evaluate if there is any risk of uninitialized memory usage or info-leaks.
Considering the guidelines: the patch primarily focuses on synchronization and memory management techniques to prevent UAF and races. There are no changes that introduce or modify kernel structures sent to user space where fields or structure padding might not be fully initialized/zeroed. There's no conditional logic that depends on potentially uninitialized variables or struct fields, nor any new allocation or initialization of complex data structures where uninitialized fields could be read later. Buffer bounds and lengths are not touched in a way that risks reading uninitialized memory. All data structures are properly zeroed or initialized (`= {0}`, `memset`, `kzalloc`).
Therefore, because the patch doesn't introduce any risk of uninitialized memory usage or info-leaks and the bugs that could be introduced are caught by other standard bug detectors, `NeedsKMSAN` should be `false`.
|
| 44/3 | 2026/08/30 08:20 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch refactors memory management and concurrency synchronization for NCSI (Network Controller Sideband Interface) devices, packages, and channels by introducing RCU-protected lists and reference counting (kref) along with deferred RCU frees (call_rcu/kfree_rcu). \n\nThese modifications aim to fix race conditions and use-after-free (UAF) hazards during device unregistration and concurrent netlink operations. All involved structures (such as `struct ncsi_dev_priv`, `struct ncsi_package`, `struct ncsi_channel`) continue to be allocated using `kzalloc_obj` (zero-initialized), and local variables in altered paths are explicitly initialized. No new uninitialized data paths, padding leaks, or uninitialized buffer operations are introduced or exposed. Potential issues arising from these changes (such as lifetime/UAF bugs, RCU locking imbalance, or reference counting bugs) are covered by KASAN and LOCKDEP/PROVE_RCU rather than KMSAN. Thus, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch refactors memory management and concurrency synchronization for NCSI (Network Controller Sideband Interface) devices, packages, and channels by introducing RCU-protected lists and reference counting (kref) along with deferred RCU frees (call_rcu/kfree_rcu). \n\nThese modifications aim to fix race conditions and use-after-free (UAF) hazards during device unregistration and concurrent netlink operations. All involved structures (such as `struct ncsi_dev_priv`, `struct ncsi_package`, `struct ncsi_channel`) continue to be allocated using `kzalloc_obj` (zero-initialized), and local variables in altered paths are explicitly initialized. No new uninitialized data paths, padding leaks, or uninitialized buffer operations are introduced or exposed. Potential issues arising from these changes (such as lifetime/UAF bugs, RCU locking imbalance, or reference counting bugs) are covered by KASAN and LOCKDEP/PROVE_RCU rather than KMSAN. Thus, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|