This chapter describes how to interface an application to the IRIS HIPPI subsystem through IRIX sockets in order to use the services of the IP network stack.
![]() | Note: For complete instructions for the IRIX socket API, see Chapter 2 of the InSight (online) document IRIX Network Programmer's Guide, and the man pages for socket(), bind(), getsocketname(), connect(), listen(), accept(), send(), recv(), etc. |
The maximum size for a buffer used within a call that transmits and retrieves data (for example, write() and read() calls) depends on the installed hardware, as summarized below.
Copper-based HIO board (HIPPI-800): max_bufsize = 2 megabytes
Fiber-optics XIO board (HIPPI-Serial): max_bufsize = 16 megabytes
To create a program that will behave correctly, regardless of which hardware is installed, include code that retrieves status from the hardware to determine the hardware type and sets the max_bufsize, as illustrated in the following example:
#include <sys/hippi.h> /* verify which platform */ if ( ioctl( fd_from_open, HIPIOC_GET_STATS, &hipstats ) < 0 ) { if ( errno == ENODEV ) fprintf(stderr, “%s: HIPPI board is down\n”, argv[0]), exit(1); else perror(“hipcntl: ioctl HIPIOC_GET_STATS failed”),exit(1); } /* set the maximum length for reads and writes */ /* HST_FORMAT_ID_MASK and HST_XIO are defined in hippi.h */ max_bufsize = ( (hipstats.hst_flags & HST_FORMAT_ID_MASK) == HST_XIO) ? (0x1000000 + 8) : (0x200000 + 8); |
![]() | Note: See Chapter 2 for complete details on the usage of IRIS HIPPI ioctl() calls (for example, “HIPIOC_GET_STATS”). |
This section describes how to program a module that uses IRIX' BSD-based sockets. Programs use this API to utilize the services of the network stack for the Internet Protocol Suite (IP). This API supports sharing the receive and/or transmit channels through the IRIS HIPPI subsystem with other upper layer protocols (such as HIPPI–FP).
The following files must be included in any program using the IRIX sockets API:
#include <sys/types.h> #include <sys/socket.h> |
For maximum throughput, DMA between the IRIS HIPPI board and the host application occurs directly to/from user application space. Due to the design of this DMA engine, the following rules must be followed by all application read()s and write()s within this API:
The specified buffers must be 8-byte–word–aligned.
The data bytecount must be a multiple of 8.
See memalign(3C) for a method of allocating 8-byte aligned memory.
To create a connection to the IP stack, use a series of calls similar to this:
s = socket (AF_INET, SOCK_DGRAM, 0); bind(s, &client_addr, sizeof(client_addr) ); connect(s, &serv_addr, sizeof(serv_addr) ); |
where client_addr corresponds to one of the available and configured IRIS HIPPI network interfaces (for example, hip0 configured with IP address 192.56.142.5).
For an application to transmit over its IRIS HIPPI socket, it simply does a write(), or any of its variations (such as send(), sendmsg(), or writev().) See “Maximum Size for write()s and read()s” and “Special Instructions” for additional details.
To retrieve data, the application simply does a read(), or any of its variations (such as recv(), recvmsg(), or readv().) All retrievals return data that has been put into message-correct order by the network stack. See “Maximum Size for write()s and read()s” and “Special Instructions” for additional details.
![]() | Tip: The IRIS HIPPI subsystem holds each accepted packet until an application reads it. If no application consumes the incoming packets, the HIPPI device will eventually stall for lack of buffer space. |