Rev 5498 | Rev 5567 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5498 | Rev 5522 | ||
---|---|---|---|
Line 173... | Line 173... | ||
173 | DSB_OWNbit = 0x80000000 |
173 | DSB_OWNbit = 0x80000000 |
174 | DSB_EORbit = 0x40000000 |
174 | DSB_EORbit = 0x40000000 |
175 | DSB_FSbit = 0x20000000 |
175 | DSB_FSbit = 0x20000000 |
176 | DSB_LSbit = 0x10000000 |
176 | DSB_LSbit = 0x10000000 |
Line 177... | Line 177... | ||
177 | 177 | ||
Line 178... | Line 178... | ||
178 | RX_BUF_SIZE = 1536 ; Rx Buffer size |
178 | RX_BUF_SIZE = 1514 ; Rx Buffer size |
179 | 179 | ||
Line 180... | Line 180... | ||
180 | ; max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4) |
180 | ; max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4) |
Line 181... | Line 181... | ||
181 | MAX_ETH_FRAME_SIZE = 1536 |
181 | MAX_ETH_FRAME_SIZE = 1514 |
182 | 182 | ||
Line 198... | Line 198... | ||
198 | 198 | ||
Line 199... | Line 199... | ||
199 | TIMER_EXPIRE_TIME = 100 |
199 | TIMER_EXPIRE_TIME = 100 |
200 | 200 | ||
201 | ETH_HDR_LEN = 14 |
201 | ETH_HDR_LEN = 14 |
Line 202... | Line 202... | ||
202 | DEFAULT_MTU = 1500 |
202 | DEFAULT_MTU = 1500 |
203 | DEFAULT_RX_BUF_LEN = 1536 |
203 | DEFAULT_RX_BUF_LEN = 1514 |
204 | 204 | ||
Line 660... | Line 660... | ||
660 | reset: |
660 | reset: |
Line 661... | Line 661... | ||
661 | 661 | ||
Line 662... | Line 662... | ||
662 | DEBUGF 1,"resetting\n" |
662 | DEBUGF 1,"resetting\n" |
- | 663 | ||
- | 664 | call init_ring |
|
- | 665 | test eax, eax |
|
663 | 666 | jnz .err |
|
Line 664... | Line 667... | ||
664 | call init_ring |
667 | |
Line 665... | Line 668... | ||
665 | call hw_start |
668 | call hw_start |
Line 676... | Line 679... | ||
676 | 679 | ||
677 | DEBUGF 2,"init OK!\n" |
680 | DEBUGF 2,"init OK!\n" |
678 | xor eax, eax |
681 | xor eax, eax |
Line 679... | Line 682... | ||
679 | ret |
682 | ret |
- | 683 | ||
- | 684 | .err: |
|
- | 685 | DEBUGF 2,"failed!\n" |
|
Line 680... | Line 686... | ||
680 | 686 | or eax, -1 |
|
681 | 687 | ret |
|
Line 798... | Line 804... | ||
798 | 804 | ||
799 | lea edi, [ebx + device.rx_ring] |
805 | lea edi, [ebx + device.rx_ring] |
800 | mov ecx, NUM_RX_DESC |
806 | mov ecx, NUM_RX_DESC |
801 | .loop: |
807 | .loop: |
802 | push ecx |
808 | push ecx |
- | 809 | invoke NetAlloc, RX_BUF_SIZE+NET_BUFF.data |
|
- | 810 | test eax, eax |
|
803 | invoke KernelAlloc, RX_BUF_SIZE |
811 | jz .err |
804 | mov dword [edi + rx_desc.buf_soft_addr], eax |
812 | mov dword [edi + rx_desc.buf_soft_addr], eax |
- | 813 | invoke GetPhysAddr |
|
805 | invoke GetPhysAddr |
814 | add eax, NET_BUFF.data |
806 | mov dword [edi + rx_desc.buf_addr], eax |
815 | mov dword [edi + rx_desc.buf_addr], eax |
807 | mov [edi + rx_desc.status], DSB_OWNbit or RX_BUF_SIZE |
816 | mov [edi + rx_desc.status], DSB_OWNbit or RX_BUF_SIZE |
808 | add edi, sizeof.rx_desc |
817 | add edi, sizeof.rx_desc |
809 | pop ecx |
818 | pop ecx |
810 | dec ecx |
819 | dec ecx |
811 | jnz .loop |
820 | jnz .loop |
Line -... | Line 821... | ||
- | 821 | or [edi - sizeof.rx_desc + rx_desc.status], DSB_EORbit |
|
812 | or [edi - sizeof.rx_desc + rx_desc.status], DSB_EORbit |
822 | |
Line -... | Line 823... | ||
- | 823 | xor eax, eax |
|
- | 824 | ret |
|
- | 825 | ||
- | 826 | .err: |
|
Line 813... | Line 827... | ||
813 | 827 | pop eax |
|
814 | ret |
828 | or eax, -1 |
Line 815... | Line 829... | ||
815 | 829 | ret |
|
Line 988... | Line 1002... | ||
988 | ; Destroyed registers |
1002 | ; Destroyed registers |
989 | ; eax, edx, esi, edi |
1003 | ; eax, edx, esi, edi |
990 | ; |
1004 | ; |
991 | ;*************************************************************************** |
1005 | ;*************************************************************************** |
Line 992... | Line 1006... | ||
992 | 1006 | ||
Line 993... | Line 1007... | ||
993 | proc transmit stdcall bufferptr, buffersize |
1007 | proc transmit stdcall bufferptr |
994 | 1008 | ||
Line -... | Line 1009... | ||
- | 1009 | pushf |
|
995 | pushf |
1010 | cli |
996 | cli |
1011 | |
997 | 1012 | mov esi, [bufferptr] |
|
998 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
1013 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
999 | mov eax, [bufferptr] |
1014 | lea eax, [esi + NET_BUFF.data] |
1000 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1015 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
Line 1001... | Line 1016... | ||
1001 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1016 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1002 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1017 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1003 | [eax+13]:2,[eax+12]:2 |
1018 | [eax+13]:2,[eax+12]:2 |
1004 | 1019 | ||
Line 1005... | Line 1020... | ||
1005 | cmp [buffersize], 1514 |
1020 | cmp [esi + NET_BUFF.length], 1514 |
1006 | ja .fail |
1021 | ja .fail |
Line 1024... | Line 1039... | ||
1024 | 1039 | ||
1025 | ;--------------------------- |
1040 | ;--------------------------- |
Line 1026... | Line 1041... | ||
1026 | ; Program the packet pointer |
1041 | ; Program the packet pointer |
- | 1042 | ||
1027 | 1043 | mov eax, [bufferptr] |
|
- | 1044 | mov ecx, [eax + NET_BUFF.length] |
|
1028 | mov eax, [bufferptr] |
1045 | mov [esi + tx_desc.buf_soft_addr], eax |
1029 | mov [esi + tx_desc.buf_soft_addr], eax |
1046 | add eax, [eax + NET_BUFF.offset] |
Line 1030... | Line 1047... | ||
1030 | invoke GetPhysAddr |
1047 | invoke GetPhysAddr |
1031 | mov dword [esi + tx_desc.buf_addr], eax |
1048 | mov dword [esi + tx_desc.buf_addr], eax |
Line 1032... | Line 1049... | ||
1032 | 1049 | ||
1033 | ;------------------------ |
- | |
1034 | ; Program the packet size |
1050 | ;------------------------ |
1035 | 1051 | ; Program the packet size |
|
1036 | mov eax, [buffersize] |
1052 | |
1037 | @@: |
1053 | mov eax, ecx |
1038 | or eax, DSB_OWNbit or DSB_FSbit or DSB_LSbit |
1054 | or eax, DSB_OWNbit or DSB_FSbit or DSB_LSbit |
Line 1058... | Line 1074... | ||
1058 | 1074 | ||
1059 | ;------------- |
1075 | ;------------- |
Line 1060... | Line 1076... | ||
1060 | ; Update stats |
1076 | ; Update stats |
1061 | - | ||
1062 | inc [ebx + device.packets_tx] |
1077 | |
1063 | mov eax, [buffersize] |
1078 | inc [ebx + device.packets_tx] |
Line 1064... | Line 1079... | ||
1064 | add dword [ebx + device.bytes_tx], eax |
1079 | add dword [ebx + device.bytes_tx], ecx |
1065 | adc dword [ebx + device.bytes_tx + 4], 0 |
1080 | adc dword [ebx + device.bytes_tx + 4], 0 |
1066 | 1081 | ||
Line 1067... | Line 1082... | ||
1067 | popf |
1082 | popf |
1068 | xor eax, eax |
1083 | xor eax, eax |
1069 | ret |
1084 | ret |
1070 | 1085 | ||
1071 | .desc: |
1086 | .desc: |
1072 | DEBUGF 2,"Descriptor is still in use!\n" |
1087 | DEBUGF 2,"Descriptor is still in use!\n" |
1073 | .fail: |
1088 | .fail: |
1074 | DEBUGF 2,"Transmit failed\n" |
1089 | DEBUGF 2,"Transmit failed\n" |
Line 1075... | Line 1090... | ||
1075 | invoke KernelFree, [bufferptr] |
1090 | invoke NetFree, [bufferptr] |
Line 1137... | Line 1152... | ||
1137 | mov eax, sizeof.rx_desc |
1152 | mov eax, sizeof.rx_desc |
1138 | mul [ebx + device.cur_rx] |
1153 | mul [ebx + device.cur_rx] |
1139 | lea esi, [ebx + device.rx_ring + eax] |
1154 | lea esi, [ebx + device.rx_ring + eax] |
Line 1140... | Line 1155... | ||
1140 | 1155 | ||
1141 | DEBUGF 1,"RxDesc.status = 0x%x\n", [esi + rx_desc.status] |
1156 | DEBUGF 1,"RxDesc.status = 0x%x\n", [esi + rx_desc.status] |
1142 | mov eax, [esi + rx_desc.status] |
1157 | mov ecx, [esi + rx_desc.status] |
1143 | test eax, DSB_OWNbit ;;; |
1158 | test ecx, DSB_OWNbit ;;; |
Line 1144... | Line 1159... | ||
1144 | jnz .no_own |
1159 | jnz .rx_return |
Line 1145... | Line 1160... | ||
1145 | 1160 | ||
1146 | DEBUGF 1,"cur_rx = %u\n", [ebx + device.cur_rx] |
1161 | DEBUGF 1,"cur_rx = %u\n", [ebx + device.cur_rx] |
Line 1147... | Line 1162... | ||
1147 | 1162 | ||
1148 | test eax, SD_RxRES |
1163 | test ecx, SD_RxRES |
1149 | jnz .rx_return ;;;;; RX error! |
1164 | jnz .rx_return ;;;;; RX error! |
1150 | 1165 | ||
- | 1166 | push ebx |
|
- | 1167 | push .check_more |
|
1151 | push ebx |
1168 | and ecx, 0x00001FFF |
- | 1169 | add ecx, -4 ; we dont need CRC |
|
1152 | push .check_more |
1170 | DEBUGF 1,"data length = %u\n", ecx |
- | 1171 | mov eax, [esi + rx_desc.buf_soft_addr] |
|
Line -... | Line 1172... | ||
- | 1172 | push eax |
|
1153 | and eax, 0x00001FFF |
1173 | mov [eax + NET_BUFF.length], ecx |
Line 1154... | Line 1174... | ||
1154 | add eax, -4 ; we dont need CRC |
1174 | mov [eax + NET_BUFF.device], ebx |
1155 | push eax |
1175 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
1156 | DEBUGF 1,"data length = %u\n", ax |
1176 | |
Line 1157... | Line 1177... | ||
1157 | 1177 | ;------------- |
|
1158 | ; Update stats |
- | |
1159 | 1178 | ; Update stats |
|
Line 1160... | Line 1179... | ||
1160 | add dword [ebx + device.bytes_rx], eax |
1179 | |
1161 | adc dword [ebx + device.bytes_rx + 4], 0 |
1180 | add dword [ebx + device.bytes_rx], eax |
1162 | inc [ebx + device.packets_rx] |
1181 | adc dword [ebx + device.bytes_rx + 4], 0 |
- | 1182 | inc [ebx + device.packets_rx] |
|
1163 | 1183 | ||
Line -... | Line 1184... | ||
- | 1184 | ;---------------------- |
|
1164 | pushd [esi + rx_desc.buf_soft_addr] |
1185 | ; Allocate a new buffer |
Line 1165... | Line 1186... | ||
1165 | 1186 | ||
1166 | ; Allocate a new buffer |
1187 | invoke NetAlloc, RX_BUF_SIZE+NET_BUFF.data |
1167 | 1188 | mov [esi + rx_desc.buf_soft_addr], eax |
|
1168 | invoke KernelAlloc, RX_BUF_SIZE |
1189 | invoke GetPhysAddr |
1169 | mov [esi + rx_desc.buf_soft_addr], eax |
1190 | add eax, NET_BUFF.data |
1170 | invoke GetPhysAddr |
1191 | mov dword [esi + rx_desc.buf_addr], eax |
Line -... | Line 1192... | ||
- | 1192 | ||
1171 | mov dword [esi + rx_desc.buf_addr], eax |
1193 | ;--------------- |
Line 1172... | Line 1194... | ||
1172 | 1194 | ; re set OWN bit |
|
1173 | ; reset OWN bit |
1195 | |
Line 1174... | Line 1196... | ||
1174 | 1196 | mov eax, DSB_OWNbit or RX_BUF_SIZE |
|
1175 | mov eax, DSB_OWNbit or RX_BUF_SIZE |
1197 | cmp [ebx + device.cur_rx], NUM_RX_DESC - 1 |
1176 | cmp [ebx + device.cur_rx], NUM_RX_DESC - 1 |
- | |
1177 | jne @f |
1198 | jne @f |
1178 | or eax, DSB_EORbit |
1199 | or eax, DSB_EORbit |
1179 | @@: |
1200 | @@: |
Line 1180... | Line 1201... | ||
1180 | mov [esi + rx_desc.status], eax |
1201 | mov [esi + rx_desc.status], eax |
1181 | 1202 | ||
Line 1182... | Line 1203... | ||
1182 | ; Update rx ptr |
1203 | ;-------------- |
1183 | 1204 | ; Update rx ptr |
|
- | 1205 | ||
Line 1184... | Line 1206... | ||
1184 | inc [ebx + device.cur_rx] |
1206 | inc [ebx + device.cur_rx] |
1185 | and [ebx + device.cur_rx], NUM_RX_DESC - 1 |
- | |
1186 | - | ||
1187 | jmp [Eth_input] |
- | |
1188 | .rx_return: |
- | |
Line -... | Line 1207... | ||
- | 1207 | and [ebx + device.cur_rx], NUM_RX_DESC - 1 |
|
- | 1208 | ||
- | 1209 | jmp [EthInput] |
|
1189 | DEBUGF 1,"RX error!\n" |
1210 | .rx_return: |
1190 | .no_own: |
1211 | |
Line 1191... | Line 1212... | ||
1191 | pop ax |
1212 | pop ax |
1192 | .no_rx: |
1213 | .no_rx: |
Line -... | Line 1214... | ||
- | 1214 | ||
1193 | 1215 | ;----------------- |
|
1194 | ;----------------- |
1216 | ; Transmit cleanup |
1195 | ; Transmit cleanup |
1217 | |
1196 | - | ||
1197 | test ax, ISB_TxOK or ISB_TxErr or ISB_TxDescUnavail |
1218 | test ax, ISB_TxOK or ISB_TxErr or ISB_TxDescUnavail |
1198 | jz .no_tx |
- | |
1199 | - | ||
Line -... | Line 1219... | ||
- | 1219 | jz .no_tx |
|
1200 | DEBUGF 1,"TX done!\n" |
1220 | push ax |
1201 | .txloop: |
1221 | |
1202 | mov esi, [ebx + device.last_tx] |
1222 | DEBUGF 1,"TX done!\n" |
- | 1223 | ||
- | 1224 | mov ecx, NUM_TX_DESC |
|
1203 | imul esi, sizeof.tx_desc |
1225 | lea esi, [ebx + device.tx_ring] |
Line 1204... | Line 1226... | ||
1204 | lea esi, [ebx + device.tx_ring + esi] |
1226 | .txloop: |
1205 | 1227 | cmp dword [esi + tx_desc.buf_soft_addr], 0 |
|
1206 | cmp dword [esi + tx_desc.buf_soft_addr], 0 |
1228 | jz .maybenext |
Line 1331... | Line 1353... | ||
1331 | ; 8168DP family. |
1353 | ; 8168DP family. |
1332 | dd 0x7cf00000, 0x28800000, 27, name_27 |
1354 | dd 0x7cf00000, 0x28800000, 27, name_27 |
1333 | dd 0x7cf00000, 0x28a00000, 28, name_27 |
1355 | dd 0x7cf00000, 0x28a00000, 28, name_27 |
Line 1334... | Line 1356... | ||
1334 | 1356 | ||
1335 | ; 8168C family. |
1357 | ; 8168C family. |
1336 | dd 0x7cf00000, 0x3cb00000, 24, name_23 |
1358 | dd 0x7cf00000, 0x3cb00000, 24, name_18 |
1337 | dd 0x7cf00000, 0x3c900000, 23, name_23 |
1359 | dd 0x7cf00000, 0x3c900000, 23, name_18 |
1338 | dd 0x7cf00000, 0x3c800000, 18, name_18 |
1360 | dd 0x7cf00000, 0x3c800000, 18, name_18 |
1339 | dd 0x7c800000, 0x3c800000, 24, name_23 |
1361 | dd 0x7c800000, 0x3c800000, 24, name_18 |
1340 | dd 0x7cf00000, 0x3c000000, 19, name_19 |
1362 | dd 0x7cf00000, 0x3c000000, 19, name_19 |
1341 | dd 0x7cf00000, 0x3c200000, 20, name_19 |
1363 | dd 0x7cf00000, 0x3c200000, 20, name_19 |
1342 | dd 0x7cf00000, 0x3c300000, 21, name_19 |
1364 | dd 0x7cf00000, 0x3c300000, 21, name_19 |
1343 | dd 0x7cf00000, 0x3c400000, 22, name_19 |
1365 | dd 0x7cf00000, 0x3c400000, 22, name_19 |
Line 1399... | Line 1421... | ||
1399 | name_18 db "RTL8168cp/8111cp",0 |
1421 | name_18 db "RTL8168cp/8111cp",0 |
1400 | name_19 db "RTL8168c/8111c",0 |
1422 | name_19 db "RTL8168c/8111c",0 |
1401 | ;name_20 db "RTL8168c/8111c",0 |
1423 | ;name_20 db "RTL8168c/8111c",0 |
1402 | ;name_21 db "RTL8168c/8111c",0 |
1424 | ;name_21 db "RTL8168c/8111c",0 |
1403 | ;name_22 db "RTL8168c/8111c",0 |
1425 | ;name_22 db "RTL8168c/8111c",0 |
1404 | name_23 db "RTL8168cp/8111cp",0 |
1426 | ;name_23 db "RTL8168cp/8111cp",0 |
1405 | ;name_24 db "RTL8168cp/8111cp",0 |
1427 | ;name_24 db "RTL8168cp/8111cp",0 |
1406 | name_25 db "RTL8168d/8111d",0 |
1428 | name_25 db "RTL8168d/8111d",0 |
1407 | ;name_26 db "RTL8168d/8111d",0 |
1429 | ;name_26 db "RTL8168d/8111d",0 |
1408 | name_27 db "RTL8168dp/8111dp",0 |
1430 | name_27 db "RTL8168dp/8111dp",0 |
1409 | ;name_28 db "RTL8168dp/8111dp",0 |
1431 | ;name_28 db "RTL8168dp/8111dp",0 |