Skip to content

Commit

Permalink
Merge branch 'ena-set_channels'
Browse files Browse the repository at this point in the history
Sameeh Jubran says:

====================
ena: Support ethtool set_channels

Difference from v2:
* ethtool's set/get channels: Switched to using combined instead of
  separate rx/tx
* Fixed error handling in set_channels
* Fixed indentation and cosmetic issues as requested by Jakub Kicinski

Difference from v1:
* Dropped the print from patch 0002 - "net: ena: multiple queue creation
  related cleanups" as requested by David Miller
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 7, 2019
2 parents 9b75803 + 2413ea9 commit 6c157f6
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 93 deletions.
35 changes: 21 additions & 14 deletions drivers/net/ethernet/amazon/ena/ena_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data)
u64 *ptr;
int i, j;

for (i = 0; i < adapter->num_queues; i++) {
for (i = 0; i < adapter->num_io_queues; i++) {
/* Tx stats */
ring = &adapter->tx_ring[i];

Expand Down Expand Up @@ -205,7 +205,7 @@ int ena_get_sset_count(struct net_device *netdev, int sset)
if (sset != ETH_SS_STATS)
return -EOPNOTSUPP;

return adapter->num_queues * (ENA_STATS_ARRAY_TX + ENA_STATS_ARRAY_RX)
return adapter->num_io_queues * (ENA_STATS_ARRAY_TX + ENA_STATS_ARRAY_RX)
+ ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENA_COM;
}

Expand All @@ -214,7 +214,7 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
const struct ena_stats *ena_stats;
int i, j;

for (i = 0; i < adapter->num_queues; i++) {
for (i = 0; i < adapter->num_io_queues; i++) {
/* Tx stats */
for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
ena_stats = &ena_stats_tx_strings[j];
Expand Down Expand Up @@ -333,7 +333,7 @@ static void ena_update_tx_rings_intr_moderation(struct ena_adapter *adapter)

val = ena_com_get_nonadaptive_moderation_interval_tx(adapter->ena_dev);

for (i = 0; i < adapter->num_queues; i++)
for (i = 0; i < adapter->num_io_queues; i++)
adapter->tx_ring[i].smoothed_interval = val;
}

Expand All @@ -344,7 +344,7 @@ static void ena_update_rx_rings_intr_moderation(struct ena_adapter *adapter)

val = ena_com_get_nonadaptive_moderation_interval_rx(adapter->ena_dev);

for (i = 0; i < adapter->num_queues; i++)
for (i = 0; i < adapter->num_io_queues; i++)
adapter->rx_ring[i].smoothed_interval = val;
}

Expand Down Expand Up @@ -612,7 +612,7 @@ static int ena_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,

switch (info->cmd) {
case ETHTOOL_GRXRINGS:
info->data = adapter->num_queues;
info->data = adapter->num_io_queues;
rc = 0;
break;
case ETHTOOL_GRXFH:
Expand Down Expand Up @@ -734,14 +734,20 @@ static void ena_get_channels(struct net_device *netdev,
{
struct ena_adapter *adapter = netdev_priv(netdev);

channels->max_rx = adapter->num_queues;
channels->max_tx = adapter->num_queues;
channels->max_other = 0;
channels->max_combined = 0;
channels->rx_count = adapter->num_queues;
channels->tx_count = adapter->num_queues;
channels->other_count = 0;
channels->combined_count = 0;
channels->max_combined = adapter->max_num_io_queues;
channels->combined_count = adapter->num_io_queues;
}

static int ena_set_channels(struct net_device *netdev,
struct ethtool_channels *channels)
{
struct ena_adapter *adapter = netdev_priv(netdev);
u32 count = channels->combined_count;
/* The check for max value is already done in ethtool */
if (count < ENA_MIN_NUM_IO_QUEUES)
return -EINVAL;

return ena_update_queue_count(adapter, count);
}

static int ena_get_tunable(struct net_device *netdev,
Expand Down Expand Up @@ -807,6 +813,7 @@ static const struct ethtool_ops ena_ethtool_ops = {
.get_rxfh = ena_get_rxfh,
.set_rxfh = ena_set_rxfh,
.get_channels = ena_get_channels,
.set_channels = ena_set_channels,
.get_tunable = ena_get_tunable,
.set_tunable = ena_set_tunable,
};
Expand Down
Loading

0 comments on commit 6c157f6

Please sign in to comment.