Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / include / netsim.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: netsim.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/*
24 * "netsim.h"
25 *
26 * low level communications for blaze device simulators to/from other
27 * processes, eg switchsim and syncsim
28 *
29 * connect: result is file descr `fd' for socket, or -1 for error.
30 *
31 * getmsg: result < 0: error
32 * result = 0: connection closed, or errno = EINTR (SIGUSR1)
33 * result > 0: success, actual bytes read is in hdr->pkt_len
34 *
35 * putmsg: result < 0: error, (including close ???)
36 * result = 0: ???
37 * result > 0: success, `result' bytes written
38 *
39 * there isn't any "partial transfer" (result < request) at this interface,
40 * its either all or nothing.
41 *
42 *
43 * TBD, eventually the argument to netsim_connect() will be parsed so:
44 *
45 * "/tmp/BLAZE*" -> mmap
46 * "/dev/*" -> snoop
47 * "<hostname>/<portno>" -> socket
48 */
49#ifndef _NETSIM_H
50#define _NETSIM_H
51
52
53typedef struct swtchdr {
54 int pkt_type; /* this field also gets used as timesync */
55 int pkt_len;
56} swtchdr;
57
58
59extern int netsim_connect (const char *switchandport);
60
61extern int netsim_close (int fd);
62
63extern int netsim_getmsg (int fd, char * buf, int maxlen, swtchdr * hdr);
64
65extern int netsim_putmsg (int fd, char * buf, int len, swtchdr * hdr);
66
67extern int netsim_snoop (char * buf, int len, int dbglvl);
68
69
70
71extern uint16_t ether_chksum (char *buf, int offset, int len);
72extern uint16_t ether_reverse_hword (uint16_t value);
73extern uint32_t ether_reverse_word (uint32_t value);
74extern uint64_t ether_reverse_lword (uint64_t value);
75
76
77
78
79/* bogus legacy globals -----------------------------------------------
80 */
81extern int netsim_switch_flag; /* when true -> using switchsim (sockets, or
82 mmap), otherwise using snoop */
83
84extern char netsim_switch_server_name[];
85extern char netsim_switch_ipc_type[];
86extern char netsim_mmap_dir[];
87
88#define NETSIM_IPC_SOCKET 0
89#define NETSIM_IPC_MMAP 1
90extern int netsim_ipc_type;
91
92// and some bogus (these don't belong down at this low level) defines
93#define SWITCH_DEFAULT_PORT 10000 /* tcp port for (ether) packets */
94#define SYNC_DEFAULT_PORT 11000 /* tcp port for global-time-sync */
95
96/*end-bogus ------------------------------------------------------------
97*/
98
99#define TIMEOUT_FIVE_SECOND 5000 /*5000ms*/
100
101#define MAXDLBUF 8192 /* max of all possible MTUs (packet size, bytes) */
102
103
104
105/* the OLD "make a socket or mmap connection" function
106 */
107extern int ipc_init(const char *switch_server, const char *ipc_type_string, int key_type, const char *mmap_dir, int mmap_file_size);
108
109
110/* the old "make a snoop connection" function
111 */
112extern int init_snoop_device (const char * name, int minor);
113extern int snoop_getmsg (int fd, char * buf, int maxlen);
114extern int snoop_putmsg (int fd, char * buf, int len);
115
116
117#endif /* _NETSIM_H */