drivers/net/ethernet/hisilicon/hns3/hnae3.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns3/hnae3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns3/hnae3.c- Extension
.c- Size
- 10097 bytes
- Lines
- 411
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/spinlock.hhnae3.h
Detected Declarations
function hnae3_unregister_ae_algo_preparefunction list_for_each_entryfunction hnae3_acquire_unload_lockfunction hnae3_release_unload_lockfunction hnae3_client_matchfunction hnae3_set_client_init_flagfunction hnae3_get_client_init_flagfunction hnae3_init_client_instancefunction hnae3_get_bitfunction hnae3_uninit_client_instancefunction hnae3_register_clientfunction hnae3_unregister_clientfunction hnae3_register_ae_algofunction list_for_each_entryfunction hnae3_unregister_ae_algofunction hnae3_register_ae_devfunction hnae3_unregister_ae_devexport hnae3_unregister_ae_algo_prepareexport hnae3_acquire_unload_lockexport hnae3_release_unload_lockexport hnae3_set_client_init_flagexport hnae3_register_clientexport hnae3_unregister_clientexport hnae3_register_ae_algoexport hnae3_unregister_ae_algoexport hnae3_register_ae_devexport hnae3_unregister_ae_dev
Annotated Snippet
if (IS_ENABLED(CONFIG_PCI_IOV)) {
device_lock(&ae_dev->pdev->dev);
pci_disable_sriov(ae_dev->pdev);
device_unlock(&ae_dev->pdev->dev);
}
}
}
EXPORT_SYMBOL(hnae3_unregister_ae_algo_prepare);
/* we are keeping things simple and using single lock for all the
* list. This is a non-critical code so other updations, if happen
* in parallel, can wait.
*/
static DEFINE_MUTEX(hnae3_common_lock);
/* ensure the drivers being unloaded one by one */
static DEFINE_MUTEX(hnae3_unload_lock);
void hnae3_acquire_unload_lock(void)
{
mutex_lock(&hnae3_unload_lock);
}
EXPORT_SYMBOL(hnae3_acquire_unload_lock);
void hnae3_release_unload_lock(void)
{
mutex_unlock(&hnae3_unload_lock);
}
EXPORT_SYMBOL(hnae3_release_unload_lock);
static bool hnae3_client_match(enum hnae3_client_type client_type)
{
if (client_type == HNAE3_CLIENT_KNIC ||
client_type == HNAE3_CLIENT_ROCE)
return true;
return false;
}
void hnae3_set_client_init_flag(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev,
unsigned int inited)
{
if (!client || !ae_dev)
return;
switch (client->type) {
case HNAE3_CLIENT_KNIC:
hnae3_set_bit(ae_dev->flag, HNAE3_KNIC_CLIENT_INITED_B, inited);
break;
case HNAE3_CLIENT_ROCE:
hnae3_set_bit(ae_dev->flag, HNAE3_ROCE_CLIENT_INITED_B, inited);
break;
default:
break;
}
}
EXPORT_SYMBOL(hnae3_set_client_init_flag);
static int hnae3_get_client_init_flag(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev)
{
int inited = 0;
switch (client->type) {
case HNAE3_CLIENT_KNIC:
inited = hnae3_get_bit(ae_dev->flag,
HNAE3_KNIC_CLIENT_INITED_B);
break;
case HNAE3_CLIENT_ROCE:
inited = hnae3_get_bit(ae_dev->flag,
HNAE3_ROCE_CLIENT_INITED_B);
break;
default:
break;
}
return inited;
}
static int hnae3_init_client_instance(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev)
{
int ret;
/* check if this client matches the type of ae_dev */
if (!(hnae3_client_match(client->type) &&
hnae3_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {
return 0;
}
Annotation
- Immediate include surface: `linux/list.h`, `linux/spinlock.h`, `hnae3.h`.
- Detected declarations: `function hnae3_unregister_ae_algo_prepare`, `function list_for_each_entry`, `function hnae3_acquire_unload_lock`, `function hnae3_release_unload_lock`, `function hnae3_client_match`, `function hnae3_set_client_init_flag`, `function hnae3_get_client_init_flag`, `function hnae3_init_client_instance`, `function hnae3_get_bit`, `function hnae3_uninit_client_instance`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- 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.