ReactOS 0.4.15-dev-8146-gdc0ed6d
ParaNdis5-Oid.c File Reference
#include "ParaNdis5.h"
#include "ParaNdis-Oid.h"
Include dependency graph for ParaNdis5-Oid.c:

Go to the source code of this file.

Macros

#define OIDENTRY(oid, el, xfl, xokl, flags)   { oid, el, xfl, xokl, flags, NULL }
 
#define OIDENTRYPROC(oid, el, xfl, xokl, flags, setproc)   { oid, el, xfl, xokl, flags, setproc }
 

Functions

static NDIS_STATUS OnOidSetNdis5Offload (PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
 
static NDIS_STATUS CreateOffloadInfo5ForQuery (PARANDIS_ADAPTER *pContext, tOidDesc *pOid, PVOID *ppInfo, PULONG pulSize)
 
static NDIS_STATUS CreateOffloadInfo5Internal (PARANDIS_ADAPTER *pContext, PVOID *ppInfo, PULONG pulSize, PCCHAR reason, NDIS_TASK_OFFLOAD_HEADER *pHeader)
 
void ParaNdis_GetSupportedOid (PVOID *pOidsArray, PULONG pLength)
 
static NDIS_STATUS ParaNdis_OidQuery (PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
 
NDIS_STATUS NTAPI ParaNdis5_QueryOID (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
 
NDIS_STATUS NTAPI ParaNdis5_SetOID (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
 
static void NTAPI OnSetPowerWorkItem (NDIS_WORK_ITEM *pWorkItem, PVOID Context)
 
NDIS_STATUS ParaNdis_OnSetPower (PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
 
static BOOLEAN IsValidPcs (PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_IP_CHECKSUM *pcs)
 
static BOOLEAN IsValidPls (PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_LARGE_SEND *pls)
 
static NDIS_STATUS ParseOffloadTask (PARANDIS_ADAPTER *pContext, BOOLEAN bApply, NDIS_TASK_OFFLOAD *pto, ULONG offset, ULONG maxSize)
 
static FORCEINLINE BOOLEAN ValidateOffloadHeader (NDIS_TASK_OFFLOAD_HEADER *pth)
 
static NDIS_STATUS ParseOffload (PARANDIS_ADAPTER *pContext, NDIS_TASK_OFFLOAD_HEADER *pth, ULONG size, BOOLEAN bApply, PCCHAR reason, BOOLEAN headerOnly)
 
static BOOLEAN GetTcpIpCheckSumCapabilities (PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_IP_CHECKSUM *pcs)
 
static BOOLEAN GetLargeSendCapabilities (PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_LARGE_SEND *pls)
 

Variables

static NDIS_TASK_OFFLOAD_HEADER ReservedHeader
 
static NDIS_OID SupportedOids []
 
static const tOidWhatToDo OidsDB []
 

Macro Definition Documentation

◆ OIDENTRY

#define OIDENTRY (   oid,
  el,
  xfl,
  xokl,
  flags 
)    { oid, el, xfl, xokl, flags, NULL }

Definition at line 37 of file ParaNdis5-Oid.c.

◆ OIDENTRYPROC

#define OIDENTRYPROC (   oid,
  el,
  xfl,
  xokl,
  flags,
  setproc 
)    { oid, el, xfl, xokl, flags, setproc }

Definition at line 39 of file ParaNdis5-Oid.c.

Function Documentation

◆ CreateOffloadInfo5ForQuery()

NDIS_STATUS CreateOffloadInfo5ForQuery ( PARANDIS_ADAPTER pContext,
tOidDesc pOid,
PVOID ppInfo,
PULONG  pulSize 
)
static

Definition at line 745 of file ParaNdis5-Oid.c.

750{
753 *ppInfo = NULL;
754 *pulSize = 0;
755 if (pOid->InformationBufferLength < sizeof(*pth)) pth = &ReservedHeader;
756 status = ParseOffload(pContext, pth, pOid->InformationBufferLength, FALSE, "query enter", TRUE);
758 {
759 CreateOffloadInfo5Internal(pContext, ppInfo, pulSize, "QUERY", pth);
760 }
761 return status;
762}
static NDIS_TASK_OFFLOAD_HEADER ReservedHeader
Definition: ParaNdis5-Oid.c:42
static NDIS_STATUS CreateOffloadInfo5Internal(PARANDIS_ADAPTER *pContext, PVOID *ppInfo, PULONG pulSize, PCCHAR reason, NDIS_TASK_OFFLOAD_HEADER *pHeader)
static NDIS_STATUS ParseOffload(PARANDIS_ADAPTER *pContext, NDIS_TASK_OFFLOAD_HEADER *pth, ULONG size, BOOLEAN bApply, PCCHAR reason, BOOLEAN headerOnly)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
if(dx< 0)
Definition: linetemp.h:194
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
int NDIS_STATUS
Definition: ntddndis.h:475
PVOID InformationBuffer
Definition: ParaNdis-Oid.h:42
UINT InformationBufferLength
Definition: ParaNdis-Oid.h:43
Definition: ps.c:97
_Check_return_ _Out_ PULONG pulSize
Definition: winddi.h:2120

Referenced by ParaNdis_OidQuery().

◆ CreateOffloadInfo5Internal()

NDIS_STATUS CreateOffloadInfo5Internal ( PARANDIS_ADAPTER pContext,
PVOID ppInfo,
PULONG  pulSize,
PCCHAR  reason,
NDIS_TASK_OFFLOAD_HEADER pHeader 
)
static

Definition at line 661 of file ParaNdis5-Oid.c.

667{
669 ULONG size =
673 *ppInfo = ParaNdis_AllocateMemory(pContext, size);
674 if (*ppInfo)
675 {
676 ULONG flags = 0;
679 flags |= GetTcpIpCheckSumCapabilities(pContext, &cs) ? 2 : 0;
680 flags |= GetLargeSendCapabilities(pContext, &lso) ? 1 : 0;
681 if (flags)
682 {
685 UINT i = 0;
686 ULONG *pOffset;
687 PVOID base;
688 *pulSize = size;
689 NdisZeroMemory(*ppInfo, size);
690 ph = (NDIS_TASK_OFFLOAD_HEADER *)*ppInfo;
691 *ph = *pHeader;
692 pto = (NDIS_TASK_OFFLOAD *)(ph + 1);
693 base = ph;
694 pOffset = &ph->OffsetFirstTask;
695 ph->OffsetFirstTask = 0;
696 do
697 {
698 if (flags & (1 << i))
699 {
700 flags &= ~(1 << i);
702 pto->Size = sizeof(*pto);
703 *pOffset = RtlPointerToOffset(base, pto);
704 base = pto;
705 pOffset = &pto->OffsetNextTask;
706 switch(i)
707 {
708 case 1:
709 {
712 pto->TaskBufferLength = sizeof(*pcs);
713 NdisMoveMemory(pcs, &cs, sizeof(cs));
714 pto = (NDIS_TASK_OFFLOAD *)(pcs + 1);
715 break;
716 }
717 case 0:
718 {
721 pto->TaskBufferLength = sizeof(*pls);
722 NdisMoveMemory(pls, &lso, sizeof(lso));
723 pto = (NDIS_TASK_OFFLOAD *)(pls + 1);
724 break;
725 }
726 default:
727 break;
728 }
729 }
730 ++i;
731 } while (flags);
732 status = ParseOffload(pContext, ph, size, FALSE, reason, FALSE);
733 }
734 else
735 {
736 NdisFreeMemory(*ppInfo, 0, 0);
737 *ppInfo = NULL;
739 }
740 }
741 return status;
742}
static BOOLEAN GetLargeSendCapabilities(PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_LARGE_SEND *pls)
static BOOLEAN GetTcpIpCheckSumCapabilities(PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_IP_CHECKSUM *pcs)
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
VOID EXPORT NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxContextHeader * pHeader
Definition: handleapi.cpp:604
#define cs
Definition: i386-dis.c:442
PVOID ParaNdis_AllocateMemory(PARANDIS_ADAPTER *pContext, ULONG ulRequiredSize)
#define RtlPointerToOffset(Base, Pointer)
Definition: ndis56common.h:54
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
unsigned int UINT
Definition: ndis.h:50
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_TASK_OFFLOAD_VERSION
Definition: ndis.h:1388
struct _NDIS_TASK_TCP_IP_CHECKSUM NDIS_TASK_TCP_IP_CHECKSUM
struct _NDIS_TASK_OFFLOAD_HEADER NDIS_TASK_OFFLOAD_HEADER
@ TcpIpChecksumNdisTask
Definition: ndis.h:1200
@ TcpLargeSendNdisTask
Definition: ndis.h:1202
struct _NDIS_TASK_TCP_LARGE_SEND NDIS_TASK_TCP_LARGE_SEND
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
ULONG TaskBufferLength
Definition: ndis.h:1237
ULONG OffsetNextTask
Definition: ndis.h:1236
UCHAR TaskBuffer[1]
Definition: ndis.h:1238
NDIS_TASK Task
Definition: ndis.h:1235
uint32_t ULONG
Definition: typedefs.h:59

Referenced by CreateOffloadInfo5ForQuery(), and OnOidSetNdis5Offload().

◆ GetLargeSendCapabilities()

static BOOLEAN GetLargeSendCapabilities ( PARANDIS_ADAPTER pContext,
NDIS_TASK_TCP_LARGE_SEND pls 
)
static

Definition at line 641 of file ParaNdis5-Oid.c.

644{
646 NdisZeroMemory(pls, sizeof(*pls));
649 pls->IpOptions = !!f.fTxLsoIP;
650 pls->TcpOptions = !!f.fTxLsoTCP;
652 pls->MaxOffLoadSize = pContext->Offload.maxPacketSize;
653 return f.fTxLso != 0;
654}
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
void ParaNdis_ResetOffloadSettings(PARANDIS_ADAPTER *pContext, tOffloadSettingsFlags *pDest, PULONG from)
#define PARANDIS_MIN_LSO_SEGMENTS
Definition: ndis56common.h:124
#define NDIS_TASK_TCP_LARGE_SEND_V0
Definition: ndis.h:1270
tOffloadSettings Offload
Definition: ndis56common.h:470

Referenced by CreateOffloadInfo5Internal().

◆ GetTcpIpCheckSumCapabilities()

static BOOLEAN GetTcpIpCheckSumCapabilities ( PARANDIS_ADAPTER pContext,
NDIS_TASK_TCP_IP_CHECKSUM pcs 
)
static

Definition at line 611 of file ParaNdis5-Oid.c.

614{
616 NdisZeroMemory(pcs, sizeof(*pcs));
618 pcs->V4Transmit.IpChecksum = !!f.fTxIPChecksum;
619 pcs->V4Transmit.TcpChecksum = !!f.fTxTCPChecksum;
620 pcs->V4Transmit.UdpChecksum = !!f.fTxUDPChecksum;
621 pcs->V4Transmit.IpOptionsSupported = !!f.fTxIPOptions;
622 pcs->V4Transmit.TcpOptionsSupported = !!f.fTxTCPOptions;
623 pcs->V4Receive.IpChecksum = !!f.fRxIPChecksum;
624 pcs->V4Receive.IpOptionsSupported = !!f.fRxIPOptions;
625 pcs->V4Receive.TcpChecksum = !!f.fRxTCPChecksum;
626 pcs->V4Receive.TcpOptionsSupported = !!f.fRxTCPOptions;
627 pcs->V4Receive.UdpChecksum = !!f.fRxUDPChecksum;
628
629 return
630 pcs->V4Transmit.IpChecksum ||
631 pcs->V4Transmit.TcpChecksum ||
632 pcs->V4Transmit.UdpChecksum ||
633 pcs->V4Receive.IpChecksum ||
634 pcs->V4Receive.TcpChecksum ||
635 pcs->V4Receive.UdpChecksum;
636}
struct _NDIS_TASK_TCP_IP_CHECKSUM::@2112 V4Transmit
struct _NDIS_TASK_TCP_IP_CHECKSUM::@2113 V4Receive

Referenced by CreateOffloadInfo5Internal().

◆ IsValidPcs()

static BOOLEAN IsValidPcs ( PARANDIS_ADAPTER pContext,
NDIS_TASK_TCP_IP_CHECKSUM pcs 
)
static

Definition at line 408 of file ParaNdis5-Oid.c.

409{
411 BOOLEAN bInvalid = FALSE;
413 bInvalid |= pcs->V4Receive.IpChecksum && !f.fRxIPChecksum;
414 bInvalid |= pcs->V4Receive.IpOptionsSupported && !f.fRxIPOptions;
415 bInvalid |= pcs->V4Receive.TcpChecksum && !f.fRxTCPChecksum;
416 bInvalid |= pcs->V4Receive.TcpOptionsSupported && !f.fRxTCPOptions;
417 bInvalid |= pcs->V4Receive.UdpChecksum && !f.fRxUDPChecksum;
418
419 bInvalid |= pcs->V4Transmit.IpChecksum && !f.fTxIPChecksum;
420 bInvalid |= pcs->V4Transmit.IpOptionsSupported && !f.fTxIPOptions;
421 bInvalid |= pcs->V4Transmit.TcpChecksum && !f.fTxTCPChecksum;
422 bInvalid |= pcs->V4Transmit.TcpOptionsSupported && !f.fTxTCPOptions;
423 bInvalid |= pcs->V4Transmit.UdpChecksum && !f.fTxUDPChecksum;
424 return !bInvalid;
425}
unsigned char BOOLEAN

Referenced by ParseOffloadTask().

◆ IsValidPls()

static BOOLEAN IsValidPls ( PARANDIS_ADAPTER pContext,
NDIS_TASK_TCP_LARGE_SEND pls 
)
static

Definition at line 431 of file ParaNdis5-Oid.c.

432{
434 BOOLEAN bInvalid = FALSE;
436 bInvalid |= pls->Version != NDIS_TASK_TCP_LARGE_SEND_V0;
437 bInvalid |= pls->IpOptions && !f.fTxLsoIP;
438 bInvalid |= pls->TcpOptions && !f.fTxLsoTCP;
439 bInvalid |= (pls->IpOptions || pls->TcpOptions || pls->MaxOffLoadSize) && !f.fTxLso;
441 return !bInvalid;
442}

Referenced by ParseOffloadTask().

◆ OnOidSetNdis5Offload()

NDIS_STATUS OnOidSetNdis5Offload ( PARANDIS_ADAPTER pContext,
tOidDesc pOid 
)
static

Definition at line 764 of file ParaNdis5-Oid.c.

765{
768 pOid->InformationBufferLength, TRUE, "SET", FALSE);
769 if (status == STATUS_SUCCESS)
770 {
771#if 0 // only for logging after SET
772 PVOID pInfo = NULL;
773 ULONG dummy = 0;
774 CreateOffloadInfo5Internal(pContext, &pInfo, &dummy, "UPDATED", &ReservedHeader);
775 if (pInfo) NdisFreeMemory(pInfo, 0, 0);
776#endif
777 *pOid->pBytesRead = pOid->InformationBufferLength;
778 }
779 else
780 {
781 DPrintf(0, ("[%s], restoring after unsuccessful set", __FUNCTION__));
782 pContext->Offload = pContext->Offload;
783 }
784 return status;
785}
#define __FUNCTION__
Definition: types.h:116
#define DPrintf(Level, Fmt)
Definition: kdebugprint.h:61
#define STATUS_SUCCESS
Definition: shellext.h:65
PUINT pBytesRead
Definition: ParaNdis-Oid.h:46

◆ OnSetPowerWorkItem()

static void NTAPI OnSetPowerWorkItem ( NDIS_WORK_ITEM pWorkItem,
PVOID  Context 
)
static

Definition at line 357 of file ParaNdis5-Oid.c.

358{
360 tPowerWorkItem *pwi = (tPowerWorkItem *)pWorkItem;
361 PARANDIS_ADAPTER *pContext = pwi->pContext;
363 {
364 status = ParaNdis_PowerOn(pContext);
365 }
366 else
367 {
368 ParaNdis_PowerOff(pContext);
369 }
370 NdisFreeMemory(pwi, 0, 0);
373}
@ hopOidRequest
Definition: DebugData.h:63
NDIS_STATUS ParaNdis_PowerOn(PARANDIS_ADAPTER *pContext)
VOID ParaNdis_PowerOff(PARANDIS_ADAPTER *pContext)
static void FORCEINLINE ParaNdis_DebugHistory(PARANDIS_ADAPTER *pContext, eHistoryLogOperation op, PVOID pParam1, ULONG lParam2, ULONG lParam3, ULONG lParam4)
Definition: ndis56common.h:647
#define NdisMSetInformationComplete(MiniportAdapterHandle, Status)
Definition: ndis.h:5762
@ NetDeviceStateD0
Definition: netpnp.h:7
#define OID_PNP_SET_POWER
Definition: ntddndis.h:361
enum _NDIS_DEVICE_POWER_STATE NDIS_DEVICE_POWER_STATE
NDIS_HANDLE MiniportHandle
Definition: ndis56common.h:349
PPARANDIS_ADAPTER pContext
Definition: ParaNdis5.h:78
NDIS_DEVICE_POWER_STATE state
Definition: ParaNdis5.h:79

Referenced by ParaNdis_OnSetPower().

◆ ParaNdis5_QueryOID()

NDIS_STATUS NTAPI ParaNdis5_QueryOID ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesWritten,
OUT PULONG  BytesNeeded 
)

Definition at line 261 of file ParaNdis5-Oid.c.

267{
269 tOidWhatToDo Rules;
270 PARANDIS_ADAPTER *pContext = (PARANDIS_ADAPTER *)MiniportAdapterContext;
271 tOidDesc _oid;
273 _oid.ulToDoFlags = Rules.Flags;
274 *BytesWritten = 0;
275 *BytesNeeded = 0;
276 ParaNdis_DebugHistory(pContext, hopOidRequest, NULL, Oid, 0, 1);
277 DPrintf(Rules.nEntryLevel, ("[%s], id 0x%X(%s) of %d", __FUNCTION__,
278 Oid,
279 Rules.name,
280 InformationBufferLength));
281 _oid.Oid = Oid;
282 _oid.InformationBuffer = InformationBuffer;
283 _oid.InformationBufferLength = InformationBufferLength;
284 _oid.pBytesNeeded = (PUINT)BytesNeeded;
288 else if (Rules.Flags & ohfQuery) status = ParaNdis_OidQuery(pContext, &_oid);
289
290
291 ParaNdis_DebugHistory(pContext, hopOidRequest, NULL, Oid, status, 0);
293 ("[%s] , id 0x%X(%s) (%X), written %d, needed %d",
295 Rules.oid,
296 Rules.name,
297 status,
299 *BytesNeeded));
300 return status;
301
302}
void ParaNdis_GetOidSupportRules(NDIS_OID oid, tOidWhatToDo *pRule, const tOidWhatToDo *Table)
Definition: ParaNdis-Oid.c:661
@ ohfQuery
Definition: ParaNdis-Oid.h:65
static const tOidWhatToDo OidsDB[]
static NDIS_STATUS ParaNdis_OidQuery(PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
unsigned int * PUINT
Definition: ndis.h:50
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
PUINT pBytesNeeded
Definition: ParaNdis-Oid.h:45
ULONG ulToDoFlags
Definition: ParaNdis-Oid.h:41
PUINT pBytesWritten
Definition: ParaNdis-Oid.h:44
NDIS_OID Oid
Definition: ParaNdis-Oid.h:40
const char * name
Definition: ParaNdis-Oid.h:60
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by DriverEntry().

◆ ParaNdis5_SetOID()

NDIS_STATUS NTAPI ParaNdis5_SetOID ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesRead,
OUT PULONG  BytesNeeded 
)

