.. | .. |
---|
42 | 42 | [IFLA_IPOIB_UMCAST] = { .type = NLA_U16 }, |
---|
43 | 43 | }; |
---|
44 | 44 | |
---|
| 45 | +static unsigned int ipoib_get_max_num_queues(void) |
---|
| 46 | +{ |
---|
| 47 | + return min_t(unsigned int, num_possible_cpus(), 128); |
---|
| 48 | +} |
---|
| 49 | + |
---|
45 | 50 | static int ipoib_fill_info(struct sk_buff *skb, const struct net_device *dev) |
---|
46 | 51 | { |
---|
47 | 52 | struct ipoib_dev_priv *priv = ipoib_priv(dev); |
---|
.. | .. |
---|
122 | 127 | } else |
---|
123 | 128 | child_pkey = nla_get_u16(data[IFLA_IPOIB_PKEY]); |
---|
124 | 129 | |
---|
| 130 | + err = ipoib_intf_init(ppriv->ca, ppriv->port, dev->name, dev); |
---|
| 131 | + if (err) { |
---|
| 132 | + ipoib_warn(ppriv, "failed to initialize pkey device\n"); |
---|
| 133 | + return err; |
---|
| 134 | + } |
---|
| 135 | + |
---|
125 | 136 | err = __ipoib_vlan_add(ppriv, ipoib_priv(dev), |
---|
126 | 137 | child_pkey, IPOIB_RTNL_CHILD); |
---|
| 138 | + if (err) |
---|
| 139 | + return err; |
---|
127 | 140 | |
---|
128 | | - if (!err && data) |
---|
| 141 | + if (data) { |
---|
129 | 142 | err = ipoib_changelink(dev, tb, data, extack); |
---|
130 | | - return err; |
---|
| 143 | + if (err) { |
---|
| 144 | + unregister_netdevice(dev); |
---|
| 145 | + return err; |
---|
| 146 | + } |
---|
| 147 | + } |
---|
| 148 | + |
---|
| 149 | + return 0; |
---|
| 150 | +} |
---|
| 151 | + |
---|
| 152 | +static void ipoib_del_child_link(struct net_device *dev, struct list_head *head) |
---|
| 153 | +{ |
---|
| 154 | + struct ipoib_dev_priv *priv = ipoib_priv(dev); |
---|
| 155 | + |
---|
| 156 | + if (!priv->parent) |
---|
| 157 | + return; |
---|
| 158 | + |
---|
| 159 | + unregister_netdevice_queue(dev, head); |
---|
131 | 160 | } |
---|
132 | 161 | |
---|
133 | 162 | static size_t ipoib_get_size(const struct net_device *dev) |
---|
.. | .. |
---|
139 | 168 | |
---|
140 | 169 | static struct rtnl_link_ops ipoib_link_ops __read_mostly = { |
---|
141 | 170 | .kind = "ipoib", |
---|
| 171 | + .netns_refund = true, |
---|
142 | 172 | .maxtype = IFLA_IPOIB_MAX, |
---|
143 | 173 | .policy = ipoib_policy, |
---|
144 | 174 | .priv_size = sizeof(struct ipoib_dev_priv), |
---|
145 | 175 | .setup = ipoib_setup_common, |
---|
146 | 176 | .newlink = ipoib_new_child_link, |
---|
| 177 | + .dellink = ipoib_del_child_link, |
---|
147 | 178 | .changelink = ipoib_changelink, |
---|
148 | 179 | .get_size = ipoib_get_size, |
---|
149 | 180 | .fill_info = ipoib_fill_info, |
---|
| 181 | + .get_num_rx_queues = ipoib_get_max_num_queues, |
---|
| 182 | + .get_num_tx_queues = ipoib_get_max_num_queues, |
---|
150 | 183 | }; |
---|
151 | 184 | |
---|
| 185 | +struct rtnl_link_ops *ipoib_get_link_ops(void) |
---|
| 186 | +{ |
---|
| 187 | + return &ipoib_link_ops; |
---|
| 188 | +} |
---|
| 189 | + |
---|
152 | 190 | int __init ipoib_netlink_init(void) |
---|
153 | 191 | { |
---|
154 | 192 | return rtnl_link_register(&ipoib_link_ops); |
---|