DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Tuning I/O resources

Configuring your system for high-speed modems

Configuration changes may be necessary to support transfer rates that are higher than 14,400bps. The optimum configuration varies from system to system. You may need to experiment in order to find the configuration that works best for you.

Three steps are needed to configure a system to support high-speed modems:

  1. Change the interrupt level

  2. Increase TTHOG and NCLIST

  3. Relink the kernel

Changing the interrupt trigger level

For serial ports using the 16550AFN UART chip, change the default values for the receive-interrupt trigger level in the sio_fifoctl kernel array from 14 to a lower value. This causes the 16550AFN to interrupt when there are fewer characters in its receive buffer and makes it less likely that the buffer will overflow during the time that the kernel takes to service the interrupt. This delay is referred to as the interrupt latency.

Possible values for the interrupt trigger level are 14 (the default), 8, 4, and 1. The default high value gives the best performance because the kernel has to service fewer interrupts. Setting the trigger level down to 4 is a good starting point. If the kernel has a high maximum interrupt latency, you may need to set the interrupt trigger level as low as 1.

At 115,200bps, three characters will take about 200 microseconds to arrive in the receive buffer. If the trigger level is set to 14, and the interrupt latency is longer than 200 microseconds, the UART's receive buffer will overflow. If the trigger level is reduced to 4, this allows 845 microseconds for the kernel to service the interrupt, but it will cause the UART to generate about three times as many interrupts.

See ``Serial device resources'' for details of how you can monitor and tune the performance of the serial driver.

The sio_fifoctl array is initialized in the file /etc/conf/pack.d/sio/space.c. The elements of the array correspond to the lowest seven bits of the minor numbers of the serial ports.

To determine the minor number for a serial port, type ls -l /dev/port and note the comma-separated integers that are listed just in front of the date. The first integer is the major number; the second number is the minor number.

As you are using a modem control port such as /dev/tty2A, subtract 128 from its minor number to remove the uppermost bit. The resulting number is the one to use for the sio_fifoctl array index.

For example, type ls -l /dev/tty2A and you might see:

   crw-r-----   1 uucp     uucp       5,136 Feb 01 17:07   /dev/tty2A
The minor number is the number after the comma in 5,136: 136. Subtracting 128 (because this is a modem control port) leaves 8. In this example, you would modify the ninth array element (sio_fifoctl[8]).
To modify an entry in the sio_fifoctl array:

  1. Log in as root and enter cd /etc/conf/pack.d/sio at the command line.

  2. Make a backup of the space.c file by entering cp space.c space.c.old at the command line.

  3. Edit the file /etc/conf/pack.d/sio/space.c to reflect the desired changes to the sio_fifoctl array.

  4. Go to line 155 of the file. This should place you at the beginning of the declaration of the sio_fifoctl array. (The comments to the right of the FCR_Rx14 | 15 lines do not appear in the shipped file, and need not be added):
    /*
     * 16550 FIFO control by minor dev: the high two bits are the RX fifo
     * trigger level, and the low four bits are the size-1 to use for the
     * TX fifo.  Statically initialize the array here, so that buffering
     * of individual channels can be disabled, e.g., for serial mouse.
     *
     * NB: The format of this array must not be changed, since it is
     * edited by the 'mkdev mouse' script, which relies on having one
     * entry per line.
     */
    unsigned char sio_fifoctl[CHANNELS] = {
    	0,		/* <- 1st array element, sio_fifoctl[0] */
    	FCR_Rx14 | 15,	/* <- 2nd array element, sio_fifoctl[1] */
    	FCR_Rx14 | 15,	/* <- 3rd array element, sio_fifoctl[2] */
    ...
    	FCR_Rx14 | 15,	/* <- 9th array element, sio_fifoctl[8] */
    ...
    

  5. Find the correct array element and change FCR_Rx14 to select the receive interrupt trigger level:

    0
    turns off buffering

    FCR_Rx1
    trigger level 1

    FCR_Rx4
    trigger level 4 (recommended for high-speed modems)

    FCR_Rx8
    trigger level 8

  6. Save the file and exit the editor.
Any changes that you make to space.c do not take effect until you relink the kernel and reboot the system -- see ``Relinking the kernel''.


WARNING: Do not enable buffering on a serial port that is attached to a mouse. The value of the sio_fifoctl element for any serial port that has a mouse attached should always be set to 0. If you enable the receive buffer on a serial mouse port, the mouse will exhibit strange behavior.

Increasing TTHOG and NCLIST

The TTHOG variable determines the size of the raw input queue of the terminal driver. It places a limit on the amount of data that can be written to the serial port by the modem. Increasing TTHOG increases the number of characters that can wait to be read from the port before characters are dropped.

The default value for TTHOG is 256 which is too small for high-speed throughput. A TTHOG value of 2048 is a good starting point. Even higher values may be called for in some applications. (Higher values for TTHOG also require you to increase the NCLIST kernel parameter.)

NCLIST determines the number of character list buffers (``cblocks'') that are available to the terminal driver. Each serial port is allowed to consume cblocks until it has used the number of bytes specified by the TTHOG kernel variable. Each cblock holds 64 bytes. This means that each serial port can use up to 32 cblocks for a TTHOG value of 2048, or 64 cblocks for a TTHOG value of 4096.

To increase TTHOG and NCLIST:

  1. Log in as root.

  2. Enter the following commands:

    cd /etc/conf/cf.d.
    ./configure.

  3. Select TTYs from the menu.

  4. You are prompted to enter a new value for NCLIST.

    Determine the new value for NCLIST using the following formula:

    new NCLIST = old NCLIST + ( TTHOG * fast_lines / 64 )

    If you have one fast modem, the number of fast serial lines, fast_lines, is 1. Use the value of TTHOG that you will set in step 7. For example, if TTHOG is to be set to 4096 and the old NCLIST value is 120, set the new value of NCLIST to 184 (calculated from 120 + ( 4096 * 1 / 64 )).

  5. Press <Enter> to see a prompt to enter a new value for TTHOG.

  6. Change the value of TTHOG to 2048 or 4096 as required.

  7. Press <Enter> to return to the main menu. Enter q to quit, and y to update the system configuration files.
Changes that you have made to kernel parameters and device drivers will not take effect until you relink the kernel, and reboot the system.

Next topic: Case study: I/O-bound multiuser system
Previous topic: Tuning serial device resources

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003