Definition at line 311 of file ParaNdis5-Oid.c.

317{
319 tOidWhatToDo Rules;
320 PARANDIS_ADAPTER *pContext = (PARANDIS_ADAPTER *)MiniportAdapterContext;
321 tOidDesc _oid;
323 _oid.ulToDoFlags = Rules.Flags;
324 *BytesRead = 0;
325 *BytesNeeded = 0;
326 ParaNdis_DebugHistory(pContext, hopOidRequest, NULL, Oid, 1, 1);
327 DPrintf(Rules.nEntryLevel, ("[%s], id 0x%X(%s) of %d", __FUNCTION__,
328 Oid,
329 Rules.name,
330 InformationBufferLength));
331 _oid.Oid = Oid;
332 _oid.InformationBuffer = InformationBuffer;
333 _oid.InformationBufferLength = InformationBufferLength;
334 _oid.pBytesNeeded = (PUINT)BytesNeeded;
335 _oid.pBytesRead = (PUINT)BytesRead;
338 else if (Rules.Flags & ohfSet)
339 {
340 if (Rules.OidSetProc) status = Rules.OidSetProc(pContext, &_oid);
341 else
342 {
343 DPrintf(0, ("[%s] ERROR in OID redirection table", __FUNCTION__));
345 }
346 }
347 ParaNdis_DebugHistory(pContext, hopOidRequest, NULL, Oid, status, 0);
349 {
351 ("[%s] , id 0x%X(%s) (%X), read %d, needed %d", __FUNCTION__,
352 Rules.oid, Rules.name, status, *BytesRead, *BytesNeeded));
353 }
354 return status;
355}
@ ohfSet
Definition: ParaNdis-Oid.h:66
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
#define NDIS_STATUS_INVALID_OID
Definition: ndis.h:488
OIDHANDLERPROC OidSetProc
Definition: ParaNdis-Oid.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by DriverEntry().

