Commit 66846048 authored by Rick Jones's avatar Rick Jones Committed by David S. Miller

enable virtio_net to return bus_info in ethtool -i consistent with emulated NICs

Add a new .bus_name to virtio_config_ops then modify virtio_net to
call through to it in an ethtool .get_drvinfo routine to report
bus_info in ethtool -i output which is consistent with other
emulated NICs and the output of lspci.
Signed-off-by: default avatarRick Jones <rick.jones2@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 64882709
...@@ -381,6 +381,11 @@ static int lg_find_vqs(struct virtio_device *vdev, unsigned nvqs, ...@@ -381,6 +381,11 @@ static int lg_find_vqs(struct virtio_device *vdev, unsigned nvqs,
return PTR_ERR(vqs[i]); return PTR_ERR(vqs[i]);
} }
static const char *lg_bus_name(struct virtio_device *vdev)
{
return "";
}
/* The ops structure which hooks everything together. */ /* The ops structure which hooks everything together. */
static struct virtio_config_ops lguest_config_ops = { static struct virtio_config_ops lguest_config_ops = {
.get_features = lg_get_features, .get_features = lg_get_features,
...@@ -392,6 +397,7 @@ static struct virtio_config_ops lguest_config_ops = { ...@@ -392,6 +397,7 @@ static struct virtio_config_ops lguest_config_ops = {
.reset = lg_reset, .reset = lg_reset,
.find_vqs = lg_find_vqs, .find_vqs = lg_find_vqs,
.del_vqs = lg_del_vqs, .del_vqs = lg_del_vqs,
.bus_name = lg_bus_name,
}; };
/* /*
......
...@@ -39,6 +39,7 @@ module_param(gso, bool, 0444); ...@@ -39,6 +39,7 @@ module_param(gso, bool, 0444);
#define GOOD_COPY_LEN 128 #define GOOD_COPY_LEN 128
#define VIRTNET_SEND_COMMAND_SG_MAX 2 #define VIRTNET_SEND_COMMAND_SG_MAX 2
#define VIRTNET_DRIVER_VERSION "1.0.0"
struct virtnet_stats { struct virtnet_stats {
struct u64_stats_sync syncp; struct u64_stats_sync syncp;
...@@ -889,7 +890,21 @@ static void virtnet_get_ringparam(struct net_device *dev, ...@@ -889,7 +890,21 @@ static void virtnet_get_ringparam(struct net_device *dev,
} }
static void virtnet_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
struct virtnet_info *vi = netdev_priv(dev);
struct virtio_device *vdev = vi->vdev;
strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
strlcpy(info->version, VIRTNET_DRIVER_VERSION, sizeof(info->version));
strlcpy(info->bus_info, virtio_bus_name(vdev), sizeof(info->bus_info));
}
static const struct ethtool_ops virtnet_ethtool_ops = { static const struct ethtool_ops virtnet_ethtool_ops = {
.get_drvinfo = virtnet_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ringparam = virtnet_get_ringparam, .get_ringparam = virtnet_get_ringparam,
}; };
......
...@@ -263,6 +263,11 @@ static int kvm_find_vqs(struct virtio_device *vdev, unsigned nvqs, ...@@ -263,6 +263,11 @@ static int kvm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
return PTR_ERR(vqs[i]); return PTR_ERR(vqs[i]);
} }
static const char *kvm_bus_name(struct virtio_device *vdev)
{
return "";
}
/* /*
* The config ops structure as defined by virtio config * The config ops structure as defined by virtio config
*/ */
...@@ -276,6 +281,7 @@ static struct virtio_config_ops kvm_vq_configspace_ops = { ...@@ -276,6 +281,7 @@ static struct virtio_config_ops kvm_vq_configspace_ops = {
.reset = kvm_reset, .reset = kvm_reset,
.find_vqs = kvm_find_vqs, .find_vqs = kvm_find_vqs,
.del_vqs = kvm_del_vqs, .del_vqs = kvm_del_vqs,
.bus_name = kvm_bus_name,
}; };
/* /*
......
...@@ -361,7 +361,12 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs, ...@@ -361,7 +361,12 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
return 0; return 0;
} }
static const char *vm_bus_name(struct virtio_device *vdev)
{
struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
return vm_dev->pdev->name;
}
static struct virtio_config_ops virtio_mmio_config_ops = { static struct virtio_config_ops virtio_mmio_config_ops = {
.get = vm_get, .get = vm_get,
...@@ -373,6 +378,7 @@ static struct virtio_config_ops virtio_mmio_config_ops = { ...@@ -373,6 +378,7 @@ static struct virtio_config_ops virtio_mmio_config_ops = {
.del_vqs = vm_del_vqs, .del_vqs = vm_del_vqs,
.get_features = vm_get_features, .get_features = vm_get_features,
.finalize_features = vm_finalize_features, .finalize_features = vm_finalize_features,
.bus_name = vm_bus_name,
}; };
......
...@@ -580,6 +580,13 @@ static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs, ...@@ -580,6 +580,13 @@ static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs,
false, false); false, false);
} }
static const char *vp_bus_name(struct virtio_device *vdev)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
return pci_name(vp_dev->pci_dev);
}
static struct virtio_config_ops virtio_pci_config_ops = { static struct virtio_config_ops virtio_pci_config_ops = {
.get = vp_get, .get = vp_get,
.set = vp_set, .set = vp_set,
...@@ -590,6 +597,7 @@ static struct virtio_config_ops virtio_pci_config_ops = { ...@@ -590,6 +597,7 @@ static struct virtio_config_ops virtio_pci_config_ops = {
.del_vqs = vp_del_vqs, .del_vqs = vp_del_vqs,
.get_features = vp_get_features, .get_features = vp_get_features,
.finalize_features = vp_finalize_features, .finalize_features = vp_finalize_features,
.bus_name = vp_bus_name,
}; };
static void virtio_pci_release_dev(struct device *_d) static void virtio_pci_release_dev(struct device *_d)
......
...@@ -100,6 +100,10 @@ ...@@ -100,6 +100,10 @@
* vdev: the virtio_device * vdev: the virtio_device
* This gives the final feature bits for the device: it can change * This gives the final feature bits for the device: it can change
* the dev->feature bits if it wants. * the dev->feature bits if it wants.
* @bus_name: return the bus name associated with the device
* vdev: the virtio_device
* This returns a pointer to the bus name a la pci_name from which
* the caller can then copy.
*/ */
typedef void vq_callback_t(struct virtqueue *); typedef void vq_callback_t(struct virtqueue *);
struct virtio_config_ops { struct virtio_config_ops {
...@@ -117,6 +121,7 @@ struct virtio_config_ops { ...@@ -117,6 +121,7 @@ struct virtio_config_ops {
void (*del_vqs)(struct virtio_device *); void (*del_vqs)(struct virtio_device *);
u32 (*get_features)(struct virtio_device *vdev); u32 (*get_features)(struct virtio_device *vdev);
void (*finalize_features)(struct virtio_device *vdev); void (*finalize_features)(struct virtio_device *vdev);
const char *(*bus_name)(struct virtio_device *vdev);
}; };
/* If driver didn't advertise the feature, it will never appear. */ /* If driver didn't advertise the feature, it will never appear. */
...@@ -182,5 +187,14 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev, ...@@ -182,5 +187,14 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
return ERR_PTR(err); return ERR_PTR(err);
return vq; return vq;
} }
static inline
const char *virtio_bus_name(struct virtio_device *vdev)
{
if (!vdev->config->bus_name)
return "virtio";
return vdev->config->bus_name(vdev);
}
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_VIRTIO_CONFIG_H */ #endif /* _LINUX_VIRTIO_CONFIG_H */
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