Skip to content

Commit

Permalink
ethtool: handle coalesce parameters (bsc#1007909,gh##685)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirmoy Das committed Feb 16, 2017
1 parent 1e8d157 commit 9c15f3f
Show file tree
Hide file tree
Showing 6 changed files with 646 additions and 69 deletions.
80 changes: 80 additions & 0 deletions client/compat.c
Expand Up @@ -245,6 +245,85 @@ __ni_compat_generate_eth_offload_node(xml_node_t *parent, const ni_ethtool_offlo

}

/* generate coalesce information */
static void
ni_compat_generate_eth_coalesce_node(xml_node_t *parent, const ni_ethtool_coalesce_t *coalesce)
{
xml_node_t *node;

if (!parent || !coalesce)
return;

node = xml_node_new("coalesce", NULL);

if (coalesce->rx_usecs != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-usecs", node, coalesce->rx_usecs);
}
if (coalesce->rx_frames != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-frames", node, coalesce->rx_frames);
}
if (coalesce->rx_usecs_irq != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-usecs-irq", node, coalesce->rx_usecs_irq);
}
if (coalesce->rx_frames_irq != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-frames-irq", node, coalesce->rx_frames_irq);
}
if (coalesce->tx_usecs != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-usecs", node, coalesce->tx_usecs);
}
if (coalesce->tx_frames != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-frames", node, coalesce->tx_frames);
}
if (coalesce->tx_usecs_irq != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-usecs-irq", node, coalesce->tx_usecs_irq);
}
if (coalesce->tx_frames_irq != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-frames-irq", node, coalesce->tx_frames_irq);
}
if (coalesce->stats_block_usecs != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("stats-block-usecs", node, coalesce->stats_block_usecs);
}
if (coalesce->pkt_rate_low != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("pkt-rate-low", node, coalesce->pkt_rate_low);
}
if (coalesce->rx_usecs_low != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-usecs-low", node, coalesce->rx_usecs_low);
}
if (coalesce->rx_frames_low != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-frames-low", node, coalesce->rx_frames_low);
}
if (coalesce->tx_usecs_low != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-usecs-low", node, coalesce->tx_usecs_low);
}
if (coalesce->tx_frames_low != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-frames-low", node, coalesce->tx_frames_low);
}
if (coalesce->pkt_rate_high != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("pkt-rate-high", node, coalesce->pkt_rate_high);
}
if (coalesce->rx_usecs_high != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-usecs-high", node, coalesce->rx_usecs_high);
}
if (coalesce->rx_frames_high != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("rx-frames-high", node, coalesce->rx_frames_high);
}
if (coalesce->tx_usecs_high != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-usecs-high", node, coalesce->tx_usecs_high);
}
if (coalesce->tx_frames_high != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("tx-frames-high", node, coalesce->tx_frames_high);
}
if (coalesce->sample_interval != NI_ETHTOOL_RING_DEFAULT) {
xml_node_new_element_uint("sample-interval", node, coalesce->sample_interval);
}

if (node->children)
xml_node_add_child(parent, node);
else
xml_node_free(node);

}

/* generate ring information */
static void
ni_compat_generate_eth_ring_node(xml_node_t *parent, const ni_ethtool_ring_t *ring)
Expand Down Expand Up @@ -318,6 +397,7 @@ __ni_compat_generate_eth_node(xml_node_t *child, const ni_ethernet_t *eth)

__ni_compat_generate_eth_offload_node(child, &eth->offload);
ni_compat_generate_eth_ring_node(child, &eth->ring);
ni_compat_generate_eth_coalesce_node(child, &eth->coalesce);
}

static ni_bool_t
Expand Down
75 changes: 75 additions & 0 deletions client/suse/compat-suse.c
Expand Up @@ -1881,6 +1881,75 @@ try_add_ethtool_offload(ni_ethtool_offload_t *offload, const char *opt, const ch
}
}

