libnl 1.1
(Fast) Prio
Queueing Discipline Modules

Attribute Modification

int rtnl_qdisc_prio_set_bands (struct rtnl_qdisc *qdisc, int bands)
 Set number of bands of PRIO qdisc.
int rtnl_qdisc_prio_get_bands (struct rtnl_qdisc *qdisc)
 Get number of bands of PRIO qdisc.
int rtnl_qdisc_prio_set_priomap (struct rtnl_qdisc *qdisc, uint8_t priomap[], int len)
 Set priomap of the PRIO qdisc.
uint8_t * rtnl_qdisc_prio_get_priomap (struct rtnl_qdisc *qdisc)
 Get priomap of a PRIO qdisc.

Priority Band Translations

char * rtnl_prio2str (int prio, char *buf, size_t size)
 Convert priority to character string.
int rtnl_str2prio (const char *name)
 Convert character string to priority.

Default Values

#define QDISC_PRIO_DEFAULT_BANDS   3
 Default number of bands.
#define QDISC_PRIO_DEFAULT_PRIOMAP   { 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }
 Default priority mapping.

Detailed Description

1) Typical PRIO configuration
 // Specify the maximal number of bands to be used for this PRIO qdisc.
 rtnl_qdisc_prio_set_bands(qdisc, QDISC_PRIO_DEFAULT_BANDS);

 // Provide a map assigning each priority to a band number.
 uint8_t map[] = QDISC_PRIO_DEFAULT_PRIOMAP;
 rtnl_qdisc_prio_set_priomap(qdisc, map, sizeof(map));

Function Documentation

int rtnl_qdisc_prio_set_bands ( struct rtnl_qdisc *  qdisc,
int  bands 
)
Parameters:
qdiscPRIO qdisc to be modified.
bandsNew number of bands.
Returns:
0 on success or a negative error code.

Definition at line 170 of file prio.c.

{
        struct rtnl_prio *prio;
        
        prio = prio_alloc(qdisc);
        if (!prio)
                return nl_errno(ENOMEM);

        prio->qp_bands = bands;
        prio->qp_mask |= SCH_PRIO_ATTR_BANDS;

        return 0;
}
int rtnl_qdisc_prio_get_bands ( struct rtnl_qdisc *  qdisc)
Parameters:
qdiscPRIO qdisc.
Returns:
Number of bands or a negative error code.

Definition at line 189 of file prio.c.

{
        struct rtnl_prio *prio;

        prio = prio_qdisc(qdisc);
        if (prio && prio->qp_mask & SCH_PRIO_ATTR_BANDS)
                return prio->qp_bands;
        else
                return nl_errno(ENOMEM);
}
int rtnl_qdisc_prio_set_priomap ( struct rtnl_qdisc *  qdisc,
uint8_t  priomap[],
int  len 
)
Parameters:
qdiscPRIO qdisc to be modified.
priomapNew priority mapping.
lenLength of priomap (# of elements).
Returns:
0 on success or a negative error code.

Definition at line 207 of file prio.c.

{
        struct rtnl_prio *prio;
        int i;

        prio = prio_alloc(qdisc);
        if (!prio)
                return nl_errno(ENOMEM);

        if (!(prio->qp_mask & SCH_PRIO_ATTR_BANDS))
                return nl_error(EINVAL, "Set number of bands first");

        if ((len / sizeof(uint8_t)) > (TC_PRIO_MAX+1))
                return nl_error(ERANGE, "priomap length out of bounds");

        for (i = 0; i <= TC_PRIO_MAX; i++) {
                if (priomap[i] > prio->qp_bands)
                        return nl_error(ERANGE, "priomap element %d " \
                            "out of bounds, increase bands number");
        }

        memcpy(prio->qp_priomap, priomap, len);
        prio->qp_mask |= SCH_PRIO_ATTR_PRIOMAP;

        return 0;
}
uint8_t* rtnl_qdisc_prio_get_priomap ( struct rtnl_qdisc *  qdisc)
Parameters:
qdiscPRIO qdisc.
Returns:
Priority mapping as array of size TC_PRIO_MAX+1 or NULL if an error occured.

Definition at line 241 of file prio.c.

{
        struct rtnl_prio *prio;

        prio = prio_qdisc(qdisc);
        if (prio && prio->qp_mask & SCH_PRIO_ATTR_PRIOMAP)
                return prio->qp_priomap;
        else {
                nl_errno(ENOENT);
                return NULL;
        }
}
char* rtnl_prio2str ( int  prio,
char *  buf,
size_t  size 
)
Parameters:
prioPriority.
bufDestination buffer
sizeSize of destination buffer.

Converts a priority to a character string and stores the result in the specified destination buffer.

Returns:
Name of priority as character string.

Definition at line 281 of file prio.c.

{
        return __type2str(prio, buf, size, prios, ARRAY_SIZE(prios));
}
int rtnl_str2prio ( const char *  name)
Parameters:
nameName of priority.

Converts the provided character string specifying a priority to the corresponding numeric value.

Returns:
Numeric priority or a negative value if no match was found.

Definition at line 295 of file prio.c.

{
        return __str2type(name, prios, ARRAY_SIZE(prios));
}