aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/lguest/lguest_device.c6
-rw-r--r--drivers/net/virtio_net.c15
-rw-r--r--drivers/s390/kvm/kvm_virtio.c6
-rw-r--r--drivers/virtio/virtio_mmio.c6
-rw-r--r--drivers/virtio/virtio_pci.c8
-rw-r--r--include/linux/virtio_config.h14
6 files changed, 55 insertions, 0 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 0dc30ffde5ad..595d73197016 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -381,6 +381,11 @@ error:
381 return PTR_ERR(vqs[i]); 381 return PTR_ERR(vqs[i]);
382} 382}
383 383
384static const char *lg_bus_name(struct virtio_device *vdev)
385{
386 return "";
387}
388
384/* The ops structure which hooks everything together. */ 389/* The ops structure which hooks everything together. */
385static struct virtio_config_ops lguest_config_ops = { 390static struct virtio_config_ops lguest_config_ops = {
386 .get_features = lg_get_features, 391 .get_features = lg_get_features,
@@ -392,6 +397,7 @@ static struct virtio_config_ops lguest_config_ops = {
392 .reset = lg_reset, 397 .reset = lg_reset,
393 .find_vqs = lg_find_vqs, 398 .find_vqs = lg_find_vqs,
394 .del_vqs = lg_del_vqs, 399 .del_vqs = lg_del_vqs,
400 .bus_name = lg_bus_name,
395}; 401};
396 402
397/* 403/*
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 6ee8410443c4..4dc9d842a7a3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -39,6 +39,7 @@ module_param(gso, bool, 0444);
39#define GOOD_COPY_LEN 128 39#define GOOD_COPY_LEN 128
40 40
41#define VIRTNET_SEND_COMMAND_SG_MAX 2 41#define VIRTNET_SEND_COMMAND_SG_MAX 2
42#define VIRTNET_DRIVER_VERSION "1.0.0"
42 43
43struct virtnet_stats { 44struct virtnet_stats {
44 struct u64_stats_sync syncp; 45 struct u64_stats_sync syncp;
@@ -889,7 +890,21 @@ static void virtnet_get_ringparam(struct net_device *dev,
889 890
890} 891}
891 892
893
894static void virtnet_get_drvinfo(struct net_device *dev,
895 struct ethtool_drvinfo *info)
896{
897 struct virtnet_info *vi = netdev_priv(dev);
898 struct virtio_device *vdev = vi->vdev;
899
900 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
901 strlcpy(info->version, VIRTNET_DRIVER_VERSION, sizeof(info->version));
902 strlcpy(info->bus_info, virtio_bus_name(vdev), sizeof(info->bus_info));
903
904}
905
892static const struct ethtool_ops virtnet_ethtool_ops = { 906static const struct ethtool_ops virtnet_ethtool_ops = {
907 .get_drvinfo = virtnet_get_drvinfo,
893 .get_link = ethtool_op_get_link, 908 .get_link = ethtool_op_get_link,
894 .get_ringparam = virtnet_get_ringparam, 909 .get_ringparam = virtnet_get_ringparam,
895}; 910};
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 94f49ffa70ba..8af868bab20b 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -263,6 +263,11 @@ error:
263 return PTR_ERR(vqs[i]); 263 return PTR_ERR(vqs[i]);
264} 264}
265 265
266static const char *kvm_bus_name(struct virtio_device *vdev)
267{
268 return "";
269}
270
266/* 271/*
267 * The config ops structure as defined by virtio config 272 * The config ops structure as defined by virtio config
268 */ 273 */
@@ -276,6 +281,7 @@ static struct virtio_config_ops kvm_vq_configspace_ops = {
276 .reset = kvm_reset, 281 .reset = kvm_reset,
277 .find_vqs = kvm_find_vqs, 282 .find_vqs = kvm_find_vqs,
278 .del_vqs = kvm_del_vqs, 283 .del_vqs = kvm_del_vqs,
284 .bus_name = kvm_bus_name,
279}; 285};
280 286
281/* 287/*
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index acc5e43c373e..2f57380d7ed4 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -361,7 +361,12 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
361 return 0; 361 return 0;
362} 362}
363 363
364static const char *vm_bus_name(struct virtio_device *vdev)
365{
366 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
364 367
368 return vm_dev->pdev->name;
369}
365 370
366static struct virtio_config_ops virtio_mmio_config_ops = { 371static struct virtio_config_ops virtio_mmio_config_ops = {
367 .get = vm_get, 372 .get = vm_get,
@@ -373,6 +378,7 @@ static struct virtio_config_ops virtio_mmio_config_ops = {
373 .del_vqs = vm_del_vqs, 378 .del_vqs = vm_del_vqs,
374 .get_features = vm_get_features, 379 .get_features = vm_get_features,
375 .finalize_features = vm_finalize_features, 380 .finalize_features = vm_finalize_features,
381 .bus_name = vm_bus_name,
376}; 382};
377 383
378 384
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 79a31e5b4b68..764ec05ea3e8 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -580,6 +580,13 @@ static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs,
580 false, false); 580 false, false);
581} 581}
582 582
583static const char *vp_bus_name(struct virtio_device *vdev)
584{
585 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
586
587 return pci_name(vp_dev->pci_dev);
588}
589
583static struct virtio_config_ops virtio_pci_config_ops = { 590static struct virtio_config_ops virtio_pci_config_ops = {
584 .get = vp_get, 591 .get = vp_get,
585 .set = vp_set, 592 .set = vp_set,
@@ -590,6 +597,7 @@ static struct virtio_config_ops virtio_pci_config_ops = {
590 .del_vqs = vp_del_vqs, 597 .del_vqs = vp_del_vqs,
591 .get_features = vp_get_features, 598 .get_features = vp_get_features,
592 .finalize_features = vp_finalize_features, 599 .finalize_features = vp_finalize_features,
600 .bus_name = vp_bus_name,
593}; 601};
594 602
595static void virtio_pci_release_dev(struct device *_d) 603static void virtio_pci_release_dev(struct device *_d)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index add4790b21fe..63f98d0a8efa 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -100,6 +100,10 @@
100 * vdev: the virtio_device 100 * vdev: the virtio_device
101 * This gives the final feature bits for the device: it can change 101 * This gives the final feature bits for the device: it can change
102 * the dev->feature bits if it wants. 102 * the dev->feature bits if it wants.
103 * @bus_name: return the bus name associated with the device
104 * vdev: the virtio_device
105 * This returns a pointer to the bus name a la pci_name from which
106 * the caller can then copy.
103 */ 107 */
104typedef void vq_callback_t(struct virtqueue *); 108typedef void vq_callback_t(struct virtqueue *);
105struct virtio_config_ops { 109struct virtio_config_ops {
@@ -117,6 +121,7 @@ struct virtio_config_ops {
117 void (*del_vqs)(struct virtio_device *); 121 void (*del_vqs)(struct virtio_device *);
118 u32 (*get_features)(struct virtio_device *vdev); 122 u32 (*get_features)(struct virtio_device *vdev);
119 void (*finalize_features)(struct virtio_device *vdev); 123 void (*finalize_features)(struct virtio_device *vdev);
124 const char *(*bus_name)(struct virtio_device *vdev);
120}; 125};
121 126
122/* If driver didn't advertise the feature, it will never appear. */ 127/* 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 return ERR_PTR(err); 187 return ERR_PTR(err);
183 return vq; 188 return vq;
184} 189}
190
191static inline
192const char *virtio_bus_name(struct virtio_device *vdev)
193{
194 if (!vdev->config->bus_name)
195 return "virtio";
196 return vdev->config->bus_name(vdev);
197}
198
185#endif /* __KERNEL__ */ 199#endif /* __KERNEL__ */
186#endif /* _LINUX_VIRTIO_CONFIG_H */ 200#endif /* _LINUX_VIRTIO_CONFIG_H */