Adaptec 1737100 Programmer Manual - Page 185

Transmit Handling

Page 185 highlights

Sample Driver Transmit Handling In the code fragment below, the operating system has called the transmit routine with a packet to be transmitted. The driver must set up the Transmit Buffer Descriptor(s) for all buffers in this packet, and then instruct the AIC-6915 controller to transmit the packet. Example: // Windows NT driver example // Type 1 Transmit Buffer Descriptor // Single Transmit Buffer Descriptor Queue (low priority) // 8 byte skip field // Assume the operating system has notified us that we are to transmit // "Packet" // Read in the current producer index register AIC6915_READ_REG(Adapter->RegisterBaseVa->TxDescQProducerIndex, &TxDescQProducerIndexValue); // Pull the current descriptor index out of the producer index. The producer // index points to the next entry in the descriptor queue in units of 8 // bytes.In this example, we are using // Type 1 descriptors with an 8 byte skip field. The descriptor size is // therefore 16 bytes. In // units of 8 bytes, each descriptor is indexed by 2. CurrentTxDescIndex = (TxDescQProducerIndexValue.LoPrTxProducerIndex * 8) / sizeof(TransmitBufferDescriptor); // Get the first buffer in this packet // This is an operating system-specific call NdisQueryPacket( Packet, &PhysicalSegmentCount, &NdisBufferCount, &CurrentBuffer, &TotalDataLength); FirstBuffer = TRUE; // Figure out if we will need to roll the queue for this packet if (CurrentTxDescIndex+PhysicalSegmentCount >=AIC6915_NUMBER_0F_TxDESC-1) Rollover = TRUE; // Loop over all buffers in this packet. Use one Transmit Buffer per packet // buffer. // while (CurrentBuffer) { // This example utilizes map registers to translate the logical address // into a physical buffer address // Get the physical address segments for the current buffer NdisMStartBufferPhysicalMapping( Adapter->MiniportAdapterHandle, CurrentBuffer, 8-25

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190

8-25
Sample Driver
Transmit Handling
In the code fragment below, the operating system has called the transmit routine with a
packet to be transmitted.
The driver must set up the Transmit Buffer Descriptor(s) for all
buffers in this packet, and then instruct the AIC-6915 controller to transmit the packet.
Example:
// Windows NT driver example
// Type 1 Transmit Buffer Descriptor
// Single Transmit Buffer Descriptor Queue (low priority)
// 8 byte skip field
// Assume the operating system has notified us that we are to transmit
// “Packet”
// Read in the current producer index register
AIC6915_READ_REG(Adapter->RegisterBaseVa->TxDescQProducerIndex,
&TxDescQProducerIndexValue);
// Pull the current descriptor index out of the producer index.
The producer
// index points to the next entry in the descriptor queue in units of 8
// bytes.In this example, we are using
// Type 1 descriptors with an 8 byte skip field.
The descriptor size is
// therefore 16 bytes.
In
// units of
8 bytes, each descriptor is indexed by 2.
CurrentTxDescIndex = (TxDescQProducerIndexValue.LoPrTxProducerIndex * 8) /
sizeof(TransmitBufferDescriptor);
// Get the first buffer in this packet
// This is an operating system-specific call
NdisQueryPacket(
Packet,
&PhysicalSegmentCount,
&NdisBufferCount,
&CurrentBuffer,
&TotalDataLength);
FirstBuffer = TRUE;
// Figure out if we will need to roll the queue for this packet
if (CurrentTxDescIndex+PhysicalSegmentCount >=AIC6915_NUMBER_0F_TxDESC-1)
Rollover = TRUE;
// Loop over all buffers in this packet.
Use one Transmit Buffer per packet
// buffer.
// while (CurrentBuffer)
{
// This example utilizes map registers to translate the logical address
// into a physical buffer address
// Get the physical address segments for the current buffer
NdisMStartBufferPhysicalMapping(
Adapter->MiniportAdapterHandle,
CurrentBuffer,