1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ETHERNET.INC ;; |
76,9 → 76,18 |
eth_input: |
|
pop eax |
pushf |
cli |
|
if defined NETWORK_SANITY_CHECKS |
cmp eax, [net_buffs_low] |
jb .assert_mbuff |
cmp eax, [net_buffs_high] |
ja .assert_mbuff |
test eax, 0x7ff |
jnz .assert_mbuff |
end if |
|
spin_lock_irqsave |
|
cmp [ETH_frame_queued], ETH_QUEUE_SIZE |
jae .full |
inc [ETH_frame_queued] |
92,7 → 101,7 |
mov [ETH_frame_tail], eax |
mov [ebx + NET_BUFF.NextPtr], eax |
|
popf |
spin_unlock_irqrestore |
|
; Mark it as being an Ethernet Frame |
mov [eax + NET_BUFF.type], NET_BUFF_ETH |
107,14 → 116,23 |
ret |
|
.full: |
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n" |
popf |
push eax |
call net_buff_free |
mov ebx, [eax + NET_BUFF.device] |
inc [ebx + NET_DEVICE.packets_rx_ovr] |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH incoming queue is full, discarding packet!\n" |
spin_unlock_irqrestore |
stdcall net_buff_free, eax |
ret |
|
if defined NETWORK_SANITY_CHECKS |
.assert_mbuff: |
DEBUGF DEBUG_NETWORK_ERROR, "eth_input: invalid buffer 0x%x\n", eax |
DEBUGF DEBUG_NETWORK_ERROR, "eth_input: caller=0x%x\n", [esp+4] |
xor eax, eax |
ret |
end if |
|
|
|
;-----------------------------------------------------------------; |
; ; |
; eth_process_input: Process packets from ethernet input queue. ; |
164,7 → 182,7 |
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: size=%u\n", ecx |
sub ecx, sizeof.ETH_header |
jb .dump |
jb .err |
|
; Set registers for protocol handlers |
lea edx, [eax + sizeof.ETH_header] |
188,13 → 206,25 |
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax |
|
.dump: |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\n" |
.drop: |
mov eax, [esp] |
mov eax, [eax + NET_BUFF.device] |
inc [eax + NET_DEVICE.packets_rx_drop] |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dropping\n" |
call net_buff_free |
ret |
|
.err: |
mov eax, [esp] |
mov eax, [eax + NET_BUFF.device] |
inc [eax + NET_DEVICE.packets_rx_err] |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: invalid frame received\n" |
call net_buff_free |
ret |
|
|
|
|
;-----------------------------------------------------------------; |
; ; |
; eth_output ; |
216,7 → 246,7 |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx |
|
cmp ecx, [ebx + ETH_DEVICE.mtu] |
ja .exit |
ja .too_large |
|
push ecx |
push ax edx |
225,6 → 255,7 |
stdcall net_buff_alloc, ecx |
test eax, eax |
jz .out_of_ram |
|
mov [eax + NET_BUFF.type], NET_BUFF_ETH |
mov [eax + NET_BUFF.device], ebx |
mov [eax + NET_BUFF.offset], NET_BUFF.data |
256,13 → 287,16 |
jmp .done |
|
.out_of_ram: |
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
add esp, 4+2+4 |
inc [ebx + NET_DEVICE.packets_tx_drop] |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: Out of ram!\n" |
add esp, 4+2 |
pop ecx |
xor eax, eax |
ret |
|
.exit: |
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
.too_large: |
inc [eax + NET_DEVICE.packets_tx_err] |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: Packet too large!\n" |
xor eax, eax |
ret |
|