/kernel/trunk/docs/sysfuncr.txt |
---|
4615,6 → 4615,84 |
eax - SF_NETWORK_GET (74) |
bl - SSF_LINK_STATUS (10) |
====================================================================== |
==== Function 74, Subfunction 11, Get TX error packets counter. ====== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 11 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of erroneous packets received since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_ERROR_COUNT (11) |
====================================================================== |
=== Function 74, Subfunction 12, Get TX dropped packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 12 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of dropped packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_DROP_COUNT (12) |
====================================================================== |
==== Function 74, Subfunction 13, Get TX missed packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 13 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of missed packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_MISS_COUNT (13) |
====================================================================== |
==== Function 74, Subfunction 14, Get RX error packets counter. ====== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 14 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of erroneous packets received since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_ERROR_COUNT (14) |
====================================================================== |
=== Function 74, Subfunction 15, Get RX dropped packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 15 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of dropped packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_DROP_COUNT (12) |
====================================================================== |
==== Function 74, Subfunction 16, Get RX missed packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 16 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of missed packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_MISS_COUNT (16) |
====================================================================== |
============== Функция 75, подфункция 0, Открыть сокет. ============== |
====================================================================== |
Параметры: |
/kernel/trunk/docs/sysfuncs.txt |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4590,6 → 4590,84 |
eax - SF_NETWORK_GET (74) |
bl - SSF_LINK_STATUS (10) |
====================================================================== |
==== Function 74, Subfunction 11, Get TX error packets counter. ====== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 11 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of erroneous packets received since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_ERROR_COUNT (11) |
====================================================================== |
=== Function 74, Subfunction 12, Get TX dropped packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 12 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of dropped packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_DROP_COUNT (12) |
====================================================================== |
==== Function 74, Subfunction 13, Get TX missed packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 13 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of missed packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_TX_PACKET_MISS_COUNT (13) |
====================================================================== |
==== Function 74, Subfunction 14, Get RX error packets counter. ====== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 14 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of erroneous packets received since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_ERROR_COUNT (14) |
====================================================================== |
=== Function 74, Subfunction 15, Get RX dropped packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 15 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of dropped packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_DROP_COUNT (12) |
====================================================================== |
==== Function 74, Subfunction 16, Get RX missed packets counter. ===== |
====================================================================== |
Parameters: |
* eax = 74 - function number |
* bl = 16 - subfunction number |
* bh = device number |
Returned value: |
* eax = Number of missed packets since device start, -1 on error |
---------------------- Constants for registers: ---------------------- |
eax - SF_NETWORK_GET (74) |
bl - SSF_RX_PACKET_MISS_COUNT (16) |
====================================================================== |
============== Function 75, Subfunction 0, Open socket. ============== |
====================================================================== |
Parameters: |
/kernel/trunk/network/ethernet.inc |
---|
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 |
/kernel/trunk/network/stack.inc |
---|
30,6 → 30,7 |
DEBUG_NETWORK_ERROR = 1 |
DEBUG_NETWORK_VERBOSE = 0 |
NETWORK_SANITY_CHECKS = 1 |
NET_DEVICES_MAX = 16 |
NET_BUFFERS = 512 |
262,9 → 263,14 |
net_device_count dd ? |
net_device_list rd NET_DEVICES_MAX |
net_buffs_free rd NET_BUFFERS |
.current dd ? |
net_buffs_free rd NET_BUFFERS ; list of pointers to actual net buffs |
.current dd ? ; pointer to current element in net_buffs_free list |
if defined NETWORK_SANITY_CHECKS |
net_buffs_low dd ? ; actual net buff mem region start |
net_buffs_high dd ? ; actual net buff mem region stop |
end if |
endg |
284,6 → 290,10 |
test eax, eax |
jz .fail |
if defined NETWORK_SANITY_CHECKS |
mov [net_buffs_low], eax |
end if |
mov edi, net_buffs_free |
mov ecx, NET_BUFFERS |
cld |
293,6 → 303,11 |
dec ecx |
jnz .loop |
if defined NETWORK_SANITY_CHECKS |
sub eax, NET_BUFFER_SIZE |
mov [net_buffs_high], eax |
end if |
mov eax, net_buffs_free |
stosd |
394,6 → 409,16 |
spin_unlock_irqrestore |
if defined NETWORK_SANITY_CHECKS |
cmp eax, [net_buffs_low] |
cmp eax, [net_buffs_low] |
jb .assert_mbuff |
cmp eax, [net_buffs_high] |
ja .assert_mbuff |
test eax, 0x7ff |
jnz .assert_mbuff |
end if |
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_alloc: 0x%x\n", eax |
ret |
408,6 → 433,15 |
xor eax, eax |
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: too large!\n" |
ret |
if defined NETWORK_SANITY_CHECKS |
.assert_mbuff: |
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: invalid buffer 0x%x\n", eax |
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: caller=0x%x\n", [esp+4] |
xor eax, eax |
ret |
end if |
endp |
416,6 → 450,16 |
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_free: 0x%x\n", [buffer] |
if defined NETWORK_SANITY_CHECKS |
mov eax, [buffer] |
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 |
sub [net_buffs_free.current], 4 ; move pointer backwards |
426,6 → 470,15 |
spin_unlock_irqrestore |
ret |
if defined NETWORK_SANITY_CHECKS |
.assert_mbuff: |
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_free: invalid buffer 0x%x\n", eax |
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_free: caller=0x%x\n", [esp+4] |
xor eax, eax |
ret |
end if |
endp |
760,6 → 813,13 |
dd .bytes_tx ; 8 |
dd .bytes_rx ; 9 |
dd .state ; 10 |
dd .packets_tx_err ; 11 |
dd .packets_tx_drop ; 12 |
dd .packets_tx_ovr ; 13 |
dd .packets_rx_err ; 14 |
dd .packets_rx_drop ; 15 |
dd .packets_rx_ovr ; 16 |
.number = ($ - .table) / 4 - 1 |
.get_type: |
768,12 → 828,10 |
ret |
.get_dev_name: |
; { Patch by Coldy, sanity check |
mov ebx, eax ; eax will used for is_region_userspace return |
mov ebx, eax |
stdcall is_region_userspace, ecx, 64 |
jz .bad_buffer |
mov esi, [ebx + NET_DEVICE.name] ;mov esi, [eax + NET_DEVICE.name] |
; } End patch by Coldy, sanity check |
mov esi, [ebx + NET_DEVICE.name] |
mov edi, ecx |
mov ecx, 64/4 ; max length |
828,6 → 886,36 |
mov [esp+32], eax |
ret |
.packets_tx_err: |
mov eax, [eax + NET_DEVICE.packets_tx_err] |
mov [esp+32], eax |
ret |
.packets_tx_drop: |
mov eax, [eax + NET_DEVICE.packets_tx_drop] |
mov [esp+32], eax |
ret |
.packets_tx_ovr: |
mov eax, [eax + NET_DEVICE.packets_tx_ovr] |
mov [esp+32], eax |
ret |
.packets_rx_err: |
mov eax, [eax + NET_DEVICE.packets_rx_err] |
mov [esp+32], eax |
ret |
.packets_rx_drop: |
mov eax, [eax + NET_DEVICE.packets_rx_drop] |
mov [esp+32], eax |
ret |
.packets_rx_ovr: |
mov eax, [eax + NET_DEVICE.packets_rx_ovr] |
mov [esp+32], eax |
ret |
.state: |
mov eax, [eax + NET_DEVICE.link_state] |
mov [esp+32], eax |