summaryrefslogtreecommitdiffstats
path: root/lib/route/link.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2012-10-09 17:57:22 (GMT)
committerThomas Graf <tgraf@redhat.com>2012-10-09 17:57:22 (GMT)
commit36ed882e003ee54cfde9a8f526007b3a66fff3a4 (patch)
tree79c4b6afa1c7b5ccc13beed959cea31aef08df84 /lib/route/link.c
parentd2876f8657b5d9187a8c2314c88dffa63ba2bc66 (diff)
downloadlibnl-36ed882e003ee54cfde9a8f526007b3a66fff3a4.zip
libnl-36ed882e003ee54cfde9a8f526007b3a66fff3a4.tar.gz
libnl-36ed882e003ee54cfde9a8f526007b3a66fff3a4.tar.bz2
link: Support IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUES
New functions: rtnl_link_set_num_tx_queues(link, nqueues) rtnl_link_get_num_tx_queues(link) rtnl_link_set_num_rx_queues(link, nqueues) rtnl_link_get_num_rx_queues(link) Signed-off-by: Thomas Graf <tgraf@redhat.com>
Diffstat (limited to 'lib/route/link.c')
-rw-r--r--lib/route/link.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index 0e14f45..4592bf0 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -50,6 +50,8 @@
#define LINK_ATTR_IFALIAS (1 << 19)
#define LINK_ATTR_NUM_VF (1 << 20)
#define LINK_ATTR_PROMISCUITY (1 << 21)
+#define LINK_ATTR_NUM_TX_QUEUES (1 << 22)
+#define LINK_ATTR_NUM_RX_QUEUES (1 << 23)
static struct nl_cache_ops rtnl_link_ops;
static struct nl_object_ops link_obj_ops;
@@ -256,6 +258,8 @@ static struct nla_policy link_policy[IFLA_MAX+1] = {
[IFLA_NUM_VF] = { .type = NLA_U32 },
[IFLA_AF_SPEC] = { .type = NLA_NESTED },
[IFLA_PROMISCUITY] = { .type = NLA_U32 },
+ [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
+ [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
};
static struct nla_policy link_info_policy[IFLA_INFO_MAX+1] = {
@@ -542,6 +546,16 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
link->ce_mask |= LINK_ATTR_PROMISCUITY;
}
+ if (tb[IFLA_NUM_TX_QUEUES]) {
+ link->l_num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]);
+ link->ce_mask |= LINK_ATTR_NUM_TX_QUEUES;
+ }
+
+ if (tb[IFLA_NUM_RX_QUEUES]) {
+ link->l_num_rx_queues = nla_get_u32(tb[IFLA_NUM_RX_QUEUES]);
+ link->ce_mask |= LINK_ATTR_NUM_RX_QUEUES;
+ };
+
err = pp->pp_cb((struct nl_object *) link, pp);
errout:
rtnl_link_af_ops_put(af_ops);
@@ -636,6 +650,12 @@ static void link_dump_details(struct nl_object *obj, struct nl_dump_params *p)
nl_dump_line(p, " ");
+ if (link->ce_mask & LINK_ATTR_NUM_TX_QUEUES)
+ nl_dump(p, "txq %u ", link->l_num_tx_queues);
+
+ if (link->ce_mask & LINK_ATTR_NUM_RX_QUEUES)
+ nl_dump(p, "rxq %u ", link->l_num_rx_queues);
+
if (link->ce_mask & LINK_ATTR_BRD)
nl_dump(p, "brd %s ", nl_addr2str(link->l_bcast, buf,
sizeof(buf)));
@@ -794,6 +814,8 @@ static int link_compare(struct nl_object *_a, struct nl_object *_b,
diff |= LINK_DIFF(IFALIAS, strcmp(a->l_ifalias, b->l_ifalias));
diff |= LINK_DIFF(NUM_VF, a->l_num_vf != b->l_num_vf);
diff |= LINK_DIFF(PROMISCUITY, a->l_promiscuity != b->l_promiscuity);
+ diff |= LINK_DIFF(NUM_TX_QUEUES,a->l_num_tx_queues != b->l_num_tx_queues);
+ diff |= LINK_DIFF(NUM_RX_QUEUES,a->l_num_rx_queues != b->l_num_rx_queues);
if (flags & LOOSE_COMPARISON)
diff |= LINK_DIFF(FLAGS,
@@ -828,6 +850,8 @@ static const struct trans_tbl link_attrs[] = {
__ADD(LINK_ATTR_IFALIAS, ifalias)
__ADD(LINK_ATTR_NUM_VF, num_vf)
__ADD(LINK_ATTR_PROMISCUITY, promiscuity)
+ __ADD(LINK_ATTR_NUM_TX_QUEUES, num_tx_queues)
+ __ADD(LINK_ATTR_NUM_RX_QUEUES, num_rx_queues)
};
static char *link_attrs2str(int attrs, char *buf, size_t len)
@@ -2049,6 +2073,67 @@ uint32_t rtnl_link_get_promiscuity(struct rtnl_link *link)
return link->l_promiscuity;
}
+/**
+ * Set number of TX queues
+ * @arg link Link object
+ * @arg nqueues Number of queues
+ *
+ * Sets the number of TX queues of the link object. The value is considered
+ * by the kernel when creating network devices that can be created via
+ * netlink. The value will be passed on to alloc_netdev_mqs()
+ *
+ * Therefore use of rtnl_link_set_num_tx_queues() only makes sense in
+ * combination with rtnl_link_add() or if the link object is used as a filter.
+ *
+ * @see rtnl_link_get_num_tx_queues()
+ */
+void rtnl_link_set_num_tx_queues(struct rtnl_link *link, uint32_t nqueues)
+{
+ link->l_num_tx_queues = nqueues;
+ link->ce_mask |= LINK_ATTR_NUM_TX_QUEUES;
+}
+
+/**
+ * Return number of TX queues
+ * @arg link Link object
+ *
+ * @return Number of TX queues or 0
+ */
+uint32_t rtnl_link_get_num_tx_queues(struct rtnl_link *link)
+{
+ return link->l_num_tx_queues;
+}
+
+/**
+ * Set number of RX queues
+ * @arg link Link object
+ * @arg nqueues Number of queues
+ *
+ * Sets the number of RX queues of the link object. The value is considered
+ * by the kernel when creating network devices that can be created via
+ * netlink. The value will be passed on to alloc_netdev_mqs()
+ *
+ * Therefore use of rtnl_link_set_num_rx_queues() only makes sense in
+ * combination with rtnl_link_add() or if the link object is used as a filter.
+ *
+ * @see rtnl_link_get_num_rx_queues()
+ */
+void rtnl_link_set_num_rx_queues(struct rtnl_link *link, uint32_t nqueues)
+{
+ link->l_num_rx_queues = nqueues;
+ link->ce_mask |= LINK_ATTR_NUM_RX_QUEUES;
+}
+
+/**
+ * Return number of RX queues
+ * @arg link Link object
+ *
+ * @return Number of RX queues or 0
+ */
+uint32_t rtnl_link_get_num_rx_queues(struct rtnl_link *link)
+{
+ return link->l_num_rx_queues;
+}
/** @} */