Skip to content

Commit

Permalink
ethtool: added missed adaptive-rx/tx, some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Feb 17, 2017
1 parent ba79ca2 commit 874e8db
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 69 deletions.
8 changes: 7 additions & 1 deletion client/compat.c
Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand Down
12 changes: 10 additions & 2 deletions client/suse/compat-suse.c
Expand Up @@ -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(&eth->coalesce.adaptive_rx, bval);
} else
if (ni_string_eq(opt, "adaptive-tx")) {
if (ni_parse_boolean(val, &bval) == 0)
ni_tristate_set(&eth->coalesce.adaptive_tx, bval);
} else
if (ni_string_eq(opt, "rx-usecs")) {
ni_parse_uint(val, &eth->coalesce.rx_usecs, 10);
} else
Expand Down
46 changes: 23 additions & 23 deletions schema/ethernet.xml
Expand Up @@ -58,29 +58,29 @@
<rx-mini type="uint32"/>
</ring>

<coalesce class="dict">
<aadaptive-rx type="tristate"/>
<adaptive-tx type="tristate"/>
<rx-usecs type="uint32"/>
<rx-frames type="uint32"/>
<rx-usecs-irq type="uint32"/>
<rx-frames-irq type="uint32"/>
<tx-usecs type="uint32"/>
<tx-frames type="uint32"/>
<tx-usecs-irq type="uint32"/>
<tx-frames-irq type="uint32"/>
<stats-block-usecs type="uint32"/>
<pkt-rate-low type="uint32"/>
<rx-usecs-low type="uint32"/>
<rx-frames-low type="uint32"/>
<tx-usecs-low type="uint32"/>
<tx-frames-low type="uint32"/>
<pkt-rate-high type="uint32"/>
<rx-usecs-high type="uint32"/>
<rx-frames-high type="uint32"/>
<tx-usecs-high type="uint32"/>
<tx-frames-high type="uint32"/>
</coalesce>
<coalesce class="dict">
<adaptive-rx type="tristate"/>
<adaptive-tx type="tristate"/>
<rx-usecs type="uint32"/>
<rx-frames type="uint32"/>
<rx-usecs-irq type="uint32"/>
<rx-frames-irq type="uint32"/>
<tx-usecs type="uint32"/>
<tx-frames type="uint32"/>
<tx-usecs-irq type="uint32"/>
<tx-frames-irq type="uint32"/>
<stats-block-usecs type="uint32"/>
<pkt-rate-low type="uint32"/>
<rx-usecs-low type="uint32"/>
<rx-frames-low type="uint32"/>
<tx-usecs-low type="uint32"/>
<tx-frames-low type="uint32"/>
<pkt-rate-high type="uint32"/>
<rx-usecs-high type="uint32"/>
<rx-frames-high type="uint32"/>
<tx-usecs-high type="uint32"/>
<tx-frames-high type="uint32"/>
</coalesce>

</define>

Expand Down
92 changes: 52 additions & 40 deletions src/dbus-objects/ethernet.c
Expand Up @@ -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;
Expand All @@ -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", &eth->coalesce.adaptive_rx))
eth->coalesce.adaptive_rx = NI_TRISTATE_DEFAULT;

if (!ni_dbus_dict_get_int32(argument, "adaptive-tx", &eth->coalesce.adaptive_tx))
eth->coalesce.adaptive_tx = NI_TRISTATE_DEFAULT;

if (!ni_dbus_dict_get_uint32(argument, "rx-usecs", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->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", &eth->coalesce.sample_interval)) {
eth->coalesce.sample_interval = 0;
eth->coalesce.sample_interval = NI_ETHTOOL_COALESCE_DEFAULT;
}

return TRUE;
Expand Down
6 changes: 3 additions & 3 deletions src/ethernet.c
Expand Up @@ -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
Expand All @@ -74,7 +74,7 @@ ni_ethernet_new(void)
ether->autoneg_enable = NI_TRISTATE_DEFAULT;
ni_ethtool_offload_init(&ether->offload);
ni_ethtool_ring_init(&ether->ring);
ni_ethtool_ring_coalesce_init(&ether->coalesce);
ni_ethtool_coalesce_init(&ether->coalesce);

return ether;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 874e8db

Please sign in to comment.