◆ ParaNdis_GetSupportedOid()

void ParaNdis_GetSupportedOid ( PVOID pOidsArray,
PULONG  pLength 
)

Definition at line 207 of file ParaNdis5-Oid.c.

208{
209 *pOidsArray = SupportedOids;
210 *pLength = sizeof(SupportedOids);
211}
static NDIS_OID SupportedOids[]
Definition: ParaNdis5-Oid.c:52

Referenced by ParaNdis_OidQueryCommon().

◆ ParaNdis_OidQuery()

static NDIS_STATUS ParaNdis_OidQuery ( PARANDIS_ADAPTER pContext,
tOidDesc pOid 
)
static

Definition at line 217 of file ParaNdis5-Oid.c.

218{
220 BOOLEAN bFreeInfo = FALSE;
221 PVOID pInfo = NULL;
222 ULONG ulSize = 0;
223 ULONG ulLinkSpeed = 0;
224
225 switch(pOid->Oid)
226 {
228 status = CreateOffloadInfo5ForQuery(pContext, pOid, &pInfo, &ulSize);
229 bFreeInfo = pInfo != NULL;
230 break;
232 {
233 /* units are 100 bps */
234 ulLinkSpeed = (ULONG)(PARANDIS_FORMAL_LINK_SPEED / 100);
235 pInfo = &ulLinkSpeed;
236 ulSize = sizeof(ulLinkSpeed);
238 }
239 break;
240 default:
241 return ParaNdis_OidQueryCommon(pContext, pOid);
242 }
244 {
245 status = ParaNdis_OidQueryCopy(pOid, pInfo, ulSize, bFreeInfo);
246 }
247 else if (bFreeInfo)
248 {
249 NdisFreeMemory(pInfo, 0, 0);
250 }
251 return status;
252}
NDIS_STATUS ParaNdis_OidQueryCopy(tOidDesc *pOid, PVOID pInfo, ULONG ulSize, BOOLEAN bFreeInfo)
Definition: ParaNdis-Oid.c:178
NDIS_STATUS ParaNdis_OidQueryCommon(PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
Definition: ParaNdis-Oid.c:225
static NDIS_STATUS CreateOffloadInfo5ForQuery(PARANDIS_ADAPTER *pContext, tOidDesc *pOid, PVOID *ppInfo, PULONG pulSize)
#define PARANDIS_FORMAL_LINK_SPEED
Definition: ndis56common.h:121
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_TCP_TASK_OFFLOAD
Definition: ntddndis.h:377

Referenced by ParaNdis5_QueryOID().

◆ ParaNdis_OnSetPower()

NDIS_STATUS ParaNdis_OnSetPower ( PARANDIS_ADAPTER pContext,
tOidDesc pOid 
)

Definition at line 378 of file ParaNdis5-Oid.c.

379{
382 DEBUG_ENTRY(0);
383 status = ParaNdis_OidSetCopy(pOid, &newState, sizeof(newState));
385 {
386 tPowerWorkItem *pwi = ParaNdis_AllocateMemory(pContext, sizeof(tPowerWorkItem));
388 if (pwi)
389 {
390 pwi->pContext = pContext;
391 pwi->state = newState;
394 {
396 }
397 else
398 NdisFreeMemory(pwi, 0, 0);
399 }
400 }
401 return status;
402}
NDIS_STATUS ParaNdis_OidSetCopy(tOidDesc *pOid, PVOID pDest, ULONG ulSize)
Definition: ParaNdis-Oid.c:66
static void NTAPI OnSetPowerWorkItem(NDIS_WORK_ITEM *pWorkItem, PVOID Context)
#define DEBUG_ENTRY(level)
Definition: kdebugprint.h:49
NDIS_STATUS EXPORT NdisScheduleWorkItem(IN PNDIS_WORK_ITEM pWorkItem)
Definition: misc.c:467
#define NdisInitializeWorkItem(_WI_, _R_, _C_)
Definition: ndis.h:3197
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
NDIS_WORK_ITEM wi
Definition: ParaNdis5.h:77

◆ ParseOffload()

static NDIS_STATUS ParseOffload ( PARANDIS_ADAPTER pContext,
NDIS_TASK_OFFLOAD_HEADER pth,
ULONG  size,
BOOLEAN  bApply,
PCCHAR  reason,
BOOLEAN  headerOnly 
)
static

Definition at line 556 of file ParaNdis5-Oid.c.

563{
565 BOOLEAN bReset = FALSE;
566 ULONG ulNoCapabilities = 0;
567 DPrintf(0, ("[%s](%s), format %d", __FUNCTION__, reason,
569 if (ValidateOffloadHeader(pth))
570 {
571 PUCHAR p = (PUCHAR)pth;
574 DPrintf(0, ("[%s], header version %d, ip header at %d, fixed %d, first at %d", __FUNCTION__,
575 pth->Version,
577 pth->EncapsulationFormat.Flags.FixedHeaderSize,
578 offset));
579 if (!offset && bApply)
580 {
581 /* disable all the capabilities */
582 // according to DDK, 0 at first task offset means disabling all the capabilities
583 DPrintf(0, ("[%s] RESETTING offload capabilities", __FUNCTION__));
584 ParaNdis_ResetOffloadSettings(pContext, NULL, &ulNoCapabilities);
585 bReset = TRUE;
586 }
587 while (!headerOnly && offset > 0 && (offset + sizeof(NDIS_TASK_OFFLOAD)) < size)
588 {
591 {
592 DPrintf(0, ("[%s], unexpected TO version %d at %d",
593 __FUNCTION__, pto->Version, offset));
595 break;
596 }
597 status = ParseOffloadTask(pContext, bApply, pto, offset, size);
599 break;
600 offset += pto->OffsetNextTask;
601 }
602 }
603 if (status == STATUS_SUCCESS && bApply)
605 return status;
606}
static FORCEINLINE BOOLEAN ValidateOffloadHeader(NDIS_TASK_OFFLOAD_HEADER *pth)
static NDIS_STATUS ParseOffloadTask(PARANDIS_ADAPTER *pContext, BOOLEAN bApply, NDIS_TASK_OFFLOAD *pto, ULONG offset, ULONG maxSize)
GLfloat GLfloat p
Definition: glext.h:8902
GLintptr offset
Definition: glext.h:5920
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
long LONG
Definition: pedump.c:60
struct _NDIS_ENCAPSULATION_FORMAT::@2111 Flags
NDIS_ENCAPSULATION Encapsulation
Definition: ndis.h:1216
NDIS_ENCAPSULATION_FORMAT EncapsulationFormat
Definition: ndis.h:1229
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by CreateOffloadInfo5ForQuery(), CreateOffloadInfo5Internal(), and OnOidSetNdis5Offload().

◆ ParseOffloadTask()

static NDIS_STATUS ParseOffloadTask ( PARANDIS_ADAPTER pContext,
BOOLEAN  bApply,
NDIS_TASK_OFFLOAD pto,
ULONG  offset,
ULONG  maxSize 
)
static

Definition at line 444 of file ParaNdis5-Oid.c.

450{
454 NDIS_TASK_IPSEC *pips = NULL;
455 LPCSTR sName = NULL;
456 ULONG TaskBufferSize = 0, tailOffset = 0;
457 switch(pto->Task)
458 {
461 TaskBufferSize = sizeof(*pcs);
462 sName = "TcpIpChecksumNdisTask";
463 break;
466 TaskBufferSize = sizeof(*pls);
467 sName = "TcpLargeSendNdisTask";
468 break;
469 case IpSecNdisTask:
470 pips = (NDIS_TASK_IPSEC *)pto->TaskBuffer;
471 TaskBufferSize = sizeof(*pips);
472 sName = "IpSecNdisTask";
473 break;
474 default:
475 break;
476 }
477 tailOffset = offset + RtlPointerToOffset(pto, &pto->TaskBuffer) + TaskBufferSize;
478 if (!TaskBufferSize)
479 {
480 DPrintf(0, ("[%s], unknown offload task %d", __FUNCTION__, pto->Task));
481 }
482 else if (tailOffset > maxSize)
483 {
484 DPrintf(0, ("[%s], can not parse %s at offset %d, tail at %d", __FUNCTION__, sName, offset, tailOffset));
486 }
487 else if (TaskBufferSize > pto->TaskBufferLength)
488 {
489 DPrintf(0, ("[%s], invalid size of %s", __FUNCTION__, sName));
491 }
492 else if (pcs)
493 {
494 DPrintf(0, ("[%s], parsing %s", __FUNCTION__, sName));
495 DPrintf(0, ("Rx4: checksum IP(%d),TCP(%d),UDP(%d), options IP(%d),TCP(%d)",
496 pcs->V4Receive.IpChecksum, pcs->V4Receive.TcpChecksum, pcs->V4Receive.UdpChecksum,
497 pcs->V4Receive.IpOptionsSupported, pcs->V4Receive.TcpOptionsSupported
498 ));
499 DPrintf(0, ("Tx4: checksum IP(%d),TCP(%d),UDP(%d), options IP(%d),TCP(%d)",
500 pcs->V4Transmit.IpChecksum, pcs->V4Transmit.TcpChecksum, pcs->V4Transmit.UdpChecksum,
501 pcs->V4Transmit.IpOptionsSupported, pcs->V4Transmit.TcpOptionsSupported
502 ));
503 if (bApply)
504 {
505 if (IsValidPcs(pContext, pcs))
506 {
507 tOffloadSettingsFlags *pf = &pContext->Offload.flags;
508 pf->fTxIPChecksum = !!pcs->V4Transmit.IpChecksum;
509 pf->fTxTCPChecksum = !!pcs->V4Transmit.TcpChecksum;
510 pf->fTxUDPChecksum = !!pcs->V4Transmit.UdpChecksum;
511 pf->fTxTCPOptions = !!pcs->V4Transmit.TcpOptionsSupported;
512 pf->fTxIPOptions = !!pcs->V4Transmit.IpOptionsSupported;
513 pf->fRxIPChecksum = !!pcs->V4Receive.IpChecksum;
514 pf->fRxIPOptions = !!pcs->V4Receive.IpOptionsSupported;
515 pf->fRxTCPChecksum = !!pcs->V4Receive.TcpChecksum;
516 pf->fRxTCPOptions = !!pcs->V4Receive.TcpOptionsSupported;
517 pf->fRxUDPChecksum = !!pcs->V4Receive.UdpChecksum;
518 }
519 else
521 }
522 }
523 else if (pls)
524 {
525 DPrintf(0, ("[%s], parsing %s version %d", __FUNCTION__, sName, pls->Version));
526 DPrintf(0, ("options IP(%d),TCP(%d),MaxOffload %d, MinSegments %d",
527 pls->IpOptions, pls->TcpOptions, pls->MaxOffLoadSize, pls->MinSegmentCount));
528 if (bApply)
529 {
530 if (IsValidPls(pContext, pls))
531 {
532 tOffloadSettingsFlags *pf = &pContext->Offload.flags;
533 pf->fTxLsoIP = !!pls->IpOptions;
534 pf->fTxLsoTCP = !!pls->TcpOptions;
535 pf->fTxLso = 1;
536 }
537 else
539 }
540 }
541 else if (pips)
542 {
543 DPrintf(0, ("[%s], parsing %s", __FUNCTION__, sName));
544 }
545 return status;
546}
static BOOLEAN IsValidPcs(PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_IP_CHECKSUM *pcs)
static BOOLEAN IsValidPls(PARANDIS_ADAPTER *pContext, NDIS_TASK_TCP_LARGE_SEND *pls)
@ IpSecNdisTask
Definition: ndis.h:1201
#define NDIS_STATUS_BUFFER_TOO_SHORT
Definition: ndis.h:487
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
tOffloadSettingsFlags flags
Definition: ndis56common.h:237
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by ParseOffload().

◆ ValidateOffloadHeader()

static FORCEINLINE BOOLEAN ValidateOffloadHeader ( NDIS_TASK_OFFLOAD_HEADER pth)
static

Definition at line 548 of file ParaNdis5-Oid.c.

549{
550 return
553 pth->Size == sizeof(*pth);
554}
@ IEEE_802_3_Encapsulation
Definition: ndis.h:1209

Referenced by ParseOffload().

Variable Documentation

◆ OidsDB

const tOidWhatToDo OidsDB[]
static

Definition at line 115 of file ParaNdis5-Oid.c.

Referenced by ParaNdis5_QueryOID(), and ParaNdis5_SetOID().

◆ ReservedHeader

NDIS_TASK_OFFLOAD_HEADER ReservedHeader
static
Initial value:

Definition at line 42 of file ParaNdis5-Oid.c.

Referenced by CreateOffloadInfo5ForQuery(), and OnOidSetNdis5Offload().

◆ SupportedOids

NDIS_OID SupportedOids[]
static

Definition at line 52 of file ParaNdis5-Oid.c.

Referenced by ParaNdis_GetSupportedOid().