diff --git a/client/compat.c b/client/compat.c index 9b559f600..e8b8e4bfb 100644 --- a/client/compat.c +++ b/client/compat.c @@ -245,7 +245,7 @@ __ni_compat_generate_eth_offload_node(xml_node_t *parent, const ni_ethtool_offlo } -/* generate coalesce information */ +/* generate coalesce configuration */ static void ni_compat_generate_eth_coalesce_node(xml_node_t *parent, const ni_ethtool_coalesce_t *coalesce) { @@ -256,6 +256,12 @@ ni_compat_generate_eth_coalesce_node(xml_node_t *parent, const ni_ethtool_coales node = xml_node_new("coalesce", NULL); + if (coalesce->adaptive_rx != NI_TRISTATE_DEFAULT) + xml_node_new_element("adaptive-rx", node, ni_format_boolean(coalesce->adaptive_rx)); + + if (coalesce->adaptive_tx != NI_TRISTATE_DEFAULT) + xml_node_new_element("adaptive-tx", node, ni_format_boolean(coalesce->adaptive_tx)); + if (coalesce->rx_usecs != NI_ETHTOOL_RING_DEFAULT) { xml_node_new_element_uint("rx-usecs", node, coalesce->rx_usecs); } diff --git a/client/suse/compat-suse.c b/client/suse/compat-suse.c index 9062a50b6..f8922371b 100644 --- a/client/suse/compat-suse.c +++ b/client/suse/compat-suse.c @@ -1881,13 +1881,21 @@ try_add_ethtool_offload(ni_ethtool_offload_t *offload, const char *opt, const ch } } -/* get coalesce from wicked config */ +/* get coalesce from ifcfg config */ static void try_add_ethtool_coalesce(ni_netdev_t *dev, const char *opt, const char *val) { - ni_ethernet_t *eth = ni_netdev_get_ethernet(dev); + ni_bool_t bval; + if (ni_string_eq(opt, "adaptive-rx")) { + if (ni_parse_boolean(val, &bval) == 0) + ni_tristate_set(ð->coalesce.adaptive_rx, bval); + } else + if (ni_string_eq(opt, "adaptive-tx")) { + if (ni_parse_boolean(val, &bval) == 0) + ni_tristate_set(ð->coalesce.adaptive_tx, bval); + } else if (ni_string_eq(opt, "rx-usecs")) { ni_parse_uint(val, ð->coalesce.rx_usecs, 10); } else diff --git a/schema/ethernet.xml b/schema/ethernet.xml index 89c08e68b..82eb09c25 100644 --- a/schema/ethernet.xml +++ b/schema/ethernet.xml @@ -58,29 +58,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dbus-objects/ethernet.c b/src/dbus-objects/ethernet.c index 371f744b1..043287ae9 100644 --- a/src/dbus-objects/ethernet.c +++ b/src/dbus-objects/ethernet.c @@ -353,65 +353,71 @@ __ni_objectmodel_ethernet_get_coalesce(const ni_dbus_object_t *object, if (eth->coalesce.supported == NI_TRISTATE_DISABLE) return FALSE; + if (eth->coalesce.adaptive_rx != NI_TRISTATE_DEFAULT) + ni_dbus_dict_add_int32(result, "adaptive-rx", eth->coalesce.adaptive_rx); + + if (eth->coalesce.adaptive_tx != NI_TRISTATE_DEFAULT) + ni_dbus_dict_add_int32(result, "adaptive-tx", eth->coalesce.adaptive_tx); + if (eth->coalesce.rx_usecs != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-usecs", eth->coalesce.rx_usecs); + ni_dbus_dict_add_uint32(result, "rx-usecs", eth->coalesce.rx_usecs); } if (eth->coalesce.rx_frames != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-frames", eth->coalesce.rx_frames); + ni_dbus_dict_add_uint32(result, "rx-frames", eth->coalesce.rx_frames); } if (eth->coalesce.rx_usecs_irq != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-usecs-irq", eth->coalesce.rx_usecs_irq); + ni_dbus_dict_add_uint32(result, "rx-usecs-irq", eth->coalesce.rx_usecs_irq); } if (eth->coalesce.rx_frames_irq != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-frames-irq", eth->coalesce.rx_frames_irq); + ni_dbus_dict_add_uint32(result, "rx-frames-irq", eth->coalesce.rx_frames_irq); } if (eth->coalesce.tx_usecs != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-usecs", eth->coalesce.tx_usecs); + ni_dbus_dict_add_uint32(result, "tx-usecs", eth->coalesce.tx_usecs); } if (eth->coalesce.tx_frames != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-frames", eth->coalesce.tx_frames); + ni_dbus_dict_add_uint32(result, "tx-frames", eth->coalesce.tx_frames); } if (eth->coalesce.tx_usecs_irq != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-usecs-irq", eth->coalesce.tx_usecs_irq); + ni_dbus_dict_add_uint32(result, "tx-usecs-irq", eth->coalesce.tx_usecs_irq); } if (eth->coalesce.tx_frames_irq != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-frames-irq", eth->coalesce.tx_frames_irq); + ni_dbus_dict_add_uint32(result, "tx-frames-irq", eth->coalesce.tx_frames_irq); } if (eth->coalesce.stats_block_usecs != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "stats-block-usecs", eth->coalesce.stats_block_usecs); + ni_dbus_dict_add_uint32(result, "stats-block-usecs", eth->coalesce.stats_block_usecs); } if (eth->coalesce.pkt_rate_low != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "pkt-rate-low", eth->coalesce.pkt_rate_low); + ni_dbus_dict_add_uint32(result, "pkt-rate-low", eth->coalesce.pkt_rate_low); } if (eth->coalesce.rx_usecs_low != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-usecs-low", eth->coalesce.rx_usecs_low); + ni_dbus_dict_add_uint32(result, "rx-usecs-low", eth->coalesce.rx_usecs_low); } if (eth->coalesce.rx_frames_low != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-frames-low", eth->coalesce.rx_frames_low); + ni_dbus_dict_add_uint32(result, "rx-frames-low", eth->coalesce.rx_frames_low); } if (eth->coalesce.tx_usecs_low != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-usecs-low", eth->coalesce.tx_usecs_low); + ni_dbus_dict_add_uint32(result, "tx-usecs-low", eth->coalesce.tx_usecs_low); } if (eth->coalesce.tx_frames_low != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-frames-low", eth->coalesce.tx_frames_low); + ni_dbus_dict_add_uint32(result, "tx-frames-low", eth->coalesce.tx_frames_low); } if (eth->coalesce.pkt_rate_high != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "pkt-rate-high", eth->coalesce.pkt_rate_high); + ni_dbus_dict_add_uint32(result, "pkt-rate-high", eth->coalesce.pkt_rate_high); } if (eth->coalesce.rx_usecs_high != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-usecs-high", eth->coalesce.rx_usecs_high); + ni_dbus_dict_add_uint32(result, "rx-usecs-high", eth->coalesce.rx_usecs_high); } if (eth->coalesce.rx_frames_high != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "rx-frames-high", eth->coalesce.rx_frames_high); + ni_dbus_dict_add_uint32(result, "rx-frames-high", eth->coalesce.rx_frames_high); } if (eth->coalesce.tx_usecs_high != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-usecs-high", eth->coalesce.tx_usecs_high); + ni_dbus_dict_add_uint32(result, "tx-usecs-high", eth->coalesce.tx_usecs_high); } if (eth->coalesce.tx_frames_high != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "tx-frames-high", eth->coalesce.tx_frames_high); + ni_dbus_dict_add_uint32(result, "tx-frames-high", eth->coalesce.tx_frames_high); } if (eth->coalesce.sample_interval != NI_ETHTOOL_COALESCE_DEFAULT) { - ni_dbus_dict_add_int32(result, "sample-interval", eth->coalesce.sample_interval); + ni_dbus_dict_add_uint32(result, "sample-interval", eth->coalesce.sample_interval); } return TRUE; @@ -428,65 +434,71 @@ __ni_objectmodel_ethernet_set_coalesce(ni_dbus_object_t *object, if (!(eth = __ni_objectmodel_ethernet_write_handle(object, error))) return FALSE; + if (!ni_dbus_dict_get_int32(argument, "adaptive-rx", ð->coalesce.adaptive_rx)) + eth->coalesce.adaptive_rx = NI_TRISTATE_DEFAULT; + + if (!ni_dbus_dict_get_int32(argument, "adaptive-tx", ð->coalesce.adaptive_tx)) + eth->coalesce.adaptive_tx = NI_TRISTATE_DEFAULT; + if (!ni_dbus_dict_get_uint32(argument, "rx-usecs", ð->coalesce.rx_usecs)) { - eth->coalesce.rx_usecs = 0; + eth->coalesce.rx_usecs = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-frames", ð->coalesce.rx_frames)) { - eth->coalesce.rx_frames = 0; + eth->coalesce.rx_frames = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-usecs-irq", ð->coalesce.rx_usecs_irq)) { - eth->coalesce.rx_usecs_irq = 0; + eth->coalesce.rx_usecs_irq = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-frames-irq", ð->coalesce.rx_frames_irq)) { - eth->coalesce.rx_frames_irq = 0; + eth->coalesce.rx_frames_irq = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-usecs", ð->coalesce.tx_usecs)) { - eth->coalesce.tx_usecs = 0; + eth->coalesce.tx_usecs = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-frames", ð->coalesce.tx_frames)) { - eth->coalesce.tx_frames = 0; + eth->coalesce.tx_frames = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-usecs-irq", ð->coalesce.tx_usecs_irq)) { - eth->coalesce.tx_usecs_irq = 0; + eth->coalesce.tx_usecs_irq = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-frames-irq", ð->coalesce.tx_frames_irq)) { - eth->coalesce.tx_frames_irq = 0; + eth->coalesce.tx_frames_irq = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "stats-block-usecs", ð->coalesce.stats_block_usecs)) { - eth->coalesce.stats_block_usecs = 0; + eth->coalesce.stats_block_usecs = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "pkt-rate-low", ð->coalesce.pkt_rate_low)) { - eth->coalesce.pkt_rate_low = 0; + eth->coalesce.pkt_rate_low = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-usecs-low", ð->coalesce.rx_usecs_low)) { - eth->coalesce.rx_usecs_low = 0; + eth->coalesce.rx_usecs_low = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-frames-low", ð->coalesce.rx_frames_low)) { - eth->coalesce.rx_frames_low = 0; + eth->coalesce.rx_frames_low = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-usecs-low", ð->coalesce.tx_usecs_low)) { - eth->coalesce.tx_usecs_low = 0; + eth->coalesce.tx_usecs_low = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-frames-low", ð->coalesce.tx_frames_low)) { - eth->coalesce.tx_frames_low = 0; + eth->coalesce.tx_frames_low = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "pkt-rate-high", ð->coalesce.pkt_rate_high)) { - eth->coalesce.pkt_rate_high = 0; + eth->coalesce.pkt_rate_high = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-usecs-high", ð->coalesce.rx_usecs_high)) { - eth->coalesce.rx_usecs_high = 0; + eth->coalesce.rx_usecs_high = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "rx-frames-high", ð->coalesce.rx_frames_high)) { - eth->coalesce.rx_frames_high = 0; + eth->coalesce.rx_frames_high = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-usecs-high", ð->coalesce.tx_usecs_high)) { - eth->coalesce.tx_usecs_high = 0; + eth->coalesce.tx_usecs_high = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "tx-frames-high", ð->coalesce.tx_frames_high)) { - eth->coalesce.tx_frames_high = 0; + eth->coalesce.tx_frames_high = NI_ETHTOOL_COALESCE_DEFAULT; } if (!ni_dbus_dict_get_uint32(argument, "sample-interval", ð->coalesce.sample_interval)) { - eth->coalesce.sample_interval = 0; + eth->coalesce.sample_interval = NI_ETHTOOL_COALESCE_DEFAULT; } return TRUE; diff --git a/src/ethernet.c b/src/ethernet.c index 5f389e0ef..6b7748008 100644 --- a/src/ethernet.c +++ b/src/ethernet.c @@ -57,7 +57,7 @@ static void __ni_system_ethernet_set(const char *, ni_ethernet_t *); static int __ni_ethtool_get_gset(const char *, ni_ethernet_t *); static void ni_ethtool_offload_init(ni_ethtool_offload_t *); static void ni_ethtool_ring_init(ni_ethtool_ring_t *); -static void ni_ethtool_ring_coalesce_init(ni_ethtool_coalesce_t *coalesce); +static void ni_ethtool_coalesce_init(ni_ethtool_coalesce_t *coalesce); /* * Allocate ethernet struct @@ -74,7 +74,7 @@ ni_ethernet_new(void) ether->autoneg_enable = NI_TRISTATE_DEFAULT; ni_ethtool_offload_init(ðer->offload); ni_ethtool_ring_init(ðer->ring); - ni_ethtool_ring_coalesce_init(ðer->coalesce); + ni_ethtool_coalesce_init(ðer->coalesce); return ether; } @@ -700,7 +700,7 @@ ni_ethtool_validate_uint_param(unsigned int *curr, unsigned int wanted, } static void -ni_ethtool_ring_coalesce_init(ni_ethtool_coalesce_t *coalesce) +ni_ethtool_coalesce_init(ni_ethtool_coalesce_t *coalesce) { if (coalesce) { coalesce->supported = NI_TRISTATE_DEFAULT;