Lines Matching refs:dev
34 static inline int dev_isalive(const struct net_device *dev) in dev_isalive() argument
36 return dev->reg_state <= NETREG_REGISTERED; in dev_isalive()
40 static ssize_t netdev_show(const struct device *dev, in netdev_show() argument
44 struct net_device *ndev = to_net_dev(dev); in netdev_show()
57 static ssize_t format_##field(const struct net_device *dev, char *buf) \
59 return sprintf(buf, format_string, dev->field); \
61 static ssize_t field##_show(struct device *dev, \
64 return netdev_show(dev, attr, buf, format_##field); \
76 static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, in netdev_store() argument
80 struct net_device *netdev = to_net_dev(dev); in netdev_store()
113 static ssize_t iflink_show(struct device *dev, struct device_attribute *attr, in iflink_show() argument
116 struct net_device *ndev = to_net_dev(dev); in iflink_show()
122 static ssize_t format_name_assign_type(const struct net_device *dev, char *buf) in format_name_assign_type() argument
124 return sprintf(buf, fmt_dec, dev->name_assign_type); in format_name_assign_type()
127 static ssize_t name_assign_type_show(struct device *dev, in name_assign_type_show() argument
131 struct net_device *ndev = to_net_dev(dev); in name_assign_type_show()
135 ret = netdev_show(dev, attr, buf, format_name_assign_type); in name_assign_type_show()
142 static ssize_t address_show(struct device *dev, struct device_attribute *attr, in address_show() argument
145 struct net_device *ndev = to_net_dev(dev); in address_show()
156 static ssize_t broadcast_show(struct device *dev, in broadcast_show() argument
159 struct net_device *ndev = to_net_dev(dev); in broadcast_show()
167 static int change_carrier(struct net_device *dev, unsigned long new_carrier) in change_carrier() argument
169 if (!netif_running(dev)) in change_carrier()
171 return dev_change_carrier(dev, (bool)new_carrier); in change_carrier()
174 static ssize_t carrier_store(struct device *dev, struct device_attribute *attr, in carrier_store() argument
177 struct net_device *netdev = to_net_dev(dev); in carrier_store()
185 return netdev_store(dev, attr, buf, len, change_carrier); in carrier_store()
188 static ssize_t carrier_show(struct device *dev, in carrier_show() argument
191 struct net_device *netdev = to_net_dev(dev); in carrier_show()
200 static ssize_t speed_show(struct device *dev, in speed_show() argument
203 struct net_device *netdev = to_net_dev(dev); in speed_show()
226 static ssize_t duplex_show(struct device *dev, in duplex_show() argument
229 struct net_device *netdev = to_net_dev(dev); in duplex_show()
266 static ssize_t dormant_show(struct device *dev, in dormant_show() argument
269 struct net_device *netdev = to_net_dev(dev); in dormant_show()
288 static ssize_t operstate_show(struct device *dev, in operstate_show() argument
291 const struct net_device *netdev = to_net_dev(dev); in operstate_show()
307 static ssize_t carrier_changes_show(struct device *dev, in carrier_changes_show() argument
311 struct net_device *netdev = to_net_dev(dev); in carrier_changes_show()
319 static ssize_t carrier_up_count_show(struct device *dev, in carrier_up_count_show() argument
323 struct net_device *netdev = to_net_dev(dev); in carrier_up_count_show()
329 static ssize_t carrier_down_count_show(struct device *dev, in carrier_down_count_show() argument
333 struct net_device *netdev = to_net_dev(dev); in carrier_down_count_show()
341 static int change_mtu(struct net_device *dev, unsigned long new_mtu) in change_mtu() argument
343 return dev_set_mtu(dev, (int)new_mtu); in change_mtu()
346 static ssize_t mtu_store(struct device *dev, struct device_attribute *attr, in mtu_store() argument
349 return netdev_store(dev, attr, buf, len, change_mtu); in mtu_store()
353 static int change_flags(struct net_device *dev, unsigned long new_flags) in change_flags() argument
355 return dev_change_flags(dev, (unsigned int)new_flags, NULL); in change_flags()
358 static ssize_t flags_store(struct device *dev, struct device_attribute *attr, in flags_store() argument
361 return netdev_store(dev, attr, buf, len, change_flags); in flags_store()
365 static ssize_t tx_queue_len_store(struct device *dev, in tx_queue_len_store() argument
372 return netdev_store(dev, attr, buf, len, dev_change_tx_queue_len); in tx_queue_len_store()
376 static int change_gro_flush_timeout(struct net_device *dev, unsigned long val) in change_gro_flush_timeout() argument
378 dev->gro_flush_timeout = val; in change_gro_flush_timeout()
382 static ssize_t gro_flush_timeout_store(struct device *dev, in gro_flush_timeout_store() argument
389 return netdev_store(dev, attr, buf, len, change_gro_flush_timeout); in gro_flush_timeout_store()
393 static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr, in ifalias_store() argument
396 struct net_device *netdev = to_net_dev(dev); in ifalias_store()
424 static ssize_t ifalias_show(struct device *dev, in ifalias_show() argument
427 const struct net_device *netdev = to_net_dev(dev); in ifalias_show()
438 static int change_group(struct net_device *dev, unsigned long new_group) in change_group() argument
440 dev_set_group(dev, (int)new_group); in change_group()
444 static ssize_t group_store(struct device *dev, struct device_attribute *attr, in group_store() argument
447 return netdev_store(dev, attr, buf, len, change_group); in group_store()
452 static int change_proto_down(struct net_device *dev, unsigned long proto_down) in change_proto_down() argument
454 return dev_change_proto_down(dev, (bool)proto_down); in change_proto_down()
457 static ssize_t proto_down_store(struct device *dev, in proto_down_store() argument
461 struct net_device *netdev = to_net_dev(dev); in proto_down_store()
469 return netdev_store(dev, attr, buf, len, change_proto_down); in proto_down_store()
473 static ssize_t phys_port_id_show(struct device *dev, in phys_port_id_show() argument
476 struct net_device *netdev = to_net_dev(dev); in phys_port_id_show()
501 static ssize_t phys_port_name_show(struct device *dev, in phys_port_name_show() argument
504 struct net_device *netdev = to_net_dev(dev); in phys_port_name_show()
530 static ssize_t phys_switch_id_show(struct device *dev, in phys_switch_id_show() argument
533 struct net_device *netdev = to_net_dev(dev); in phys_switch_id_show()
599 struct net_device *dev = to_net_dev(d); in netstat_show() local
606 if (dev_isalive(dev)) { in netstat_show()
608 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp); in netstat_show()
934 dev_put(queue->dev); in rx_queue_release()
940 struct device *dev = &queue->dev->dev; in rx_queue_namespace() local
943 if (dev->class && dev->class->ns_type) in rx_queue_namespace()
944 ns = dev->class->namespace(dev); in rx_queue_namespace()
965 static int rx_queue_add_kobject(struct net_device *dev, int index) in rx_queue_add_kobject() argument
967 struct netdev_rx_queue *queue = dev->_rx + index; in rx_queue_add_kobject()
974 dev_hold(queue->dev); in rx_queue_add_kobject()
976 kobj->kset = dev->queues_kset; in rx_queue_add_kobject()
982 if (dev->sysfs_rx_queue_group) { in rx_queue_add_kobject()
983 error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); in rx_queue_add_kobject()
999 net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) in net_rx_queue_update_kobjects() argument
1006 if (!dev->sysfs_rx_queue_group) in net_rx_queue_update_kobjects()
1010 error = rx_queue_add_kobject(dev, i); in net_rx_queue_update_kobjects()
1018 struct kobject *kobj = &dev->_rx[i].kobj; in net_rx_queue_update_kobjects()
1020 if (!refcount_read(&dev_net(dev)->count)) in net_rx_queue_update_kobjects()
1022 if (dev->sysfs_rx_queue_group) in net_rx_queue_update_kobjects()
1023 sysfs_remove_group(kobj, dev->sysfs_rx_queue_group); in net_rx_queue_update_kobjects()
1093 struct net_device *dev = queue->dev; in get_netdev_queue_index() local
1096 i = queue - dev->_tx; in get_netdev_queue_index()
1097 BUG_ON(i >= dev->num_tx_queues); in get_netdev_queue_index()
1105 struct net_device *dev = queue->dev; in traffic_class_show() local
1109 if (!netif_is_multiqueue(dev)) in traffic_class_show()
1115 dev = netdev_get_tx_queue(dev, index)->sb_dev ? : dev; in traffic_class_show()
1117 tc = netdev_txq_to_tc(dev, index); in traffic_class_show()
1128 return dev->num_tc < 0 ? sprintf(buf, "%u%d\n", tc, dev->num_tc) : in traffic_class_show()
1142 struct net_device *dev = queue->dev; in tx_maxrate_store() local
1152 if (!dev->netdev_ops->ndo_set_tx_maxrate) in tx_maxrate_store()
1163 if (dev->netdev_ops->ndo_set_tx_maxrate) in tx_maxrate_store()
1164 err = dev->netdev_ops->ndo_set_tx_maxrate(dev, index, rate); in tx_maxrate_store()
1294 struct net_device *dev = queue->dev; in xps_cpus_show() local
1299 if (!netif_is_multiqueue(dev)) in xps_cpus_show()
1307 if (dev->num_tc) { in xps_cpus_show()
1309 num_tc = dev->num_tc; in xps_cpus_show()
1316 dev = netdev_get_tx_queue(dev, index)->sb_dev ? : dev; in xps_cpus_show()
1318 tc = netdev_txq_to_tc(dev, index); in xps_cpus_show()
1331 dev_maps = rcu_dereference(dev->xps_cpus_map); in xps_cpus_show()
1365 struct net_device *dev = queue->dev; in xps_cpus_store() local
1370 if (!netif_is_multiqueue(dev)) in xps_cpus_store()
1392 err = netif_set_xps_queue(dev, mask, index); in xps_cpus_store()
1406 struct net_device *dev = queue->dev; in xps_rxqs_show() local
1415 if (dev->num_tc) { in xps_rxqs_show()
1416 num_tc = dev->num_tc; in xps_rxqs_show()
1417 tc = netdev_txq_to_tc(dev, index); in xps_rxqs_show()
1423 mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL); in xps_rxqs_show()
1430 dev_maps = rcu_dereference(dev->xps_rxqs_map); in xps_rxqs_show()
1434 for (j = -1; j = netif_attrmask_next(j, NULL, dev->num_rx_queues), in xps_rxqs_show()
1435 j < dev->num_rx_queues;) { in xps_rxqs_show()
1455 len = bitmap_print_to_pagebuf(false, buf, mask, dev->num_rx_queues); in xps_rxqs_show()
1468 struct net_device *dev = queue->dev; in xps_rxqs_store() local
1469 struct net *net = dev_net(dev); in xps_rxqs_store()
1476 mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL); in xps_rxqs_store()
1482 err = bitmap_parse(buf, len, mask, dev->num_rx_queues); in xps_rxqs_store()
1494 err = __netif_set_xps_queue(dev, mask, index, true); in xps_rxqs_store()
1524 dev_put(queue->dev); in netdev_queue_release()
1530 struct device *dev = &queue->dev->dev; in netdev_queue_namespace() local
1533 if (dev->class && dev->class->ns_type) in netdev_queue_namespace()
1534 ns = dev->class->namespace(dev); in netdev_queue_namespace()
1555 static int netdev_queue_add_kobject(struct net_device *dev, int index) in netdev_queue_add_kobject() argument
1557 struct netdev_queue *queue = dev->_tx + index; in netdev_queue_add_kobject()
1564 dev_hold(queue->dev); in netdev_queue_add_kobject()
1566 kobj->kset = dev->queues_kset; in netdev_queue_add_kobject()
1588 netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) in netdev_queue_update_kobjects() argument
1595 error = netdev_queue_add_kobject(dev, i); in netdev_queue_update_kobjects()
1603 struct netdev_queue *queue = dev->_tx + i; in netdev_queue_update_kobjects()
1605 if (!refcount_read(&dev_net(dev)->count)) in netdev_queue_update_kobjects()
1619 static int register_queue_kobjects(struct net_device *dev) in register_queue_kobjects() argument
1624 dev->queues_kset = kset_create_and_add("queues", in register_queue_kobjects()
1625 NULL, &dev->dev.kobj); in register_queue_kobjects()
1626 if (!dev->queues_kset) in register_queue_kobjects()
1628 real_rx = dev->real_num_rx_queues; in register_queue_kobjects()
1630 real_tx = dev->real_num_tx_queues; in register_queue_kobjects()
1632 error = net_rx_queue_update_kobjects(dev, 0, real_rx); in register_queue_kobjects()
1637 error = netdev_queue_update_kobjects(dev, 0, real_tx); in register_queue_kobjects()
1645 netdev_queue_update_kobjects(dev, txq, 0); in register_queue_kobjects()
1646 net_rx_queue_update_kobjects(dev, rxq, 0); in register_queue_kobjects()
1648 kset_unregister(dev->queues_kset); in register_queue_kobjects()
1653 static void remove_queue_kobjects(struct net_device *dev) in remove_queue_kobjects() argument
1658 real_rx = dev->real_num_rx_queues; in remove_queue_kobjects()
1660 real_tx = dev->real_num_tx_queues; in remove_queue_kobjects()
1662 net_rx_queue_update_kobjects(dev, real_rx, 0); in remove_queue_kobjects()
1663 netdev_queue_update_kobjects(dev, real_tx, 0); in remove_queue_kobjects()
1665 dev->real_num_rx_queues = 0; in remove_queue_kobjects()
1666 dev->real_num_tx_queues = 0; in remove_queue_kobjects()
1668 kset_unregister(dev->queues_kset); in remove_queue_kobjects()
1711 struct net_device *dev = to_net_dev(d); in netdev_uevent() local
1715 retval = add_uevent_var(env, "INTERFACE=%s", dev->name); in netdev_uevent()
1723 retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex); in netdev_uevent()
1735 struct net_device *dev = to_net_dev(d); in netdev_release() local
1737 BUG_ON(dev->reg_state != NETREG_RELEASED); in netdev_release()
1742 kfree(rcu_access_pointer(dev->ifalias)); in netdev_release()
1743 netdev_freemem(dev); in netdev_release()
1748 struct net_device *dev = to_net_dev(d); in net_namespace() local
1750 return dev_net(dev); in net_namespace()
1755 struct net_device *dev = to_net_dev(d); in net_get_ownership() local
1756 const struct net *net = dev_net(dev); in net_get_ownership()
1772 static int of_dev_node_match(struct device *dev, const void *data) in of_dev_node_match() argument
1776 if (dev->parent) in of_dev_node_match()
1777 ret = dev->parent->of_node == data; in of_dev_node_match()
1779 return ret == 0 ? dev->of_node == data : ret; in of_dev_node_match()
1793 struct device *dev; in of_find_net_device_by_node() local
1795 dev = class_find_device(&net_class, NULL, np, of_dev_node_match); in of_find_net_device_by_node()
1796 if (!dev) in of_find_net_device_by_node()
1799 return to_net_dev(dev); in of_find_net_device_by_node()
1809 struct device *dev = &ndev->dev; in netdev_unregister_kobject() local
1812 dev_set_uevent_suppress(dev, 1); in netdev_unregister_kobject()
1814 kobject_get(&dev->kobj); in netdev_unregister_kobject()
1818 pm_runtime_set_memalloc_noio(dev, false); in netdev_unregister_kobject()
1820 device_del(dev); in netdev_unregister_kobject()
1826 struct device *dev = &ndev->dev; in netdev_register_kobject() local
1830 device_initialize(dev); in netdev_register_kobject()
1831 dev->class = &net_class; in netdev_register_kobject()
1832 dev->platform_data = ndev; in netdev_register_kobject()
1833 dev->groups = groups; in netdev_register_kobject()
1835 dev_set_name(dev, "%s", ndev->name); in netdev_register_kobject()
1854 error = device_add(dev); in netdev_register_kobject()
1860 device_del(dev); in netdev_register_kobject()
1864 pm_runtime_set_memalloc_noio(dev, true); in netdev_register_kobject()