Lines Matching refs:dev
41 static inline int dev_isalive(const struct net_device *dev) in dev_isalive() argument
43 return READ_ONCE(dev->reg_state) <= NETREG_REGISTERED; in dev_isalive()
128 static ssize_t netdev_show(const struct device *dev, in netdev_show() argument
132 struct net_device *ndev = to_net_dev(dev); in netdev_show()
145 static ssize_t format_##field(const struct net_device *dev, char *buf) \
147 return sysfs_emit(buf, format_string, READ_ONCE(dev->field)); \
149 static ssize_t field##_show(struct device *dev, \
152 return netdev_show(dev, attr, buf, format_##field); \
164 static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, in netdev_store() argument
168 struct net_device *netdev = to_net_dev(dev); in netdev_store()
180 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in netdev_store()
195 netdev_lock_store(struct device *dev, struct device_attribute *attr, in netdev_lock_store() argument
199 struct net_device *netdev = to_net_dev(dev); in netdev_lock_store()
231 static ssize_t iflink_show(struct device *dev, struct device_attribute *attr, in iflink_show() argument
234 struct net_device *ndev = to_net_dev(dev); in iflink_show()
240 static ssize_t format_name_assign_type(const struct net_device *dev, char *buf) in format_name_assign_type() argument
242 return sysfs_emit(buf, fmt_dec, READ_ONCE(dev->name_assign_type)); in format_name_assign_type()
245 static ssize_t name_assign_type_show(struct device *dev, in name_assign_type_show() argument
249 struct net_device *ndev = to_net_dev(dev); in name_assign_type_show()
253 ret = netdev_show(dev, attr, buf, format_name_assign_type); in name_assign_type_show()
260 static ssize_t address_show(struct device *dev, struct device_attribute *attr, in address_show() argument
263 struct net_device *ndev = to_net_dev(dev); in address_show()
278 static ssize_t broadcast_show(struct device *dev, in broadcast_show() argument
281 struct net_device *ndev = to_net_dev(dev); in broadcast_show()
292 static int change_carrier(struct net_device *dev, unsigned long new_carrier) in change_carrier() argument
294 if (!netif_running(dev)) in change_carrier()
296 return dev_change_carrier(dev, (bool)new_carrier); in change_carrier()
299 static ssize_t carrier_store(struct device *dev, struct device_attribute *attr, in carrier_store() argument
302 struct net_device *netdev = to_net_dev(dev); in carrier_store()
310 return netdev_store(dev, attr, buf, len, change_carrier); in carrier_store()
313 static ssize_t carrier_show(struct device *dev, in carrier_show() argument
316 struct net_device *netdev = to_net_dev(dev); in carrier_show()
319 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in carrier_show()
338 static ssize_t speed_show(struct device *dev, in speed_show() argument
341 struct net_device *netdev = to_net_dev(dev); in speed_show()
350 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in speed_show()
366 static ssize_t duplex_show(struct device *dev, in duplex_show() argument
369 struct net_device *netdev = to_net_dev(dev); in duplex_show()
378 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in duplex_show()
408 static ssize_t testing_show(struct device *dev, in testing_show() argument
411 struct net_device *netdev = to_net_dev(dev); in testing_show()
420 static ssize_t dormant_show(struct device *dev, in dormant_show() argument
423 struct net_device *netdev = to_net_dev(dev); in dormant_show()
442 static ssize_t operstate_show(struct device *dev, in operstate_show() argument
445 const struct net_device *netdev = to_net_dev(dev); in operstate_show()
459 static ssize_t carrier_changes_show(struct device *dev, in carrier_changes_show() argument
463 struct net_device *netdev = to_net_dev(dev); in carrier_changes_show()
471 static ssize_t carrier_up_count_show(struct device *dev, in carrier_up_count_show() argument
475 struct net_device *netdev = to_net_dev(dev); in carrier_up_count_show()
481 static ssize_t carrier_down_count_show(struct device *dev, in carrier_down_count_show() argument
485 struct net_device *netdev = to_net_dev(dev); in carrier_down_count_show()
493 static int change_mtu(struct net_device *dev, unsigned long new_mtu) in change_mtu() argument
495 return dev_set_mtu(dev, (int)new_mtu); in change_mtu()
498 static ssize_t mtu_store(struct device *dev, struct device_attribute *attr, in mtu_store() argument
501 return netdev_store(dev, attr, buf, len, change_mtu); in mtu_store()
505 static int change_flags(struct net_device *dev, unsigned long new_flags) in change_flags() argument
507 return dev_change_flags(dev, (unsigned int)new_flags, NULL); in change_flags()
510 static ssize_t flags_store(struct device *dev, struct device_attribute *attr, in flags_store() argument
513 return netdev_store(dev, attr, buf, len, change_flags); in flags_store()
517 static ssize_t tx_queue_len_store(struct device *dev, in tx_queue_len_store() argument
524 return netdev_store(dev, attr, buf, len, dev_change_tx_queue_len); in tx_queue_len_store()
528 static int change_gro_flush_timeout(struct net_device *dev, unsigned long val) in change_gro_flush_timeout() argument
530 netdev_set_gro_flush_timeout(dev, val); in change_gro_flush_timeout()
534 static ssize_t gro_flush_timeout_store(struct device *dev, in gro_flush_timeout_store() argument
541 return netdev_lock_store(dev, attr, buf, len, change_gro_flush_timeout); in gro_flush_timeout_store()
545 static int change_napi_defer_hard_irqs(struct net_device *dev, unsigned long val) in change_napi_defer_hard_irqs() argument
550 netdev_set_defer_hard_irqs(dev, (u32)val); in change_napi_defer_hard_irqs()
554 static ssize_t napi_defer_hard_irqs_store(struct device *dev, in napi_defer_hard_irqs_store() argument
561 return netdev_lock_store(dev, attr, buf, len, in napi_defer_hard_irqs_store()
566 static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr, in ifalias_store() argument
569 struct net_device *netdev = to_net_dev(dev); in ifalias_store()
581 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in ifalias_store()
596 static ssize_t ifalias_show(struct device *dev, in ifalias_show() argument
599 const struct net_device *netdev = to_net_dev(dev); in ifalias_show()
610 static int change_group(struct net_device *dev, unsigned long new_group) in change_group() argument
612 dev_set_group(dev, (int)new_group); in change_group()
616 static ssize_t group_store(struct device *dev, struct device_attribute *attr, in group_store() argument
619 return netdev_store(dev, attr, buf, len, change_group); in group_store()
624 static int change_proto_down(struct net_device *dev, unsigned long proto_down) in change_proto_down() argument
626 return dev_change_proto_down(dev, (bool)proto_down); in change_proto_down()
629 static ssize_t proto_down_store(struct device *dev, in proto_down_store() argument
633 return netdev_store(dev, attr, buf, len, change_proto_down); in proto_down_store()
637 static ssize_t phys_port_id_show(struct device *dev, in phys_port_id_show() argument
640 struct net_device *netdev = to_net_dev(dev); in phys_port_id_show()
644 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in phys_port_id_show()
658 static ssize_t phys_port_name_show(struct device *dev, in phys_port_name_show() argument
661 struct net_device *netdev = to_net_dev(dev); in phys_port_name_show()
665 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in phys_port_name_show()
679 static ssize_t phys_switch_id_show(struct device *dev, in phys_switch_id_show() argument
682 struct net_device *netdev = to_net_dev(dev); in phys_switch_id_show()
686 ret = sysfs_rtnl_lock(&dev->kobj, &attr->attr, netdev); in phys_switch_id_show()
710 struct device *dev = kobj_to_dev(kobj); in netdev_phys_is_visible() local
711 struct net_device *netdev = to_net_dev(dev); in netdev_phys_is_visible()
734 static ssize_t threaded_show(struct device *dev, in threaded_show() argument
737 struct net_device *netdev = to_net_dev(dev); in threaded_show()
750 static int modify_napi_threaded(struct net_device *dev, unsigned long val) in modify_napi_threaded() argument
754 if (list_empty(&dev->napi_list)) in modify_napi_threaded()
760 ret = netif_set_threaded(dev, val); in modify_napi_threaded()
765 static ssize_t threaded_store(struct device *dev, in threaded_store() argument
769 return netdev_lock_store(dev, attr, buf, len, modify_napi_threaded); in threaded_store()
812 struct net_device *dev = to_net_dev(d); in netstat_show() local
819 if (dev_isalive(dev)) { in netstat_show()
821 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp); in netstat_show()
1179 netdev_put(queue->dev, &queue->dev_tracker); in rx_queue_release()
1185 struct device *dev = &queue->dev->dev; in rx_queue_namespace() local
1188 if (dev->class && dev->class->namespace) in rx_queue_namespace()
1189 ns = dev->class->namespace(dev); in rx_queue_namespace()
1209 static int rx_queue_default_mask(struct net_device *dev, in rx_queue_default_mask() argument
1218 rps_default_mask = dev_net(dev)->core.rps_default_mask; in rx_queue_default_mask()
1230 static int rx_queue_add_kobject(struct net_device *dev, int index) in rx_queue_add_kobject() argument
1232 struct netdev_rx_queue *queue = dev->_rx + index; in rx_queue_add_kobject()
1248 netdev_warn_once(dev, "Cannot re-add rx queues before their removal completed"); in rx_queue_add_kobject()
1255 netdev_hold(queue->dev, &queue->dev_tracker, GFP_KERNEL); in rx_queue_add_kobject()
1257 kobj->kset = dev->queues_kset; in rx_queue_add_kobject()
1268 if (dev->sysfs_rx_queue_group) { in rx_queue_add_kobject()
1269 error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); in rx_queue_add_kobject()
1274 error = rx_queue_default_mask(dev, queue); in rx_queue_add_kobject()
1289 static int rx_queue_change_owner(struct net_device *dev, int index, kuid_t kuid, in rx_queue_change_owner() argument
1292 struct netdev_rx_queue *queue = dev->_rx + index; in rx_queue_change_owner()
1300 if (dev->sysfs_rx_queue_group) in rx_queue_change_owner()
1302 kobj, dev->sysfs_rx_queue_group, kuid, kgid); in rx_queue_change_owner()
1309 net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) in net_rx_queue_update_kobjects() argument
1316 if (!dev->sysfs_rx_queue_group) in net_rx_queue_update_kobjects()
1320 error = rx_queue_add_kobject(dev, i); in net_rx_queue_update_kobjects()
1328 struct netdev_rx_queue *queue = &dev->_rx[i]; in net_rx_queue_update_kobjects()
1331 if (!refcount_read(&dev_net(dev)->ns.count)) in net_rx_queue_update_kobjects()
1333 if (dev->sysfs_rx_queue_group) in net_rx_queue_update_kobjects()
1334 sysfs_remove_group(kobj, dev->sysfs_rx_queue_group); in net_rx_queue_update_kobjects()
1345 static int net_rx_queue_change_owner(struct net_device *dev, int num, in net_rx_queue_change_owner() argument
1353 if (!dev->sysfs_rx_queue_group) in net_rx_queue_change_owner()
1357 error = rx_queue_change_owner(dev, i, kuid, kgid); in net_rx_queue_change_owner()
1427 struct net_device *dev = queue->dev; in get_netdev_queue_index() local
1430 i = queue - dev->_tx; in get_netdev_queue_index()
1431 BUG_ON(i >= dev->num_tx_queues); in get_netdev_queue_index()
1439 struct net_device *dev = queue->dev; in traffic_class_show() local
1442 if (!netif_is_multiqueue(dev)) in traffic_class_show()
1445 ret = sysfs_rtnl_lock(kobj, attr, queue->dev); in traffic_class_show()
1452 dev = netdev_get_tx_queue(dev, index)->sb_dev ? : dev; in traffic_class_show()
1454 num_tc = dev->num_tc; in traffic_class_show()
1455 tc = netdev_txq_to_tc(dev, index); in traffic_class_show()
1485 struct net_device *dev = queue->dev; in tx_maxrate_store() local
1494 if (!dev->netdev_ops->ndo_set_tx_maxrate) in tx_maxrate_store()
1501 err = sysfs_rtnl_lock(kobj, attr, dev); in tx_maxrate_store()
1506 netdev_lock_ops(dev); in tx_maxrate_store()
1507 if (dev->netdev_ops->ndo_set_tx_maxrate) in tx_maxrate_store()
1508 err = dev->netdev_ops->ndo_set_tx_maxrate(dev, index, rate); in tx_maxrate_store()
1509 netdev_unlock_ops(dev); in tx_maxrate_store()
1711 static ssize_t xps_queue_show(struct net_device *dev, unsigned int index, in xps_queue_show() argument
1720 dev_maps = rcu_dereference(dev->xps_maps[type]); in xps_queue_show()
1726 (type == XPS_CPUS ? nr_cpu_ids : dev->num_rx_queues); in xps_queue_show()
1764 struct net_device *dev = queue->dev; in xps_cpus_show() local
1768 if (!netif_is_multiqueue(dev)) in xps_cpus_show()
1773 ret = sysfs_rtnl_lock(kobj, attr, queue->dev); in xps_cpus_show()
1778 dev = netdev_get_tx_queue(dev, index)->sb_dev ? : dev; in xps_cpus_show()
1780 tc = netdev_txq_to_tc(dev, index); in xps_cpus_show()
1789 dev_hold(dev); in xps_cpus_show()
1792 len = xps_queue_show(dev, index, tc, buf, XPS_CPUS); in xps_cpus_show()
1794 dev_put(dev); in xps_cpus_show()
1802 struct net_device *dev = queue->dev; in xps_cpus_store() local
1807 if (!netif_is_multiqueue(dev)) in xps_cpus_store()
1824 err = sysfs_rtnl_lock(kobj, attr, dev); in xps_cpus_store()
1830 err = netif_set_xps_queue(dev, mask, index); in xps_cpus_store()
1844 struct net_device *dev = queue->dev; in xps_rxqs_show() local
1850 ret = sysfs_rtnl_lock(kobj, attr, dev); in xps_rxqs_show()
1854 tc = netdev_txq_to_tc(dev, index); in xps_rxqs_show()
1859 dev_hold(dev); in xps_rxqs_show()
1862 ret = tc >= 0 ? xps_queue_show(dev, index, tc, buf, XPS_RXQS) : -EINVAL; in xps_rxqs_show()
1863 dev_put(dev); in xps_rxqs_show()
1871 struct net_device *dev = queue->dev; in xps_rxqs_store() local
1872 struct net *net = dev_net(dev); in xps_rxqs_store()
1880 mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL); in xps_rxqs_store()
1886 err = bitmap_parse(buf, len, mask, dev->num_rx_queues); in xps_rxqs_store()
1892 err = sysfs_rtnl_lock(kobj, attr, dev); in xps_rxqs_store()
1899 err = __netif_set_xps_queue(dev, mask, index, XPS_RXQS); in xps_rxqs_store()
1929 netdev_put(queue->dev, &queue->dev_tracker); in netdev_queue_release()
1935 struct device *dev = &queue->dev->dev; in netdev_queue_namespace() local
1938 if (dev->class && dev->class->namespace) in netdev_queue_namespace()
1939 ns = dev->class->namespace(dev); in netdev_queue_namespace()
1959 static bool netdev_uses_bql(const struct net_device *dev) in netdev_uses_bql() argument
1961 if (dev->lltx || (dev->priv_flags & IFF_NO_QUEUE)) in netdev_uses_bql()
1967 static int netdev_queue_add_kobject(struct net_device *dev, int index) in netdev_queue_add_kobject() argument
1969 struct netdev_queue *queue = dev->_tx + index; in netdev_queue_add_kobject()
1985 netdev_warn_once(dev, "Cannot re-add tx queues before their removal completed"); in netdev_queue_add_kobject()
1992 netdev_hold(queue->dev, &queue->dev_tracker, GFP_KERNEL); in netdev_queue_add_kobject()
1994 kobj->kset = dev->queues_kset; in netdev_queue_add_kobject()
2005 if (netdev_uses_bql(dev)) { in netdev_queue_add_kobject()
2040 netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) in netdev_queue_update_kobjects() argument
2050 WARN(dev->reg_state == NETREG_UNREGISTERING && new_num > old_num, in netdev_queue_update_kobjects()
2054 error = netdev_queue_add_kobject(dev, i); in netdev_queue_update_kobjects()
2062 struct netdev_queue *queue = dev->_tx + i; in netdev_queue_update_kobjects()
2064 if (!refcount_read(&dev_net(dev)->ns.count)) in netdev_queue_update_kobjects()
2067 if (netdev_uses_bql(dev)) in netdev_queue_update_kobjects()
2080 static int net_tx_queue_change_owner(struct net_device *dev, int num, in net_tx_queue_change_owner() argument
2088 error = tx_queue_change_owner(dev, i, kuid, kgid); in net_tx_queue_change_owner()
2099 static int register_queue_kobjects(struct net_device *dev) in register_queue_kobjects() argument
2104 dev->queues_kset = kset_create_and_add("queues", in register_queue_kobjects()
2105 NULL, &dev->dev.kobj); in register_queue_kobjects()
2106 if (!dev->queues_kset) in register_queue_kobjects()
2108 real_rx = dev->real_num_rx_queues; in register_queue_kobjects()
2110 real_tx = dev->real_num_tx_queues; in register_queue_kobjects()
2112 error = net_rx_queue_update_kobjects(dev, 0, real_rx); in register_queue_kobjects()
2117 error = netdev_queue_update_kobjects(dev, 0, real_tx); in register_queue_kobjects()
2125 netdev_queue_update_kobjects(dev, txq, 0); in register_queue_kobjects()
2126 net_rx_queue_update_kobjects(dev, rxq, 0); in register_queue_kobjects()
2128 kset_unregister(dev->queues_kset); in register_queue_kobjects()
2158 static void remove_queue_kobjects(struct net_device *dev) in remove_queue_kobjects() argument
2163 real_rx = dev->real_num_rx_queues; in remove_queue_kobjects()
2165 real_tx = dev->real_num_tx_queues; in remove_queue_kobjects()
2167 net_rx_queue_update_kobjects(dev, real_rx, 0); in remove_queue_kobjects()
2168 netdev_queue_update_kobjects(dev, real_tx, 0); in remove_queue_kobjects()
2170 netdev_lock_ops(dev); in remove_queue_kobjects()
2171 dev->real_num_rx_queues = 0; in remove_queue_kobjects()
2172 dev->real_num_tx_queues = 0; in remove_queue_kobjects()
2173 netdev_unlock_ops(dev); in remove_queue_kobjects()
2175 kset_unregister(dev->queues_kset); in remove_queue_kobjects()
2218 const struct net_device *dev = to_net_dev(d); in netdev_uevent() local
2222 retval = add_uevent_var(env, "INTERFACE=%s", dev->name); in netdev_uevent()
2230 retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex); in netdev_uevent()
2242 struct net_device *dev = to_net_dev(d); in netdev_release() local
2244 BUG_ON(dev->reg_state != NETREG_RELEASED); in netdev_release()
2249 kfree(rcu_access_pointer(dev->ifalias)); in netdev_release()
2250 kvfree(dev); in netdev_release()
2255 const struct net_device *dev = to_net_dev(d); in net_namespace() local
2257 return dev_net(dev); in net_namespace()
2262 const struct net_device *dev = to_net_dev(d); in net_get_ownership() local
2263 const struct net *net = dev_net(dev); in net_get_ownership()
2279 static int of_dev_node_match(struct device *dev, const void *data) in of_dev_node_match() argument
2281 for (; dev; dev = dev->parent) { in of_dev_node_match()
2282 if (dev->of_node == data) in of_dev_node_match()
2300 struct device *dev; in of_find_net_device_by_node() local
2302 dev = class_find_device(&net_class, NULL, np, of_dev_node_match); in of_find_net_device_by_node()
2303 if (!dev) in of_find_net_device_by_node()
2306 return to_net_dev(dev); in of_find_net_device_by_node()
2316 struct device *dev = &ndev->dev; in netdev_unregister_kobject() local
2319 dev_set_uevent_suppress(dev, 1); in netdev_unregister_kobject()
2321 kobject_get(&dev->kobj); in netdev_unregister_kobject()
2325 pm_runtime_set_memalloc_noio(dev, false); in netdev_unregister_kobject()
2327 device_del(dev); in netdev_unregister_kobject()
2333 struct device *dev = &ndev->dev; in netdev_register_kobject() local
2337 device_initialize(dev); in netdev_register_kobject()
2338 dev->class = &net_class; in netdev_register_kobject()
2339 dev->platform_data = ndev; in netdev_register_kobject()
2340 dev->groups = groups; in netdev_register_kobject()
2342 dev_set_name(dev, "%s", ndev->name); in netdev_register_kobject()
2356 error = device_add(dev); in netdev_register_kobject()
2362 device_del(dev); in netdev_register_kobject()
2366 pm_runtime_set_memalloc_noio(dev, true); in netdev_register_kobject()
2379 struct device *dev = &ndev->dev; in netdev_change_owner() local
2391 error = device_change_owner(dev, new_uid, new_gid); in netdev_change_owner()