ReactOS  0.4.15-dev-4574-g434cf85
send.c File Reference
#include "nic.h"
#include <debug.h>
Include dependency graph for send.c:

Go to the source code of this file.

Functions

static NDIS_STATUS NICTransmitPacket (_In_ PE1000_ADAPTER Adapter, _In_ PHYSICAL_ADDRESS PhysicalAddress, _In_ ULONG Length)
 
NDIS_STATUS NTAPI MiniportSend (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet, _In_ UINT Flags)
 

Function Documentation

◆ MiniportSend()

NDIS_STATUS NTAPI MiniportSend ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ PNDIS_PACKET  Packet,
_In_ UINT  Flags 
)

Definition at line 49 of file send.c.

53 {
54  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
55  PSCATTER_GATHER_LIST sgList;
56  ULONG TransmitLength;
57  PHYSICAL_ADDRESS TransmitBuffer;
59 
61 
62  ASSERT(sgList != NULL);
63  ASSERT(sgList->NumberOfElements == 1);
64  ASSERT((sgList->Elements[0].Address.LowPart & 3) == 0);
65  ASSERT(sgList->Elements[0].Length <= MAXIMUM_FRAME_SIZE);
66 
67  if (Adapter->TxFull)
68  {
69  NDIS_DbgPrint(MIN_TRACE, ("All TX descriptors are full\n"));
70  return NDIS_STATUS_RESOURCES;
71  }
72 
73  TransmitLength = sgList->Elements[0].Length;
74  TransmitBuffer = sgList->Elements[0].Address;
75  Adapter->TransmitPackets[Adapter->CurrentTxDesc] = Packet;
76 
77  Status = NICTransmitPacket(Adapter, TransmitBuffer, TransmitLength);
79  {
80  NDIS_DbgPrint(MIN_TRACE, ("Transmit packet failed\n"));
81  return Status;
82  }
83 
84  return NDIS_STATUS_PENDING;
85 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
struct _E1000_ADAPTER * PE1000_ADAPTER
int NDIS_STATUS
Definition: ntddndis.h:475
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
BOOLEAN TxFull
Definition: nic.h:81
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
ULONG CurrentTxDesc
Definition: nic.h:79
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2204
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
static NDIS_STATUS NICTransmitPacket(_In_ PE1000_ADAPTER Adapter, _In_ PHYSICAL_ADDRESS PhysicalAddress, _In_ ULONG Length)
Definition: send.c:15
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351

◆ NICTransmitPacket()

static NDIS_STATUS NICTransmitPacket ( _In_ PE1000_ADAPTER  Adapter,
_In_ PHYSICAL_ADDRESS  PhysicalAddress,
_In_ ULONG  Length 
)
static

Definition at line 15 of file send.c.

19 {
20  volatile PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptor;
21 
22  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
23 
24  TransmitDescriptor = Adapter->TransmitDescriptors + Adapter->CurrentTxDesc;
25  TransmitDescriptor->Address = PhysicalAddress.QuadPart;
26  TransmitDescriptor->Length = Length;
27  TransmitDescriptor->ChecksumOffset = 0;
28  TransmitDescriptor->Command = E1000_TDESC_CMD_RS | E1000_TDESC_CMD_IFCS |
30  TransmitDescriptor->Status = 0;
31  TransmitDescriptor->ChecksumStartField = 0;
32  TransmitDescriptor->Special = 0;
33 
34  Adapter->CurrentTxDesc = (Adapter->CurrentTxDesc + 1) % NUM_TRANSMIT_DESCRIPTORS;
35 
36  E1000WriteUlong(Adapter, E1000_REG_TDT, Adapter->CurrentTxDesc);
37 
38  if (Adapter->CurrentTxDesc == Adapter->LastTxDesc)
39  {
40  NDIS_DbgPrint(MID_TRACE, ("All TX descriptors are full now\n"));
41  Adapter->TxFull = TRUE;
42  }
43 
44  return NDIS_STATUS_SUCCESS;
45 }
#define MID_TRACE
Definition: debug.h:15
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define E1000_TDESC_CMD_IDE
Definition: e1000hw.h:79
#define TRUE
Definition: types.h:120
#define E1000_TDESC_CMD_RS
Definition: e1000hw.h:80
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
#define E1000_TDESC_CMD_EOP
Definition: e1000hw.h:82
#define E1000_TDESC_CMD_IFCS
Definition: e1000hw.h:81
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by MiniportSend().