(Fast) Prio
[Queueing Discipline Modules]

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.

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.

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:
qdisc PRIO qdisc to be modified.
bands New number of bands.
Returns:
0 on success or a negative error code.

Definition at line 170 of file prio.c.

00171 {
00172         struct rtnl_prio *prio;
00173         
00174         prio = prio_alloc(qdisc);
00175         if (!prio)
00176                 return nl_errno(ENOMEM);
00177 
00178         prio->qp_bands = bands;
00179         prio->qp_mask |= SCH_PRIO_ATTR_BANDS;
00180 
00181         return 0;
00182 }

int rtnl_qdisc_prio_get_bands ( struct rtnl_qdisc *  qdisc  ) 
Parameters:
qdisc PRIO qdisc.
Returns:
Number of bands or a negative error code.

Definition at line 189 of file prio.c.

00190 {
00191         struct rtnl_prio *prio;
00192 
00193         prio = prio_qdisc(qdisc);
00194         if (prio && prio->qp_mask & SCH_PRIO_ATTR_BANDS)
00195                 return prio->qp_bands;
00196         else
00197                 return nl_errno(ENOMEM);
00198 }

int rtnl_qdisc_prio_set_priomap ( struct rtnl_qdisc *  qdisc,
uint8_t  priomap[],
int  len 
)
Parameters:
qdisc PRIO qdisc to be modified.
priomap New priority mapping.
len Length of priomap (# of elements).
Returns:
0 on success or a negative error code.

Definition at line 207 of file prio.c.

00209 {
00210         struct rtnl_prio *prio;
00211         int i;
00212 
00213         prio = prio_alloc(qdisc);
00214         if (!prio)
00215                 return nl_errno(ENOMEM);
00216 
00217         if (!(prio->qp_mask & SCH_PRIO_ATTR_BANDS))
00218                 return nl_error(EINVAL, "Set number of bands first");
00219 
00220         if ((len / sizeof(uint8_t)) > (TC_PRIO_MAX+1))
00221                 return nl_error(ERANGE, "priomap length out of bounds");
00222 
00223         for (i = 0; i <= TC_PRIO_MAX; i++) {
00224                 if (priomap[i] > prio->qp_bands)
00225                         return nl_error(ERANGE, "priomap element %d " \
00226                             "out of bounds, increase bands number");
00227         }
00228 
00229         memcpy(prio->qp_priomap, priomap, len);
00230         prio->qp_mask |= SCH_PRIO_ATTR_PRIOMAP;
00231 
00232         return 0;
00233 }

uint8_t* rtnl_qdisc_prio_get_priomap ( struct rtnl_qdisc *  qdisc  ) 
Parameters:
qdisc PRIO 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.

00242 {
00243         struct rtnl_prio *prio;
00244 
00245         prio = prio_qdisc(qdisc);
00246         if (prio && prio->qp_mask & SCH_PRIO_ATTR_PRIOMAP)
00247                 return prio->qp_priomap;
00248         else {
00249                 nl_errno(ENOENT);
00250                 return NULL;
00251         }
00252 }

char* rtnl_prio2str ( int  prio,
char *  buf,
size_t  size 
)
Parameters:
prio Priority.
buf Destination buffer
size Size 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.

00282 {
00283         return __type2str(prio, buf, size, prios, ARRAY_SIZE(prios));
00284 }

int rtnl_str2prio ( const char *  name  ) 
Parameters:
name Name 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.

00296 {
00297         return __str2type(name, prios, ARRAY_SIZE(prios));
00298 }


Generated on 30 Oct 2009 for libnl by  doxygen 1.6.1