📄 mp_req.c
字号:
/*++
Copyright (c) 1999 Microsoft Corporation
Module Name:
mp_req.c
Abstract:
This module contains miniport OID related handlers
Revision History:
Who When What
-------- -------- ----------------------------------------------
DChen 11-01-99 created
Notes:
--*/
#include "precomp.h"
#include "e100_wmi.h"
#if DBG
#define _FILENUMBER 'QERM'
#endif
#if OFFLOAD
//
// This miniport only supports one Encapsultion type: IEEE_802_3_Encapsulation
// one task version: NDIS_TASK_OFFLOAD_VERSION. Modify the code below OID_TCP_
// TASK_OFFLOAD in query and setting information functions to make it support
// more than one encapsulation type and task version
//
// Define the task offload the miniport currently supports.
// This miniport only supports two kinds of offload tasks:
// TCP/IP checksum offload and Segmentation large TCP packet offload
// Later if it can supports more tasks, just redefine this task array
//
NDIS_TASK_OFFLOAD OffloadTasks[] = {
{
NDIS_TASK_OFFLOAD_VERSION,
sizeof(NDIS_TASK_OFFLOAD),
TcpIpChecksumNdisTask,
0,
sizeof(NDIS_TASK_TCP_IP_CHECKSUM)
},
{
NDIS_TASK_OFFLOAD_VERSION,
sizeof(NDIS_TASK_OFFLOAD),
TcpLargeSendNdisTask,
0,
sizeof(NDIS_TASK_TCP_LARGE_SEND)
}
};
//
// Get the number of offload tasks this miniport supports
//
ULONG OffloadTasksCount = sizeof(OffloadTasks) / sizeof(OffloadTasks[0]);
//
// Specify TCP/IP checksum offload task, the miniport can only supports, for now,
// TCP checksum and IP checksum on the sending side, also it supports TCP and IP
// options
//
NDIS_TASK_TCP_IP_CHECKSUM TcpIpChecksumTask = {
{1, 1, 1, 0, 1},
{0, 0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};
//
// Specify Large Send offload task, the miniport supports TCP options and IP options,
// and the minimum segment count the protocol can offload is 1. At this point, we
// cannot specify the maximum offload size(here is 0), because it depends on the size
// of shared memory and the number of TCB used by the driver.
//
NDIS_TASK_TCP_LARGE_SEND TcpLargeSendTask = {
0, //Currently the version is set to 0, later it may change
0,
1,
TRUE,
TRUE
};
#endif // OFFLOAD
ULONG VendorDriverVersion = NIC_VENDOR_DRIVER_VERSION;
NDIS_OID NICSupportedOids[] =
{
OID_GEN_SUPPORTED_LIST,
OID_GEN_HARDWARE_STATUS,
OID_GEN_MEDIA_SUPPORTED,
OID_GEN_MEDIA_IN_USE,
OID_GEN_MAXIMUM_LOOKAHEAD,
OID_GEN_MAXIMUM_FRAME_SIZE,
OID_GEN_LINK_SPEED,
OID_GEN_TRANSMIT_BUFFER_SPACE,
OID_GEN_RECEIVE_BUFFER_SPACE,
OID_GEN_TRANSMIT_BLOCK_SIZE,
OID_GEN_RECEIVE_BLOCK_SIZE,
OID_GEN_VENDOR_ID,
OID_GEN_VENDOR_DESCRIPTION,
OID_GEN_VENDOR_DRIVER_VERSION,
OID_GEN_CURRENT_PACKET_FILTER,
OID_GEN_CURRENT_LOOKAHEAD,
OID_GEN_DRIVER_VERSION,
OID_GEN_MAXIMUM_TOTAL_SIZE,
OID_GEN_MAC_OPTIONS,
OID_GEN_MEDIA_CONNECT_STATUS,
OID_GEN_MAXIMUM_SEND_PACKETS,
OID_GEN_SUPPORTED_GUIDS,
OID_GEN_XMIT_OK,
OID_GEN_RCV_OK,
OID_GEN_XMIT_ERROR,
OID_GEN_RCV_ERROR,
OID_GEN_RCV_NO_BUFFER,
OID_GEN_RCV_CRC_ERROR,
OID_GEN_TRANSMIT_QUEUE_LENGTH,
OID_802_3_PERMANENT_ADDRESS,
OID_802_3_CURRENT_ADDRESS,
OID_802_3_MULTICAST_LIST,
OID_802_3_MAXIMUM_LIST_SIZE,
OID_802_3_RCV_ERROR_ALIGNMENT,
OID_802_3_XMIT_ONE_COLLISION,
OID_802_3_XMIT_MORE_COLLISIONS,
OID_802_3_XMIT_DEFERRED,
OID_802_3_XMIT_MAX_COLLISIONS,
OID_802_3_RCV_OVERRUN,
OID_802_3_XMIT_UNDERRUN,
OID_802_3_XMIT_HEARTBEAT_FAILURE,
OID_802_3_XMIT_TIMES_CRS_LOST,
OID_802_3_XMIT_LATE_COLLISIONS,
#if !BUILD_W2K
OID_GEN_PHYSICAL_MEDIUM,
#endif
#if OFFLOAD
OID_TCP_TASK_OFFLOAD,
#endif
/* powermanagement */
OID_PNP_CAPABILITIES,
OID_PNP_SET_POWER,
OID_PNP_QUERY_POWER,
OID_PNP_ADD_WAKE_UP_PATTERN,
OID_PNP_REMOVE_WAKE_UP_PATTERN,
OID_PNP_ENABLE_WAKE_UP,
/* custom oid WMI support */
OID_CUSTOM_DRIVER_SET,
OID_CUSTOM_DRIVER_QUERY,
OID_CUSTOM_ARRAY,
OID_CUSTOM_STRING
};
//
// WMI support
// check out the e100.mof file for examples of how the below
// maps into a .mof file for external advertisement of GUIDs
//
#define NIC_NUM_CUSTOM_GUIDS 4
//
// Define the following values to demonstrate that the driver should
// always validat the content in the information buffer whether the OID
// is for set or query
//
#define CUSTOM_DRIVER_SET_MIN 0x1
#define CUSTOM_DRIVER_SET_MAX 0xFFFFFF
#if BUILD_W2K
static const NDIS_GUID NICGuidList[NIC_NUM_CUSTOM_GUIDS] = {
{ // {F4A80276-23B7-11d1-9ED9-00A0C9010057} example of a uint set
E100BExampleSetUINT_OIDGuid,
OID_CUSTOM_DRIVER_SET,
sizeof(ULONG),
(fNDIS_GUID_TO_OID )
},
{ // {F4A80277-23B7-11d1-9ED9-00A0C9010057} example of a uint query
E100BExampleQueryUINT_OIDGuid,
OID_CUSTOM_DRIVER_QUERY,
sizeof(ULONG),
(fNDIS_GUID_TO_OID)
},
{ // {F4A80278-23B7-11d1-9ED9-00A0C9010057} example of an array query
E100BExampleQueryArrayOIDGuid,
OID_CUSTOM_ARRAY,
sizeof(UCHAR), // size is size of each element in the array
(fNDIS_GUID_TO_OID|fNDIS_GUID_ARRAY )
},
{ // {F4A80279-23B7-11d1-9ED9-00A0C9010057} example of a string query
E100BExampleQueryStringOIDGuid,
OID_CUSTOM_STRING,
(ULONG) -1, // size is -1 for ANSI or NDIS_STRING string types
(fNDIS_GUID_TO_OID|fNDIS_GUID_ANSI_STRING)
}
};
#else
//
// Support for the fNDIS_GUID_ALLOW_READ flag has been added in WinXP for
// both 5.0 and 5.1 miniports
//
static const NDIS_GUID NICGuidList[NIC_NUM_CUSTOM_GUIDS] = {
{ // {F4A80276-23B7-11d1-9ED9-00A0C9010057} example of a uint set
E100BExampleSetUINT_OIDGuid,
OID_CUSTOM_DRIVER_SET,
sizeof(ULONG),
// Not setting fNDIS_GUID_ALLOW_WRITE flag means that we don't allow
// users without administrator privilege to set this value, but we do
// allow any user to query this value
(fNDIS_GUID_TO_OID | fNDIS_GUID_ALLOW_READ)
},
{ // {F4A80277-23B7-11d1-9ED9-00A0C9010057} example of a uint query
E100BExampleQueryUINT_OIDGuid,
OID_CUSTOM_DRIVER_QUERY,
sizeof(ULONG),
// setting fNDIS_GUID_ALLOW_READ flag means that we allow any
// user to query this value.
(fNDIS_GUID_TO_OID | fNDIS_GUID_ALLOW_READ)
},
{ // {F4A80278-23B7-11d1-9ED9-00A0C9010057} example of an array query
E100BExampleQueryArrayOIDGuid,
OID_CUSTOM_ARRAY,
sizeof(UCHAR), // size is size of each element in the array
// setting fNDIS_GUID_ALLOW_READ flag means that we allow any
// user to query this value.
(fNDIS_GUID_TO_OID|fNDIS_GUID_ARRAY | fNDIS_GUID_ALLOW_READ)
},
{ // {F4A80279-23B7-11d1-9ED9-00A0C9010057} example of a string query
E100BExampleQueryStringOIDGuid,
OID_CUSTOM_STRING,
(ULONG) -1, // size is -1 for ANSI or NDIS_STRING string types
// setting fNDIS_GUID_ALLOW_READ flag means that we allow any
// user to query this value.
(fNDIS_GUID_TO_OID|fNDIS_GUID_ANSI_STRING | fNDIS_GUID_ALLOW_READ)
}
};
#endif
/**
Local Prototypes
**/
NDIS_STATUS
MPSetPower(
PMP_ADAPTER Adapter,
NDIS_DEVICE_POWER_STATE PowerState
);
VOID
MPFillPoMgmtCaps (
IN PMP_ADAPTER Adapter,
IN OUT PNDIS_PNP_CAPABILITIES pPower_Management_Capabilities,
IN OUT PNDIS_STATUS pStatus,
IN OUT PULONG pulInfoLen
);
NDIS_STATUS
MPAddWakeUpPattern(
IN PMP_ADAPTER pAdapter,
IN PVOID InformationBuffer,
IN UINT InformationBufferLength,
IN OUT PULONG BytesRead,
IN OUT PULONG BytesNeeded
);
NDIS_STATUS
MPRemoveWakeUpPattern(
IN PMP_ADAPTER pAdapter,
IN PVOID InformationBuffer,
IN UINT InformationBufferLength,
OUT PULONG BytesRead,
OUT PULONG BytesNeeded
);
BOOLEAN
MPAreTwoPatternsEqual(
IN PNDIS_PM_PACKET_PATTERN pNdisPattern1,
IN PNDIS_PM_PACKET_PATTERN pNdisPattern2
);
//
// Macros used to walk a doubly linked list. Only macros that are not defined in ndis.h
// The List Next macro will work on Single and Doubly linked list as Flink is a common
// field name in both
//
/*
PLIST_ENTRY
ListNext (
IN PLIST_ENTRY
);
PSINGLE_LIST_ENTRY
ListNext (
IN PSINGLE_LIST_ENTRY
);
*/
#define ListNext(_pL) (_pL)->Flink
/*
PLIST_ENTRY
ListPrev (
IN LIST_ENTRY *
);
*/
#define ListPrev(_pL) (_pL)->Blink
__inline
BOOLEAN
MPIsPoMgmtSupported(
IN PMP_ADAPTER pAdapter
)
{
if (pAdapter->RevsionID >= E100_82559_A_STEP &&
pAdapter->RevsionID <= E100_82559_C_STEP )
{
return TRUE;
}
else
{
return FALSE;
}
}
NDIS_STATUS MPQueryInformation(
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesWritten,
OUT PULONG BytesNeeded
)
/*++
Routine Description:
MiniportQueryInformation handler
Arguments:
MiniportAdapterContext Pointer to the adapter structure
Oid Oid for this query
InformationBuffer Buffer for information
InformationBufferLength Size of this buffer
BytesWritten Specifies how much info is written
BytesNeeded In case the buffer is smaller than what we need, tell them how much is needed
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_NOT_SUPPORTED
NDIS_STATUS_BUFFER_TOO_SHORT
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PMP_ADAPTER Adapter;
NDIS_HARDWARE_STATUS HardwareStatus = NdisHardwareStatusReady;
NDIS_MEDIUM Medium = NIC_MEDIA_TYPE;
UCHAR VendorDesc[] = NIC_VENDOR_DESC;
NDIS_PNP_CAPABILITIES Power_Management_Capabilities;
ULONG ulInfo = 0;
ULONG64 ul64Info = 0;
USHORT usInfo = 0;
PVOID pInfo = (PVOID) &ulInfo;
ULONG ulInfoLen = sizeof(ulInfo);
ULONG ulBytesAvailable = ulInfoLen;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -