📄 3c90x.c
字号:
(PUSHORT)&compatability);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_INITIALIZE((
"GetAdapterProperties: compatability read failed\n"));
return NIC_STATUS_FAILURE;
}
//
// Check the Failure level.
//
if (compatability.FailureLevel > EEPROM_COMPATABILITY_LEVEL) {
DBGPRINT_ERROR((
"GetAdapterProperties: Incompatible level\n"));
DBGPRINT_INITIALIZE((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
//
// Check the warning level.
//
if (compatability.WarningLevel > EEPROM_COMPATABILITY_LEVEL) {
DBGPRINT_ERROR((
"GetAdapterProperties: Wrong down compatability level\n"
));
}
//
// ----------------- Read the software information 1 -------
//
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_SOFTWARE_INFORMATION_1,
(PUSHORT)&information1);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_INITIALIZE((
"GetAdapterProperties: EEPROM s/w info1 read failed\n"));
return NIC_STATUS_FAILURE;
}
if (information1.LinkBeatDisable) {
DBGPRINT_INITIALIZE(("s/w information1 - Link beat disable\n"));
pAdapter->Hardware.LinkBeatDisable = TRUE;
}
if (pAdapter->Hardware.DuplexCommandOverride == FALSE) {
if (information1.FullDuplexMode) {
DBGPRINT_INITIALIZE(("s/w information1 - Full duplex enable\n"));
pAdapter->Hardware.FullDuplexEnable = TRUE;
}
else {
DBGPRINT_INITIALIZE(("s/w information 1 - Full duplex disabled\n"));
pAdapter->Hardware.FullDuplexEnable = FALSE;
}
}
switch (information1.OptimizeFor) {
case EEPROM_OPTIMIZE_FOR_THROUGHPUT:
DBGPRINT_INITIALIZE(("sw info1 - optimize throughput\n"));
pAdapter->Hardware.OptimizeForThroughput = TRUE;
break;
case EEPROM_OPTIMIZE_FOR_CPU:
DBGPRINT_INITIALIZE(("s/w info1 - optimize CPU\n"));
pAdapter->Hardware.OptimizeForCPU = TRUE;
break;
case EEPROM_OPTIMIZE_NORMAL:
DBGPRINT_INITIALIZE(("s/w info1 - optimize Normal\n"));
pAdapter->Hardware.OptimizeNormal = TRUE;
break;
default:
DBGPRINT_ERROR((
"GetAdapterProperties: Wrong optimization level\n"));
return NIC_STATUS_FAILURE;
break;
}
// ----------------- Read the capabilities information -----
//
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_CAPABILITIES_WORD,
(PUSHORT)&capabilities
);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_INITIALIZE((
"GetAdapterProprties: EEPROM s/w capabilities read failed\n"));
return NIC_STATUS_FAILURE;
}
if (capabilities.SupportsPowerManagement) {
DBGPRINT_INITIALIZE(("Adapter supports power management\n"));
pAdapter->Hardware.SupportsPowerManagement = TRUE;
}
//
// ----------------- Read the software information 2 -------
//
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_SOFTWARE_INFORMATION_2,
(PUSHORT)&information2);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"GetAdapterProperties: ReadEEPROM , SWINFO2 failed\n"));
DBGPRINT_INITIALIZE((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
if (information2.BroadcastRxErrDone){
DBGPRINT_INITIALIZE(("Adapter has BroadcastRxErrDone\n"));
pAdapter->Hardware.BroadcastErrDone = TRUE;
}
if (information2.MWIErrDone) {
DBGPRINT_INITIALIZE(("Adapter has MWIErrDone\n"));
pAdapter->Hardware.MWIErrDone = TRUE;
}
if (information2.WOLConnectorPresent){
DBGPRINT_INITIALIZE(("WOL is connected\n"));
pAdapter->Hardware.WOLConnectorPresent = TRUE;
}
if (information2.AutoResetToD0) {
DBGPRINT_INITIALIZE(("Auto reset to D0 bit on\n"));
pAdapter->Hardware.AutoResetToD0 = TRUE;
}
//
// ----------------- Read the OEM station address ----------
//
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_OEM_NODE_ADDRESS_WORD_0,
&eepromValue);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"GetAdapterProperties: EEPROM read word 0 failed\n"));
DBGPRINT_INITIALIZE((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
pAdapter->PermanentAddress[0] = HIBYTE(eepromValue);
pAdapter->PermanentAddress[1] = LOBYTE(eepromValue);
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_OEM_NODE_ADDRESS_WORD_1,
&eepromValue);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"GetAdapterProperties: EEPROM read word 1 failed\n"));
DBGPRINT_INITIALIZE((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
pAdapter->PermanentAddress[2] = HIBYTE(eepromValue);
pAdapter->PermanentAddress[3] = LOBYTE(eepromValue);
nicStatus = tc90x_ReadEEPROM(
pAdapter,
EEPROM_OEM_NODE_ADDRESS_WORD_2,
&eepromValue);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"GetAdapterProperties: EEPROM read word 2 failed\n"));
DBGPRINT_INITIALIZE((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
pAdapter->PermanentAddress[4] = HIBYTE(eepromValue);
pAdapter->PermanentAddress[5] = LOBYTE(eepromValue);
//
// If the station address has not been overriden, fill the permanent
// address into it.
//
value = pAdapter->StationAddress[0] |
pAdapter->StationAddress[1] |
pAdapter->StationAddress[2] |
pAdapter->StationAddress[3] |
pAdapter->StationAddress[4] |
pAdapter->StationAddress[5];
//
// If the station address has not been overriden, set this value
// in the station address.
//
if (!value) {
for (index=0; index < 6; index++)
pAdapter->StationAddress[index] =
pAdapter->PermanentAddress[index];
}
for (index=0; index < 6; index++)
device->dev_addr[index] = pAdapter->StationAddress[index];
DBGPRINT_FUNCTION(("GetAdapterProperties: OUT \n"));
return NIC_STATUS_SUCCESS;
}
/*++
Routine Name:
tc90x_BasicInitializeAdapter.
Routine Description:
This routine does the basic initialize of the adapter. It does
not set the media specific stuff.
Arguments:
MiniportAdapterContext - Pointer to the adapter structure.
Return Value:
NIC_STATUS_SUCCESS if the initialization succeeds.
NIC_STATUS_FAILUTE if the initialization fails.
--*/
NIC_STATUS
tc90x_BasicInitializeAdapter(
IN PNIC_INFORMATION Adapter
)
{
PNIC_INFORMATION pAdapter = Adapter;
USHORT stationTemp, macControl;
NIC_STATUS nicStatus;
DBGPRINT_FUNCTION(("BasicInitializeAdapter: In\n"));
//
// ----------------- Tx Engine handling --------------------
//
nicStatus = NIC_COMMAND_WAIT(pAdapter, COMMAND_TX_DISABLE);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"BasicInitializeAdapter: COMMAND_TX_DISABLE failed\n"));
DBGPRINT_FUNCTION((
"BasicInitializeAdapter: Out with error\n"));
return NIC_STATUS_FAILURE;
}
#ifdef SERR_NEEDED
// Down stall the adapter and wait for 100 milliseconds for
// any pending PCI retry to be over.
NIC_COMMAND_WAIT(pAdapter, COMMAND_DOWN_STALL);
#endif
nicStatus = NIC_COMMAND_WAIT(pAdapter, COMMAND_TX_RESET | TX_RESET_MASK_NETWORK_RESET);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"BasicInitializeAdapter: COMMAND_TX_RESET failed\n"));
DBGPRINT_FUNCTION((
"GetAdapterProperties: Out with error\n"));
return NIC_STATUS_FAILURE;
}
//
// ----------------- Rx engine handling --------------------
//
nicStatus = NIC_COMMAND_WAIT(pAdapter, COMMAND_RX_DISABLE);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"BasicInitializeAdapter: Rx disable failed\n"));
DBGPRINT_FUNCTION((
"BasicInitializeAdapter: Out with error\n"));
return NIC_STATUS_FAILURE;
}
#ifdef SERR_NEEDED
// Up stall the adapter and wait for 100 milliseconds for
// any pending PCI retry to be over.
NIC_COMMAND_WAIT(pAdapter, COMMAND_UP_STALL);
#endif
nicStatus = NIC_COMMAND_WAIT(pAdapter, COMMAND_RX_RESET | RX_RESET_MASK_NETWORK_RESET);
if (nicStatus != NIC_STATUS_SUCCESS) {
DBGPRINT_ERROR((
"BasicInitializeAdapter: Rx reset failed\n"
));
DBGPRINT_FUNCTION((
"BasicInitializeAdapter: Out with error\n"
));
return NIC_STATUS_FAILURE;
}
//
// Take care of the interrupts.
//
NIC_ACKNOWLEDGE_ALL_INTERRUPT(pAdapter);
NIC_COMMAND(pAdapter, COMMAND_STATISTICS_DISABLE);
NIC_COMMAND(
pAdapter,
COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_6);
//
// Clear the statistics from the hardware.
//
NIC_READ_PORT_UCHAR(pAdapter, CARRIER_LOST_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, SQE_ERRORS_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, MULTIPLE_COLLISIONS_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, SINGLE_COLLISIONS_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, LATE_COLLISIONS_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, RX_OVERRUNS_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, FRAMES_TRANSMITTED_OK_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, FRAMES_RECEIVED_OK_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, FRAMES_DEFERRED_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, UPPER_FRAMES_OK_REGISTER);
NIC_READ_PORT_USHORT(pAdapter, BYTES_RECEIVED_OK_REGISTER);
NIC_READ_PORT_USHORT(pAdapter, BYTES_TRANSMITTED_OK_REGISTER);
NIC_COMMAND(
pAdapter,
COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_4);
NIC_READ_PORT_UCHAR(pAdapter, BAD_SSD_REGISTER);
NIC_READ_PORT_UCHAR(pAdapter, UPPER_BYTES_OK_REGISTER);
//
// Program the station address.
//
NIC_COMMAND(
pAdapter,
COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_2);
stationTemp = pAdapter->StationAddress[1] << 8;
stationTemp |= pAdapter->StationAddress[0];
NIC_WRITE_PORT_USHORT(
pAdapter,
STATION_ADDRESS_LOW_REGISTER,
stationTemp);
stationTemp = pAdapter->StationAddress[3] << 8;
stationTemp |= pAdapter->StationAddress[2];
NIC_WRITE_PORT_USHORT(
pAdapter,
STATION_ADDRESS_MID_REGISTER,
stationTemp);
stationTemp = pAdapter->StationAddress[5] << 8;
stationTemp |= pAdapter->StationAddress[4];
NIC_WRITE_PORT_USHORT(
pAdapter,
STATION_ADDRESS_HIGH_REGISTER,
stationTemp);
NIC_WRITE_PORT_USHORT(pAdapter, 0x6, 0);
NIC_WRITE_PORT_USHORT(pAdapter, 0x8, 0);
NIC_WRITE_PORT_USHORT(pAdapter, 0xA, 0);
NIC_COMMAND(pAdapter, COMMAND_STATISTICS_ENABLE);
//
// Clear the mac control register.
//
NIC_COMMAND(
pAdapter,
COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_3);
macControl = NIC_READ_PORT_USHORT(pAdapter, MAC_CONTROL_REGISTER);
macControl &= 0x1;
NIC_WRITE_PORT_USHORT(pAdapter, MAC_CONTROL_REGISTER, macControl);
DBGPRINT_FUNCTION((
"BasicInitializeAdapter: Out with success\n"));
return NIC_STATUS_SUCCESS;
}
/*++
Routine Name:
tc90x_AllocateSharedMemory.
Routine Description:
This routine allocates the shared memory
Arguments:
Device - Pointer to the device structure
Return Value:
NIC_STATUS_SUCCESS if memory allocations succeeds
NIC_STATUS_FAILURE if memory allocation fails
--*/
NIC_STATUS
tc90x_AllocateSharedMemory(
IN PNIC_INFORMATION Adapter
)
{
PNIC_INFORMATION pAdapter = Adapter;
PDEVICE device = pAdapter->Device;
ULONG updMemoryForOne, totalUPDMemory;
ULONG dpdMemoryForOne, totalDPDMemory;
ULONG rxMemoryForOne;
ULONG cacheLineSize, count, alignment;
ULONG memoryBaseVirtual, memoryBasePhysical;
ULONG updMemoryVirtualStart, updMemoryPhysicalStart;
ULONG dpdMemoryVirtualStart, dpdMemoryPhysicalStart;
ULONG currentUPDPhysical, previousUPDPhysical;
ULONG firstUPDPhysical = 0;
PUPD_LIST_ENTRY currentUPDVirtual = NULL;
PUPD_LIST_ENTRY firstUPDVirtual = NULL;
PUPD_LIST_ENTRY previousUPDVirtual = NULL;
PUCHAR dataPointer;
PDPD_LIST_ENTRY currentDPDVirtual = NULL;
PDPD_LIST_ENTRY headDPDVirtual = NULL;
PDPD_LIST_ENTRY previousDPDVirtual = NULL;
ULONG currentDPDPhysical = 0;
ULONG testMemoryVirtualStart, testMemoryPhysicalStart;
ULONG totalTestMemory;
DBGPRINT_FUNCTION(("tc90x_AllocateSharedMemory: In\n"));
cacheLineSize = pAdapter->Hardware.CacheLineSize;
//
// UPD structure memory requirement.
//
updMemoryForOne = sizeof(UPD_LIST_ENTRY) + cacheLineSize;
totalUPDMemory = pAdapter->Resources.ReceiveCount * updMemoryForOne;
//
// Receive buffer requirement.
//
rxMemoryForOne = ETHERNET_MAXIMUM_FRAME_SIZE + cacheLineSize;
//
// DPD structure memory requirement.
//
dpdMemoryForOne = sizeof(DPD_LIST_ENTRY) + cacheLineSize;
totalDPDMemory = pAdapter->Resources.SendCount * dpdMemoryForOne;
//
// Calculate the test memory required.
//
totalTestMemory = MAXIMUM_TEST_BUFFERS *
(dpdMemoryForOne + rxMemoryForOne);
pAdapter->Resources.SharedMemorySize = totalUPDMemory +
totalDPDMemory +
totalTestMemory;
//
// Allocate the memory
//
pAdapter->Resources.SharedMemoryVirtual =
(PUCHAR) kmalloc(
pAdapter->Resources.SharedMemorySize,
GFP_KERNEL);
pAdapter->ResourcesReserved |= NIC_SHA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -