Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9017 → Rev 9016

/kernel/trunk/docs/sysfuncr.txt
4615,84 → 4615,6
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-2021. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4590,84 → 4590,6
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/stack.inc
30,7 → 30,6
 
DEBUG_NETWORK_ERROR = 1
DEBUG_NETWORK_VERBOSE = 0
NETWORK_SANITY_CHECKS = 1
 
NET_DEVICES_MAX = 16
NET_BUFFERS = 512
263,14 → 262,9
net_device_count dd ?
net_device_list rd NET_DEVICES_MAX
 
net_buffs_free rd NET_BUFFERS ; list of pointers to actual net buffs
.current dd ? ; pointer to current element in net_buffs_free list
net_buffs_free rd NET_BUFFERS
.current dd ?
 
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
 
 
290,10 → 284,6
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
303,11 → 293,6
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
 
409,16 → 394,6
 
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
 
433,15 → 408,6
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
 
 
450,16 → 416,6
 
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
470,15 → 426,6
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
 
 
813,13 → 760,6
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:
828,10 → 768,12
ret
 
.get_dev_name:
mov ebx, eax
; { Patch by Coldy, sanity check
mov ebx, eax ; eax will used for is_region_userspace return
stdcall is_region_userspace, ecx, 64
jz .bad_buffer
mov esi, [ebx + NET_DEVICE.name]
mov esi, [ebx + NET_DEVICE.name] ;mov esi, [eax + NET_DEVICE.name]
; } End patch by Coldy, sanity check
mov edi, ecx
 
mov ecx, 64/4 ; max length
886,36 → 828,6
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
/kernel/trunk/network/ethernet.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ETHERNET.INC ;;
76,18 → 76,9
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]
101,7 → 92,7
mov [ETH_frame_tail], eax
mov [ebx + NET_BUFF.NextPtr], eax
 
spin_unlock_irqrestore
popf
 
; Mark it as being an Ethernet Frame
mov [eax + NET_BUFF.type], NET_BUFF_ETH
116,23 → 107,14
ret
 
.full:
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
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
popf
push eax
call net_buff_free
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. ;
182,7 → 164,7
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: size=%u\n", ecx
sub ecx, sizeof.ETH_header
jb .err
jb .dump
 
; Set registers for protocol handlers
lea edx, [eax + sizeof.ETH_header]
206,25 → 188,13
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
 
.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"
.dump:
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\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 ;
246,7 → 216,7
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
 
cmp ecx, [ebx + ETH_DEVICE.mtu]
ja .too_large
ja .exit
 
push ecx
push ax edx
255,7 → 225,6
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
287,16 → 256,13
jmp .done
 
.out_of_ram:
inc [ebx + NET_DEVICE.packets_tx_drop]
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: Out of ram!\n"
add esp, 4+2
pop ecx
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n"
add esp, 4+2+4
xor eax, eax
ret
 
.too_large:
inc [eax + NET_DEVICE.packets_tx_err]
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: Packet too large!\n"
.exit:
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n"
xor eax, eax
ret