Adaptec 1737100 Programmer Manual - Page 187

Transmit Completion Interrupt Handling

Page 187 highlights

Sample Driver &CurrentBuffer); } // while (CurrentBuffer) // We've placed all the buffers in this packet into Transmit Buffer // Descriptors. // We're ready to tell the chip to transmit the packet. // Advance the Tx Producer Index causing the chip to transmit the packet out. // The Producer index is incremented by units of 8 bytes. For this example, // we are using a Type 1 descriptor (8 bytes) with an 8 byte skip field. // Therefore, we must increment the producer index by 2 for each buffer // transmitted TxDescQProducerIndexValue.LoPrTxProducerIndex = (CurrentTxDescIndex * sizeof(TransmitBufferDescriptor) / 8; // and write the updated register value back to the chip AIC6915_WRITE_REG(Adapter->RegisterbaseVa->TxDescQueueProducerIndex, TxDescQProducerIndexValue); // Our transmit is complete! Transmit Completion Interrupt Handling After the AIC-6915 has transmitted a packet, it places that packet in the Transmit Completion Descriptor Queue and initiates a TXFRAMECOMPLETE interrupt or a TXDMADONE interrupt. The driver must process this interrupt and return the transmitted packet resource to the operating system. In the code fragment below, we have received a transmit complete interrupt. Example: // Windows NT example // Single Transmit Completion and Buffer Descriptor Queue // 32-bit addressing, 8-byte skip field // Read the Completion QueueProducer and Consumer indices AIC6915_READ_REG(CompletionQueue1ProducerIndex, &CompletionQueue1ProducerReg); AIC6915_READ_REG(CompletionQueue1ConsumerIndex, &CompletionQueue1ConsumerReg); TxComQProducerIndex = CompletionQueue1ProducerReg.b.TxCompletionProducerIndex; TxComQConsumerIndex = CompletionQueue1ConsumerReg.b.TxCompletionConsumerIndex; // Repeat until we've processed all transmit complete entries while ( TxComQConsumerIndex != TxComQProducerIndex ) { // Get the TX Complete entry TxCompletionDesc = Adapter->TxCompletionDesc[TxComQConsumerIndex]; // Get the TX buffer descriptor index from the completion descriptor. 8-27

  • 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-27
Sample Driver
&CurrentBuffer);
} // while (CurrentBuffer)
// We’ve placed all the buffers in this packet into Transmit Buffer
// Descriptors.
// We’re ready to tell the chip to transmit the packet.
// Advance the Tx Producer Index causing the chip to transmit the packet out.
// The Producer index is incremented by units of 8 bytes.
For this example,
// we are using a Type 1 descriptor (8 bytes) with an 8 byte skip field.
// Therefore, we must increment the producer index by 2 for each buffer
// transmitted
TxDescQProducerIndexValue.LoPrTxProducerIndex =
(CurrentTxDescIndex * sizeof(TransmitBufferDescriptor) / 8;
// and write the updated register value back to the chip
AIC6915_WRITE_REG(Adapter->RegisterbaseVa->TxDescQueueProducerIndex,
TxDescQProducerIndexValue);
// Our transmit is complete!
Transmit Completion Interrupt Handling
After the AIC-6915 has transmitted a packet, it places that packet in the Transmit
Completion Descriptor Queue and initiates a
T
X
F
RAME
C
OMPLETE
interrupt or a
T
X
D
MA
D
ONE
interrupt.
The driver must process this interrupt and return the transmitted
packet resource to the operating system.
In the code fragment below, we have received a
transmit complete interrupt.
Example:
// Windows NT example
// Single Transmit Completion and Buffer Descriptor Queue
// 32-bit addressing, 8-byte skip field
// Read the Completion QueueProducer and Consumer indices
AIC6915_READ_REG(CompletionQueue1ProducerIndex,
&CompletionQueue1ProducerReg);
AIC6915_READ_REG(CompletionQueue1ConsumerIndex,
&CompletionQueue1ConsumerReg);
TxComQProducerIndex =
CompletionQueue1ProducerReg.b.TxCompletionProducerIndex;
TxComQConsumerIndex =
CompletionQueue1ConsumerReg.b.TxCompletionConsumerIndex;
// Repeat until we’ve processed all transmit complete entries
while ( TxComQConsumerIndex != TxComQProducerIndex )
{
// Get the TX Complete entry
TxCompletionDesc = Adapter->TxCompletionDesc[TxComQConsumerIndex];
// Get the TX buffer descriptor index from the completion descriptor.