PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
netman.h
Go to the documentation of this file.
1
6#ifndef __NETMAN_H__
7#define __NETMAN_H__
8
9#include <tamtypes.h>
10
11// Common structures
12#define NETMAN_NETIF_NAME_MAX_LEN 4
13#define NETMAN_NETIF_FRAME_SIZE 1514
14#define NETMAN_FRAME_GROUP_SIZE 8 // The actual number of DMA transfer tags is twice this. The total number presented to sceSifSetDma must never exceed 32.
15
17{
18 void (*LinkStateUp)(void);
19 void (*LinkStateDown)(void);
20 void *(*AllocRxPacket)(unsigned int size, void **payload);
21 void (*FreeRxPacket)(void *packet);
22 void (*EnQRxPacket)(void *packet);
23 int (*NextTxPacket)(void **payload);
24 void (*DeQTxPacket)(void);
25 int (*AfterTxPacket)(void **payload); // For EE only, peek at the packet after the current packet.
26 void (*ReallocRxPacket)(void *packet, unsigned int size); // For EE only, update the size of the Rx packet (size will be always smaller than NETMAN_NETIF_FRAME_SIZE).
27};
28
30{
31 u32 RxDroppedFrameCount;
32 u32 RxErrorCount;
33 u16 RxFrameOverrunCount;
34 u16 RxFrameBadLengthCount;
35 u16 RxFrameBadFCSCount;
36 u16 RxFrameBadAlignmentCount;
37 u32 TxDroppedFrameCount;
38 u32 TxErrorCount;
39 u16 TxFrameLOSSCRCount;
40 u16 TxFrameEDEFERCount;
41 u16 TxFrameCollisionCount;
42 u16 TxFrameUnderrunCount;
43 u16 RxAllocFail;
44};
45
47{
48 u8 LinkStatus, LinkMode;
49 struct NetManEthRuntimeStats stats;
50};
51
53#define NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE 0x40
54
69
70enum NETMAN_NETIF_ETH_LINK_STATE {
71 NETMAN_NETIF_ETH_LINK_STATE_DOWN = 0,
72 NETMAN_NETIF_ETH_LINK_STATE_UP
73};
74
76 // Ethernet I/F-only IOCTL codes
79 // Function codes with no input and no output; the result is in the return value.
80 NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE,
81 NETMAN_NETIF_IOCTL_ETH_GET_RX_EOVERRUN_CNT,
82 NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADLEN_CNT,
83 NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADFCS_CNT,
84 NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADALIGN_CNT,
85 NETMAN_NETIF_IOCTL_ETH_GET_TX_ELOSSCR_CNT,
86 NETMAN_NETIF_IOCTL_ETH_GET_TX_EEDEFER_CNT,
87 NETMAN_NETIF_IOCTL_ETH_GET_TX_ECOLL_CNT,
88 NETMAN_NETIF_IOCTL_ETH_GET_TX_EUNDERRUN_CNT,
89 // Returns struct NetManEthStatus
90 NETMAN_NETIF_IOCTL_ETH_GET_STATUS,
91
94
95 // Dial-up I/F-only IOCTL codes
96 // 0x2000
97
98 // Common IOCTL codes
99 NETMAN_NETIF_IOCTL_GET_LINK_STATUS = 0x3000,
100 NETMAN_NETIF_IOCTL_GET_TX_DROPPED_COUNT,
101 NETMAN_NETIF_IOCTL_GET_RX_DROPPED_COUNT,
102};
103
104//*** Higher-level services, for the running user program ***
105// Initialization and deinitialization functions, for the EE side.
106#ifdef _EE
107
108int NetManInit(void);
109void NetManDeinit(void);
110
111#endif
112
113// Network Interface (IF) control.
114int NetManGetGlobalNetIFLinkState(void);
115int NetManSetMainIF(const char *name);
116int NetManQueryMainIF(char *name);
117
118//*** System functions for either the Network IF driver or the network protocol stack ***
119// For the network protocol stack to initialize/deinitialize NETMAN.
120int NetManRegisterNetworkStack(const struct NetManNetProtStack *stack);
121void NetManUnregisterNetworkStack(void);
122
123/* Common network Interface (IF) management functions. Used by the user program and the protocol stack. */
124int NetManIoctl(unsigned int command, void *args, unsigned int args_len, void *output, unsigned int length);
125int NetManSetLinkMode(int mode);
126
127/* Network Interface (IF) management functions. Used by the protocol stack. */
128void NetManNetIFXmit(void); // Notify the interface of available packets. May be called from the interrupt context.
129
130/* Network protocol stack management functions. Used by the Network InterFace (IF) driver. */
131void *NetManNetProtStackAllocRxPacket(unsigned int length, void **payload);
132void NetManNetProtStackFreeRxPacket(void *packet);
133void NetManNetProtStackEnQRxPacket(void *packet);
134int NetManTxPacketNext(void **payload);
135void NetManTxPacketDeQ(void);
136
137int NetManTxPacketAfter(void **payload); // For EE only, for NETMAN's internal use.
138void NetManNetProtStackReallocRxPacket(void *packet, unsigned int length); // For EE only, for NETMAN's internal use.
139
140/* NETIF flags. */
142#define NETMAN_NETIF_IN_USE 0x80
144#define NETMAN_NETIF_ETHERNET 1
146#define NETMAN_NETIF_DIALUP 2
148#define NETMAN_NETIF_LINK_UP 4
149
151{
152 char name[NETMAN_NETIF_NAME_MAX_LEN];
153 unsigned short int flags;
155 short int id;
156 int (*init)(void);
157 void (*deinit)(void);
158 void (*xmit)(void);
159 int (*ioctl)(unsigned int command, void *args, unsigned int args_len, void *output, unsigned int length);
160 int EventFlagID;
161};
162
163// IF event flag bits, set by NETMAN
164#define NETMAN_NETIF_EVF_UP 0x01
165#define NETMAN_NETIF_EVF_DOWN 0x02
166
167#define NETMAN_MAX_NETIF_COUNT 2
168
169/* Network InterFace (IF) management functions. Used by the network InterFace (IF). */
170int NetManRegisterNetIF(struct NetManNetIF *NetIF);
171void NetManUnregisterNetIF(const char *name);
172void NetManToggleNetIFLinkState(int NetIFID, unsigned char state); // Also toggles NETMAN_NETIF_EVF_UP and NETMAN_NETIF_EVF_DOWN
173
174#ifdef _IOP
175
176#define netman_IMPORTS_start DECLARE_IMPORT_TABLE(netman, 3, 1)
177#define netman_IMPORTS_end END_IMPORT_TABLE
178
179#define I_NetManRegisterNetworkStack DECLARE_IMPORT(4, NetManRegisterNetworkStack)
180#define I_NetManUnregisterNetworkStack DECLARE_IMPORT(5, NetManUnregisterNetworkStack)
181
182#define I_NetManNetIFXmit DECLARE_IMPORT(6, NetManNetIFXmit)
183#define I_NetManIoctl DECLARE_IMPORT(7, NetManIoctl)
184
185#define I_NetManNetProtStackAllocPacket DECLARE_IMPORT(8, NetManNetProtStackAllocRxPacket)
186#define I_NetManNetProtStackFreePacket DECLARE_IMPORT(9, NetManNetProtStackFreeRxPacket)
187#define I_NetManNetProtStackEnQPacket DECLARE_IMPORT(10, NetManNetProtStackEnQRxPacket)
188
189#define I_NetManRegisterNetIF DECLARE_IMPORT(11, NetManRegisterNetIF)
190#define I_NetManUnregisterNetIF DECLARE_IMPORT(12, NetManUnregisterNetIF)
191#define I_NetManToggleNetIFLinkState DECLARE_IMPORT(13, NetManToggleNetIFLinkState)
192#define I_NetManGetGlobalNetIFLinkState DECLARE_IMPORT(14, NetManGetGlobalNetIFLinkState)
193
194#define I_NetManSetMainIF DECLARE_IMPORT(15, NetManSetMainIF)
195#define I_NetManQueryMainIF DECLARE_IMPORT(16, NetManQueryMainIF)
196
197#define I_NetManSetLinkMode DECLARE_IMPORT(17, NetManSetLinkMode)
198
199#define I_NetManTxPacketNext DECLARE_IMPORT(18, NetManTxPacketNext)
200#define I_NetManTxPacketDeQ DECLARE_IMPORT(19, NetManTxPacketDeQ)
201
202#endif
203
204#endif /* __NETMAN_H__ */
NETMAN_NETIF_ETH_LINK_MODE
Definition netman.h:55
@ NETMAN_NETIF_ETH_LINK_MODE_100M_HDX
Definition netman.h:63
@ NETMAN_NETIF_ETH_LINK_MODE_10M_FDX
Definition netman.h:61
@ NETMAN_NETIF_ETH_LINK_MODE_10M_HDX
Definition netman.h:59
@ NETMAN_NETIF_ETH_LINK_MODE_AUTO
Definition netman.h:57
@ NETMAN_NETIF_ETH_LINK_MODE_100M_FDX
Definition netman.h:65
NETMAN_NETIF_IOCTL_CODES
Definition netman.h:75
@ NETMAN_NETIF_IOCTL_ETH_GET_MAC
Definition netman.h:78
@ NETMAN_NETIF_IOCTL_ETH_SET_LINK_MODE
Definition netman.h:93
short int id
Definition netman.h:155