ReactOS 0.4.16-dev-250-g3ecd236
send.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Intel PRO/1000 Driver
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Sending packets
5 * COPYRIGHT: Copyright 2018 Mark Jansen <mark.jansen@reactos.org>
6 * Copyright 2019 Victor Perevertkin <victor.perevertkin@reactos.org>
7 */
8
9#include "nic.h"
10
11#include <debug.h>
12
13static
16 _In_ PE1000_ADAPTER Adapter,
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
45}
46
50 _In_ NDIS_HANDLE MiniportAdapterContext,
53{
54 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
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"));
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
85}
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
#define MAX_TRACE
Definition: debug.h:16
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static NDIS_STATUS NICTransmitPacket(_In_ PE1000_ADAPTER Adapter, _In_ PHYSICAL_ADDRESS PhysicalAddress, _In_ ULONG Length)
Definition: send.c:15
NDIS_STATUS NTAPI MiniportSend(_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet, _In_ UINT Flags)
Definition: send.c:49
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
struct _E1000_ADAPTER * PE1000_ADAPTER
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_TDESC_CMD_EOP
Definition: e1000hw.h:82
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define E1000_TDESC_CMD_IDE
Definition: e1000hw.h:79
#define E1000_TDESC_CMD_RS
Definition: e1000hw.h:80
#define E1000_TDESC_CMD_IFCS
Definition: e1000hw.h:81
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
unsigned int UINT
Definition: ndis.h:50
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
@ ScatterGatherListPacketInfo
Definition: ndis.h:1183
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define _In_
Definition: no_sal2.h:158
int NDIS_STATUS
Definition: ntddndis.h:475
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
BOOLEAN TxFull
Definition: nic.h:81
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
ULONG CurrentTxDesc
Definition: nic.h:79
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2204