/* get coalesce from wicked 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);

if (ni_string_eq(opt, "rx-usecs")) {
ni_parse_uint(val, &eth->coalesce.rx_usecs, 10);
} else
if (ni_string_eq(opt, "rx-frames")) {
ni_parse_uint(val, &eth->coalesce.rx_frames, 10);
} else
if (ni_string_eq(opt, "rx-usecs-irq")) {
ni_parse_uint(val, &eth->coalesce.rx_usecs_irq, 10);
} else
if (ni_string_eq(opt, "rx-frames-irq")) {
ni_parse_uint(val, &eth->coalesce.rx_frames_irq, 10);
} else
if (ni_string_eq(opt, "tx-usecs")) {
ni_parse_uint(val, &eth->coalesce.tx_usecs, 10);
} else
if (ni_string_eq(opt, "tx-frames")) {
ni_parse_uint(val, &eth->coalesce.tx_frames, 10);
} else
if (ni_string_eq(opt, "tx-usecs-irq")) {
ni_parse_uint(val, &eth->coalesce.tx_usecs_irq, 10);
} else
if (ni_string_eq(opt, "tx-frames-irq")) {
ni_parse_uint(val, &eth->coalesce.tx_frames_irq, 10);
} else
if (ni_string_eq(opt, "stats-block-usecs")) {
ni_parse_uint(val, &eth->coalesce.stats_block_usecs, 10);
} else
if (ni_string_eq(opt, "pkt-rate-low")) {
ni_parse_uint(val, &eth->coalesce.pkt_rate_low, 10);
} else
if (ni_string_eq(opt, "rx-usecs-low")) {
ni_parse_uint(val, &eth->coalesce.rx_usecs_low, 10);
} else
if (ni_string_eq(opt, "rx-frames-low")) {
ni_parse_uint(val, &eth->coalesce.rx_frames_low, 10);
} else
if (ni_string_eq(opt, "tx-usecs-low")) {
ni_parse_uint(val, &eth->coalesce.tx_usecs_low, 10);
} else
if (ni_string_eq(opt, "tx-frames-low")) {
ni_parse_uint(val, &eth->coalesce.tx_frames_low, 10);
} else
if (ni_string_eq(opt, "pkt-rate-high")) {
ni_parse_uint(val, &eth->coalesce.pkt_rate_high, 10);
} else
if (ni_string_eq(opt, "rx-usecs-high")) {
ni_parse_uint(val, &eth->coalesce.rx_usecs_high, 10);
} else
if (ni_string_eq(opt, "rx-frames-high")) {
ni_parse_uint(val, &eth->coalesce.rx_frames_high, 10);
} else
if (ni_string_eq(opt, "tx-usecs-high")) {
ni_parse_uint(val, &eth->coalesce.tx_usecs_high, 10);
} else
if (ni_string_eq(opt, "tx-frames-high")) {
ni_parse_uint(val, &eth->coalesce.tx_frames_high, 10);
} else
if (ni_string_eq(opt, "sample-interval")) {
ni_parse_uint(val, &eth->coalesce.sample_interval, 10);
}
}

/* get ringparams from wicked config */
static void
try_add_ethtool_ring(ni_netdev_t *dev, const char *opt, const char *val)
Expand Down Expand Up @@ -1927,6 +1996,12 @@ try_add_ethtool_options(ni_netdev_t *dev, const char *type,
try_add_ethtool_ring(dev, opts->data[i],
opts->data[i + 1]);
}
} else
if (ni_string_eq(type, "-C") || ni_string_eq(type, "--coalesce")) {
for (i = start; (i + 1) < opts->count; i+=2) {
try_add_ethtool_coalesce(dev, opts->data[i],
opts->data[i + 1]);
}
}
}

Expand Down
36 changes: 36 additions & 0 deletions include/wicked/ethernet.h
Expand Up @@ -68,6 +68,41 @@ typedef struct ni_ethtool_ring {
unsigned int rx_mini;
} ni_ethtool_ring_t;

#define NI_ETHTOOL_COALESCE_DEFAULT -1U

typedef struct ni_ethtool_coalesce {
ni_tristate_t supported;

ni_tristate_t adaptive_tx;
ni_tristate_t adaptive_rx;

unsigned int pkt_rate_low;
unsigned int pkt_rate_high;

unsigned int sample_interval;
unsigned int stats_block_usecs;

unsigned int rx_usecs;
unsigned int rx_usecs_irq;
unsigned int rx_usecs_low;
unsigned int rx_usecs_high;

unsigned int rx_frames;
unsigned int rx_frames_irq;
unsigned int rx_frames_low;
unsigned int rx_frames_high;

unsigned int tx_usecs;
unsigned int tx_usecs_irq;
unsigned int tx_usecs_low;
unsigned int tx_usecs_high;

unsigned int tx_frames;
unsigned int tx_frames_irq;
unsigned int tx_frames_low;
unsigned int tx_frames_high;
} ni_ethtool_coalesce_t;

struct ni_ethernet {
ni_hwaddr_t permanent_address;
unsigned int link_speed;
Expand All @@ -78,6 +113,7 @@ struct ni_ethernet {
ni_ethernet_wol_t wol;
ni_ethtool_offload_t offload;
ni_ethtool_ring_t ring;
ni_ethtool_coalesce_t coalesce;

unsigned int identify_time;
};
Expand Down
25 changes: 25 additions & 0 deletions schema/ethernet.xml
Expand Up @@ -57,6 +57,31 @@
<rx-jumbo type="uint32"/>
<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>

</define>

<define name="properties" class="dict" extends="ethernet:configuration">
Expand Down

0 comments on commit 9c15f3f

Please sign in to comment.