Commit 421797b1 authored by Kan Liang's avatar Kan Liang Committed by David S. Miller

net/ethtool: support get coalesce per queue

This patch implements sub command ETHTOOL_GCOALESCE for ioctl
ETHTOOL_PERQUEUE. It introduces an interface get_per_queue_coalesce to
get coalesce of each masked queue from device driver. Then the interrupt
coalescing parameters will be copied back to user space one by one.
Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
Reviewed-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac2c7ad0
...@@ -201,6 +201,11 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) ...@@ -201,6 +201,11 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
* @get_module_eeprom: Get the eeprom information from the plug-in module * @get_module_eeprom: Get the eeprom information from the plug-in module
* @get_eee: Get Energy-Efficient (EEE) supported and status. * @get_eee: Get Energy-Efficient (EEE) supported and status.
* @set_eee: Set EEE status (enable/disable) as well as LPI timers. * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
* @get_per_queue_coalesce: Get interrupt coalescing parameters per queue.
* It must check that the given queue number is valid. If neither a RX nor
* a TX queue has this number, return -EINVAL. If only a RX queue or a TX
* queue has this number, set the inapplicable fields to ~0 and return 0.
* Returns a negative error code or zero.
* *
* All operations are optional (i.e. the function pointer may be set * All operations are optional (i.e. the function pointer may be set
* to %NULL) and callers must take this into account. Callers must * to %NULL) and callers must take this into account. Callers must
...@@ -279,7 +284,8 @@ struct ethtool_ops { ...@@ -279,7 +284,8 @@ struct ethtool_ops {
const struct ethtool_tunable *, void *); const struct ethtool_tunable *, void *);
int (*set_tunable)(struct net_device *, int (*set_tunable)(struct net_device *,
const struct ethtool_tunable *, const void *); const struct ethtool_tunable *, const void *);
int (*get_per_queue_coalesce)(struct net_device *, u32,
struct ethtool_coalesce *);
}; };
#endif /* _LINUX_ETHTOOL_H */ #endif /* _LINUX_ETHTOOL_H */
...@@ -1888,6 +1888,38 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr) ...@@ -1888,6 +1888,38 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
return ret; return ret;
} }
static int ethtool_get_per_queue_coalesce(struct net_device *dev,
void __user *useraddr,
struct ethtool_per_queue_op *per_queue_opt)
{
u32 bit;
int ret;
DECLARE_BITMAP(queue_mask, MAX_NUM_QUEUE);
if (!dev->ethtool_ops->get_per_queue_coalesce)
return -EOPNOTSUPP;
useraddr += sizeof(*per_queue_opt);
bitmap_from_u32array(queue_mask,
MAX_NUM_QUEUE,
per_queue_opt->queue_mask,
DIV_ROUND_UP(MAX_NUM_QUEUE, 32));
for_each_set_bit(bit, queue_mask, MAX_NUM_QUEUE) {
struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
ret = dev->ethtool_ops->get_per_queue_coalesce(dev, bit, &coalesce);
if (ret != 0)
return ret;
if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
return -EFAULT;
useraddr += sizeof(coalesce);
}
return 0;
}
static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr) static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr)
{ {
struct ethtool_per_queue_op per_queue_opt; struct ethtool_per_queue_op per_queue_opt;
...@@ -1896,7 +1928,8 @@ static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr) ...@@ -1896,7 +1928,8 @@ static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr)
return -EFAULT; return -EFAULT;
switch (per_queue_opt.sub_command) { switch (per_queue_opt.sub_command) {
case ETHTOOL_GCOALESCE:
return ethtool_get_per_queue_coalesce(dev, useraddr, &per_queue_opt);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment