* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: netsim.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
* low level communications for blaze device simulators to/from other
* processes, eg switchsim and syncsim
* connect: result is file descr `fd' for socket, or -1 for error.
* getmsg: result < 0: error
* result = 0: connection closed, or errno = EINTR (SIGUSR1)
* result > 0: success, actual bytes read is in hdr->pkt_len
* putmsg: result < 0: error, (including close ???)
* result > 0: success, `result' bytes written
* there isn't any "partial transfer" (result < request) at this interface,
* its either all or nothing.
* TBD, eventually the argument to netsim_connect() will be parsed so:
* "<hostname>/<portno>" -> socket
int pkt_type
; /* this field also gets used as timesync */
extern int netsim_connect (const char *switchandport
);
extern int netsim_close (int fd
);
extern int netsim_getmsg (int fd
, char * buf
, int maxlen
, swtchdr
* hdr
);
extern int netsim_putmsg (int fd
, char * buf
, int len
, swtchdr
* hdr
);
extern int netsim_snoop (char * buf
, int len
, int dbglvl
);
extern uint16_t ether_chksum (char *buf
, int offset
, int len
);
extern uint16_t ether_reverse_hword (uint16_t value
);
extern uint32_t ether_reverse_word (uint32_t value
);
extern uint64_t ether_reverse_lword (uint64_t value
);
/* bogus legacy globals -----------------------------------------------
extern int netsim_switch_flag
; /* when true -> using switchsim (sockets, or
mmap), otherwise using snoop */
extern char netsim_switch_server_name
[];
extern char netsim_switch_ipc_type
[];
extern char netsim_mmap_dir
[];
#define NETSIM_IPC_SOCKET 0
#define NETSIM_IPC_MMAP 1
extern int netsim_ipc_type
;
// and some bogus (these don't belong down at this low level) defines
#define SWITCH_DEFAULT_PORT 10000 /* tcp port for (ether) packets */
#define SYNC_DEFAULT_PORT 11000 /* tcp port for global-time-sync */
/*end-bogus ------------------------------------------------------------
#define TIMEOUT_FIVE_SECOND 5000 /*5000ms*/
#define MAXDLBUF 8192 /* max of all possible MTUs (packet size, bytes) */
/* the OLD "make a socket or mmap connection" function
extern int ipc_init(const char *switch_server
, const char *ipc_type_string
, int key_type
, const char *mmap_dir
, int mmap_file_size
);
/* the old "make a snoop connection" function
extern int init_snoop_device (const char * name
, int minor
);
extern int snoop_getmsg (int fd
, char * buf
, int maxlen
);
extern int snoop_putmsg (int fd
, char * buf
, int len
);