libnl  1.1.4

Attribute Modification

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

Priority Band Translations

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

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.
// Provide a map assigning each priority to a band number.
rtnl_qdisc_prio_set_priomap(qdisc, map, sizeof(map));

Function Documentation

◆ rtnl_qdisc_prio_set_bands()

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.

171 {
172  struct rtnl_prio *prio;
173 
174  prio = prio_alloc(qdisc);
175  if (!prio)
176  return nl_errno(ENOMEM);
177 
178  prio->qp_bands = bands;
179  prio->qp_mask |= SCH_PRIO_ATTR_BANDS;
180 
181  return 0;
182 }

◆ rtnl_qdisc_prio_get_bands()

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.

190 {
191  struct rtnl_prio *prio;
192 
193  prio = prio_qdisc(qdisc);
194  if (prio && prio->qp_mask & SCH_PRIO_ATTR_BANDS)
195  return prio->qp_bands;
196  else
197  return nl_errno(ENOMEM);
198 }

◆ rtnl_qdisc_prio_set_priomap()

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.

209 {
210  struct rtnl_prio *prio;
211  int i;
212 
213  prio = prio_alloc(qdisc);
214  if (!prio)
215  return nl_errno(ENOMEM);
216 
217  if (!(prio->qp_mask & SCH_PRIO_ATTR_BANDS))
218  return nl_error(EINVAL, "Set number of bands first");
219 
220  if ((len / sizeof(uint8_t)) > (TC_PRIO_MAX+1))
221  return nl_error(ERANGE, "priomap length out of bounds");
222 
223  for (i = 0; i <= TC_PRIO_MAX; i++) {
224  if (priomap[i] > prio->qp_bands)
225  return nl_error(ERANGE, "priomap element %d " \
226  "out of bounds, increase bands number");
227  }
228 
229  memcpy(prio->qp_priomap, priomap, len);
230  prio->qp_mask |= SCH_PRIO_ATTR_PRIOMAP;
231 
232  return 0;
233 }

◆ rtnl_qdisc_prio_get_priomap()

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.

242 {
243  struct rtnl_prio *prio;
244 
245  prio = prio_qdisc(qdisc);
246  if (prio && prio->qp_mask & SCH_PRIO_ATTR_PRIOMAP)
247  return prio->qp_priomap;
248  else {
249  nl_errno(ENOENT);
250  return NULL;
251  }
252 }

◆ rtnl_prio2str()

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.

282 {
283  return __type2str(prio, buf, size, prios, ARRAY_SIZE(prios));
284 }

◆ rtnl_str2prio()

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.

References rtnl_qdisc_ops::qo_kind.

296 {
297  return __str2type(name, prios, ARRAY_SIZE(prios));
298 }