drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c- Extension
.c- Size
- 73546 bytes
- Lines
- 2594
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool.hnet/flow_offload.hnet/vxlan.hhclge_fd.hhclge_main.h
Detected Declarations
function hclge_sync_fd_statefunction hclge_fd_inc_rule_cntfunction hclge_fd_dec_rule_cntfunction hclge_fd_free_nodefunction hclge_update_fd_rule_nodefunction hlist_for_each_entry_safefunction hclge_fd_insert_rule_nodefunction hclge_fd_set_user_def_cmdfunction hclge_sync_fd_user_def_cfgfunction hclge_fd_check_user_def_refcntfunction hclge_fd_inc_user_def_refcntfunction hclge_fd_dec_user_def_refcntfunction hclge_update_fd_listfunction hclge_get_fd_modefunction hclge_get_fd_allocationfunction hclge_set_fd_key_configfunction hclge_fd_disable_user_deffunction hclge_init_fd_configfunction hclge_fd_tcam_configfunction hclge_fd_ad_configfunction hclge_fd_convert_tuplefunction hclge_fd_convert_meta_datafunction hclge_config_keyfunction hclge_config_actionfunction hclge_fd_check_tcpip4_tuplefunction hclge_fd_check_ip4_tuplefunction hclge_fd_check_tcpip6_tuplefunction hclge_fd_check_ip6_tuplefunction hclge_fd_check_ether_tuplefunction hclge_fd_check_ext_tuplefunction hclge_fd_get_user_def_layerfunction hclge_fd_is_user_def_all_maskedfunction hclge_fd_parse_user_def_fieldfunction hclge_fd_check_specfunction hclge_fd_get_tcpip4_tuplefunction hclge_fd_get_ip4_tuplefunction hclge_fd_get_tcpip6_tuplefunction hclge_fd_get_ip6_tuplefunction hclge_fd_get_ether_tuplefunction hclge_fd_get_user_def_tuplefunction hclge_fd_get_tuplefunction hclge_fd_config_rulefunction hclge_add_fd_entry_commonfunction hclge_is_cls_flower_activefunction hclge_fd_parse_ring_cookiefunction hclge_add_fd_entryfunction hclge_del_fd_entryfunction hclge_clear_fd_rules_in_list
Annotated Snippet
if (old_rule->state == HCLGE_FD_TO_ADD) {
hclge_fd_dec_rule_cnt(hdev, old_rule->location);
hclge_fd_free_node(hdev, old_rule);
return;
}
old_rule->state = HCLGE_FD_TO_DEL;
break;
}
}
static struct hclge_fd_rule *hclge_find_fd_rule(struct hlist_head *hlist,
u16 location,
struct hclge_fd_rule **parent)
{
struct hclge_fd_rule *rule;
struct hlist_node *node;
hlist_for_each_entry_safe(rule, node, hlist, rule_node) {
if (rule->location == location)
return rule;
else if (rule->location > location)
return NULL;
/* record the parent node, use to keep the nodes in fd_rule_list
* in ascend order.
*/
*parent = rule;
}
return NULL;
}
/* insert fd rule node in ascend order according to rule->location */
static void hclge_fd_insert_rule_node(struct hlist_head *hlist,
struct hclge_fd_rule *rule,
struct hclge_fd_rule *parent)
{
INIT_HLIST_NODE(&rule->rule_node);
if (parent)
hlist_add_behind(&rule->rule_node, &parent->rule_node);
else
hlist_add_head(&rule->rule_node, hlist);
}
static int hclge_fd_set_user_def_cmd(struct hclge_dev *hdev,
struct hclge_fd_user_def_cfg *cfg)
{
struct hclge_fd_user_def_cfg_cmd *req;
struct hclge_desc desc;
u16 data = 0;
int ret;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_USER_DEF_OP, false);
req = (struct hclge_fd_user_def_cfg_cmd *)desc.data;
hnae3_set_bit(data, HCLGE_FD_USER_DEF_EN_B, cfg[0].ref_cnt > 0);
hnae3_set_field(data, HCLGE_FD_USER_DEF_OFT_M,
HCLGE_FD_USER_DEF_OFT_S, cfg[0].offset);
req->ol2_cfg = cpu_to_le16(data);
data = 0;
hnae3_set_bit(data, HCLGE_FD_USER_DEF_EN_B, cfg[1].ref_cnt > 0);
hnae3_set_field(data, HCLGE_FD_USER_DEF_OFT_M,
HCLGE_FD_USER_DEF_OFT_S, cfg[1].offset);
req->ol3_cfg = cpu_to_le16(data);
data = 0;
hnae3_set_bit(data, HCLGE_FD_USER_DEF_EN_B, cfg[2].ref_cnt > 0);
hnae3_set_field(data, HCLGE_FD_USER_DEF_OFT_M,
HCLGE_FD_USER_DEF_OFT_S, cfg[2].offset);
req->ol4_cfg = cpu_to_le16(data);
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret)
dev_err(&hdev->pdev->dev,
"failed to set fd user def data, ret= %d\n", ret);
return ret;
}
static void hclge_sync_fd_user_def_cfg(struct hclge_dev *hdev, bool locked)
{
int ret;
if (!test_and_clear_bit(HCLGE_STATE_FD_USER_DEF_CHANGED, &hdev->state))
return;
if (!locked)
spin_lock_bh(&hdev->fd_rule_lock);
Annotation
- Immediate include surface: `linux/ethtool.h`, `net/flow_offload.h`, `net/vxlan.h`, `hclge_fd.h`, `hclge_main.h`.
- Detected declarations: `function hclge_sync_fd_state`, `function hclge_fd_inc_rule_cnt`, `function hclge_fd_dec_rule_cnt`, `function hclge_fd_free_node`, `function hclge_update_fd_rule_node`, `function hlist_for_each_entry_safe`, `function hclge_fd_insert_rule_node`, `function hclge_fd_set_user_def_cmd`, `function hclge_sync_fd_user_def_cfg`, `function hclge_fd_check_user_def_refcnt`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.