Failed to create multiple NetAdapter on a WDFDevice

Arthman Xu 11 Reputation points
2022-11-07T02:35:32.39+00:00

Hi MS team,

I'm developing the NIC driver for our NIC adapter. Our card hardware has 1 PCIE device but 2 physical network ports.

In this case, we need to create a WDFDEVICE for the PCIE device, and 2 NETADAPTER instances on the WDFDevice to represent the 2 physical ports. I checked the official document and seems this mode is supported.

We are creating these items in the callback "EvtDriverDeviceAdd". We have no problem creating the WDFDEVICE, and the 1st NETADAPTER. But it return error when creating the 2nd NETADAPTER. the errno is "-2147483622" which is "STATUS_NO_MORE_ENTRIES". Is there anything wrong here?

Here is part of the code.
WDFDEVICE wdfDevice;
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WdfDeviceCreate(&deviceInit, &deviceAttributes, &wdfDevice));

DbgPrint("<-- Created WDF Device OK\n");  
  
WdfDeviceSetAlignmentRequirement(wdfDevice, FILE_256_BYTE_ALIGNMENT);  
  
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;  
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleCannotWakeFromS0);  
idleSettings.UserControlOfIdleSettings = IdleAllowUserControl;  
  
GOTO_IF_NOT_NT_SUCCESS(Exit, status,  
    WdfDeviceAssignS0IdleSettings(wdfDevice, &idleSettings));  
  
pf = RtGetDeviceContext(wdfDevice);  
  
DbgBreakPoint();  
  
  
for (int i = 0; i < MAX_NFP_PORT; i++) {  
    adapterInit = NetAdapterInitAllocate(wdfDevice);  
  
    GOTO_WITH_INSUFFICIENT_RESOURCES_IF_NULL(Exit, status, adapterInit);  
  
    NET_ADAPTER_DATAPATH_CALLBACKS datapathCallbacks;  
    NET_ADAPTER_DATAPATH_CALLBACKS_INIT(  
        &datapathCallbacks,  
        EvtAdapterCreateTxQueue,  
        EvtAdapterCreateRxQueue);  
  
    NetAdapterInitSetDatapathCallbacks(  
        adapterInit,  
        &datapathCallbacks);  
  
    WDF_OBJECT_ATTRIBUTES adapterAttributes;  
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&adapterAttributes, NFP_NET_ADAPTER);  
  
    NETADAPTER netAdapter;  
    GOTO_IF_NOT_NT_SUCCESS(Exit, status,  
        NetAdapterCreate(adapterInit, &adapterAttributes, &netAdapter));  
  
    DbgPrint("<-- Created NetAdapter %d OK\n", i);  
  
    NFP_NET_ADAPTER* adapter = RtGetAdapterContext(netAdapter);  
  
  
    adapter->pf = pf;  
  
    GOTO_IF_NOT_NT_SUCCESS(Exit, status,  
        RtInitializeAdapterContext(adapter, wdfDevice, netAdapter));  
  
    pf->Adapters[i] = adapter;  
    NetAdapterInitFree(adapterInit);  
    adapterInit = nullptr;  
}  
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,538 questions
0 comments No comments
{count} votes