aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2012-07-19 22:28:48 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-20 14:07:00 -0400
commit76ff5cc91935c51fcf1a6a99ffa28b97a6e7a884 (patch)
treee0b8367bc36b79986d0c5951485531377a39c680 /net/core/rtnetlink.c
parentd40156aa5ecbd51fed932ed4813df82b56e5ff4d (diff)
rtnl: allow to specify number of rx and tx queues on device creation
This patch introduces IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUES by which userspace can set number of rx and/or tx queues to be allocated for newly created netdevice. This overrides ops->get_num_[tr]x_queues() Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index db5a8ad8a79b..5bb1ebca2eb0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -771,6 +771,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
771 + nla_total_size(4) /* IFLA_LINK */ 771 + nla_total_size(4) /* IFLA_LINK */
772 + nla_total_size(4) /* IFLA_MASTER */ 772 + nla_total_size(4) /* IFLA_MASTER */
773 + nla_total_size(4) /* IFLA_PROMISCUITY */ 773 + nla_total_size(4) /* IFLA_PROMISCUITY */
774 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
775 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
774 + nla_total_size(1) /* IFLA_OPERSTATE */ 776 + nla_total_size(1) /* IFLA_OPERSTATE */
775 + nla_total_size(1) /* IFLA_LINKMODE */ 777 + nla_total_size(1) /* IFLA_LINKMODE */
776 + nla_total_size(ext_filter_mask 778 + nla_total_size(ext_filter_mask
@@ -889,6 +891,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
889 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 891 nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
890 nla_put_u32(skb, IFLA_GROUP, dev->group) || 892 nla_put_u32(skb, IFLA_GROUP, dev->group) ||
891 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) || 893 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
894 nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) ||
895 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
892 (dev->ifindex != dev->iflink && 896 (dev->ifindex != dev->iflink &&
893 nla_put_u32(skb, IFLA_LINK, dev->iflink)) || 897 nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
894 (dev->master && 898 (dev->master &&
@@ -1106,6 +1110,8 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1106 [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1110 [IFLA_AF_SPEC] = { .type = NLA_NESTED },
1107 [IFLA_EXT_MASK] = { .type = NLA_U32 }, 1111 [IFLA_EXT_MASK] = { .type = NLA_U32 },
1108 [IFLA_PROMISCUITY] = { .type = NLA_U32 }, 1112 [IFLA_PROMISCUITY] = { .type = NLA_U32 },
1113 [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
1114 [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
1109}; 1115};
1110EXPORT_SYMBOL(ifla_policy); 1116EXPORT_SYMBOL(ifla_policy);
1111 1117
@@ -1627,9 +1633,14 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
1627 unsigned int num_tx_queues = 1; 1633 unsigned int num_tx_queues = 1;
1628 unsigned int num_rx_queues = 1; 1634 unsigned int num_rx_queues = 1;
1629 1635
1630 if (ops->get_num_tx_queues) 1636 if (tb[IFLA_NUM_TX_QUEUES])
1637 num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]);
1638 else if (ops->get_num_tx_queues)
1631 num_tx_queues = ops->get_num_tx_queues(); 1639 num_tx_queues = ops->get_num_tx_queues();
1632 if (ops->get_num_rx_queues) 1640
1641 if (tb[IFLA_NUM_RX_QUEUES])
1642 num_rx_queues = nla_get_u32(tb[IFLA_NUM_RX_QUEUES]);
1643 else if (ops->get_num_rx_queues)
1633 num_rx_queues = ops->get_num_rx_queues(); 1644 num_rx_queues = ops->get_num_rx_queues();
1634 1645
1635 err = -ENOMEM; 1646 err = -ENOMEM;