static void update_tc_infos(struct element *e, struct rtnl_tc *tc) { char buf[64]; snprintf(buf, sizeof(buf), "%u", rtnl_tc_get_mtu(tc)); element_update_info(e, "MTU", buf); snprintf(buf, sizeof(buf), "%u", rtnl_tc_get_mpu(tc)); element_update_info(e, "MPU", buf); snprintf(buf, sizeof(buf), "%u", rtnl_tc_get_overhead(tc)); element_update_info(e, "Overhead", buf); snprintf(buf, sizeof(buf), "%#x", rtnl_tc_get_handle(tc)); element_update_info(e, "Id", buf); snprintf(buf, sizeof(buf), "%#x", rtnl_tc_get_parent(tc)); element_update_info(e, "Parent", buf); }
/** * Compute a transmission time lookup table * @arg tc traffic control object * @arg spec Rate specification * @arg dst Destination buffer of RTNL_TC_RTABLE_SIZE uint32_t[]. * * Computes a table of RTNL_TC_RTABLE_SIZE entries specyfing the * transmission times for various packet sizes, e.g. the transmission * time for a packet of size \c pktsize could be looked up: * @code * txtime = table[pktsize >> log2(mtu)]; * @endcode */ int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *spec, uint32_t *dst) { uint32_t mtu = rtnl_tc_get_mtu(tc); uint32_t linktype = rtnl_tc_get_linktype(tc); uint8_t cell_log = spec->rs_cell_log; unsigned int size, i; spec->rs_mpu = rtnl_tc_get_mpu(tc); spec->rs_overhead = rtnl_tc_get_overhead(tc); if (mtu == 0) mtu = 2047; if (cell_log == UINT8_MAX) { /* * cell_log not specified, calculate it. It has to specify the * minimum number of rshifts required to break the MTU to below * RTNL_TC_RTABLE_SIZE. */ cell_log = 0; while ((mtu >> cell_log) >= RTNL_TC_RTABLE_SIZE) cell_log++; }