net: mana: Build the PCI transport as a separate module

Build the shared GDMA and Ethernet code as gdma_core.ko, selected by
MICROSOFT_GDMA_CORE. Build the PCI transport separately as mana.ko and
export the required core symbols.

Preserve the PCI module name, device table, and mana.eth/mana.rdma
auxiliary-device names. Each transport registers its own bus driver.

Signed-off-by: Manish Awasthi <mawasthi@linux.microsoft.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Link: https://patch.msgid.link/20260924173054.589291-4-mawasthi@linux.microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Manish Awasthi 2026-09-24 17:30:53 +00:00 committed by Jakub Kicinski
parent 34520ae5dd
commit 445927de07
7 changed files with 36 additions and 31 deletions

View File

@ -15,15 +15,19 @@ config NET_VENDOR_MICROSOFT
if NET_VENDOR_MICROSOFT
config MICROSOFT_GDMA_CORE
tristate
select AUXILIARY_BUS
select DIMLIB
select PAGE_POOL
select NET_SHAPER
config MICROSOFT_MANA
tristate "Microsoft Azure Network Adapter (MANA) support"
depends on PCI_MSI
depends on X86_64 || (ARM64 && !CPU_BIG_ENDIAN)
depends on PCI_HYPERV
select AUXILIARY_BUS
select DIMLIB
select PAGE_POOL
select NET_SHAPER
select MICROSOFT_GDMA_CORE
help
This driver supports Microsoft Azure Network Adapter (MANA).
So far, the driver is only supported on X86_64.

View File

@ -2,4 +2,4 @@
# Makefile for the Microsoft Azure network device driver.
#
obj-$(CONFIG_MICROSOFT_MANA) += mana/
obj-$(CONFIG_MICROSOFT_GDMA_CORE) += mana/

View File

@ -2,6 +2,9 @@
#
# Makefile for the Microsoft Azure Network Adapter driver
obj-$(CONFIG_MICROSOFT_GDMA_CORE) += gdma_core.o
gdma_core-y := gdma_main.o shm_channel.o hw_channel.o mana_en.o mana_ethtool.o \
mana_bpf.o
obj-$(CONFIG_MICROSOFT_MANA) += mana.o
mana-y := gdma_main.o shm_channel.o hw_channel.o mana_en.o mana_ethtool.o mana_bpf.o \
gdma_pci.o
mana-y := gdma_pci.o

View File

@ -1991,6 +1991,7 @@ int mana_gd_setup(struct gdma_context *gc)
dev_err(gc->dev, "%s failed (error %d)\n", __func__, err);
return err;
}
EXPORT_SYMBOL_NS(mana_gd_setup, "NET_MANA");
void mana_gd_cleanup(struct gdma_context *gc)
{
@ -2005,36 +2006,24 @@ void mana_gd_cleanup(struct gdma_context *gc)
dev_dbg(gc->dev, "mana gdma cleanup successful\n");
}
EXPORT_SYMBOL_NS(mana_gd_cleanup, "NET_MANA");
static int __init mana_driver_init(void)
static int __init gdma_core_init(void)
{
int err;
mana_debugfs_root = debugfs_create_dir("mana", NULL);
err = mana_pci_driver_register();
if (err)
goto err_debugfs;
return 0;
err_debugfs:
debugfs_remove(mana_debugfs_root);
mana_debugfs_root = NULL;
return err;
}
static void __exit mana_driver_exit(void)
static void __exit gdma_core_exit(void)
{
mana_pci_driver_unregister();
debugfs_remove(mana_debugfs_root);
mana_debugfs_root = NULL;
}
module_init(mana_driver_init);
module_exit(mana_driver_exit);
module_init(gdma_core_init);
module_exit(gdma_core_exit);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("Microsoft Azure Network Adapter driver");
MODULE_DESCRIPTION("Microsoft Azure Network Adapter GDMA core");

View File

@ -878,7 +878,7 @@ static struct pci_driver mana_driver = {
MODULE_DEVICE_TABLE(pci, mana_id_table);
int mana_pci_driver_register(void)
static int __init mana_driver_init(void)
{
INIT_LIST_HEAD(&mana_dev_recovery_work.dev_list);
spin_lock_init(&mana_dev_recovery_work.lock);
@ -888,7 +888,7 @@ int mana_pci_driver_register(void)
return pci_register_driver(&mana_driver);
}
void mana_pci_driver_unregister(void)
static void __exit mana_driver_exit(void)
{
struct mana_dev_recovery *dev;
unsigned long flags;
@ -907,3 +907,10 @@ void mana_pci_driver_unregister(void)
pci_unregister_driver(&mana_driver);
}
module_init(mana_driver_init);
module_exit(mana_driver_exit);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("Microsoft Azure Network Adapter driver");
MODULE_IMPORT_NS("NET_MANA");

View File

@ -3957,7 +3957,8 @@ static int add_adev(struct gdma_dev *gd, const char *name)
/* madev is owned by the auxiliary device */
madev = NULL;
ret = auxiliary_device_add(adev);
/* Keep the established mana.{eth,rdma} auxiliary match names. */
ret = __auxiliary_device_add(adev, "mana");
if (ret)
goto add_fail;
@ -4194,6 +4195,7 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
return err;
}
EXPORT_SYMBOL_NS(mana_probe, "NET_MANA");
void mana_remove(struct gdma_dev *gd, bool suspending)
{
@ -4272,6 +4274,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
kfree(ac);
dev_dbg(dev, "%s succeeded\n", __func__);
}
EXPORT_SYMBOL_NS(mana_remove, "NET_MANA");
int mana_rdma_probe(struct gdma_dev *gd)
{
@ -4307,6 +4310,7 @@ int mana_rdma_probe(struct gdma_dev *gd)
return err;
}
EXPORT_SYMBOL_NS(mana_rdma_probe, "NET_MANA");
void mana_rdma_remove(struct gdma_dev *gd)
{
@ -4327,6 +4331,7 @@ void mana_rdma_remove(struct gdma_dev *gd)
mana_gd_deregister_device(gd);
}
EXPORT_SYMBOL_NS(mana_rdma_remove, "NET_MANA");
struct net_device *mana_get_primary_netdev(struct mana_context *ac,
u32 port_index,

View File

@ -1175,7 +1175,4 @@ int mana_gd_query_device_cfg(struct gdma_context *gc, u32 proto_major_ver,
u16 *max_num_vports, u8 *bm_hostmode);
int mana_gd_dev_reset(struct gdma_context *gc);
int mana_pci_driver_register(void);
void mana_pci_driver_unregister(void);
#endif /* _GDMA_H */