Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci virtio: use the new syntax for snprintb(3) forma...



details:   https://anonhg.NetBSD.org/src/rev/20f8d023a0e0
branches:  trunk
changeset: 365202:20f8d023a0e0
user:      uwe <uwe%NetBSD.org@localhost>
date:      Wed Apr 13 10:42:12 2022 +0000

description:
virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).

diffstat:

 sys/dev/pci/if_vioif.c  |  50 ++++++++++++++++++++++++------------------------
 sys/dev/pci/ld_virtio.c |  28 +++++++++++++-------------
 sys/dev/pci/viomb.c     |  12 +++++-----
 sys/dev/pci/virtioreg.h |  15 +++++++------
 4 files changed, 53 insertions(+), 52 deletions(-)

diffs (182 lines):

diff -r 5046da7b2bc7 -r 20f8d023a0e0 sys/dev/pci/if_vioif.c
--- a/sys/dev/pci/if_vioif.c    Wed Apr 13 02:28:01 2022 +0000
+++ b/sys/dev/pci/if_vioif.c    Wed Apr 13 10:42:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vioif.c,v 1.78 2022/04/13 02:28:01 yamaguchi Exp $  */
+/*     $NetBSD: if_vioif.c,v 1.79 2022/04/13 10:42:12 uwe Exp $        */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.78 2022/04/13 02:28:01 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.79 2022/04/13 10:42:12 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -101,29 +101,29 @@
 #define VIRTIO_NET_F_MQ                        __BIT(22)
 #define VIRTIO_NET_F_CTRL_MAC_ADDR     __BIT(23)
 
-#define VIRTIO_NET_FLAG_BITS \
-       VIRTIO_COMMON_FLAG_BITS \
-       "\x18""CTRL_MAC" \
-       "\x17""MQ" \
-       "\x16""GUEST_ANNOUNCE" \
-       "\x15""CTRL_RX_EXTRA" \
-       "\x14""CTRL_VLAN" \
-       "\x13""CTRL_RX" \
-       "\x12""CTRL_VQ" \
-       "\x11""STATUS" \
-       "\x10""MRG_RXBUF" \
-       "\x0f""HOST_UFO" \
-       "\x0e""HOST_ECN" \
-       "\x0d""HOST_TSO6" \
-       "\x0c""HOST_TSO4" \
-       "\x0b""GUEST_UFO" \
-       "\x0a""GUEST_ECN" \
-       "\x09""GUEST_TSO6" \
-       "\x08""GUEST_TSO4" \
-       "\x07""GSO" \
-       "\x06""MAC" \
-       "\x02""GUEST_CSUM" \
-       "\x01""CSUM"
+#define VIRTIO_NET_FLAG_BITS                   \
+       VIRTIO_COMMON_FLAG_BITS                 \
+       "b\x17" "CTRL_MAC\0"                    \
+       "b\x16" "MQ\0"                          \
+       "b\x15" "GUEST_ANNOUNCE\0"              \
+       "b\x14" "CTRL_RX_EXTRA\0"               \
+       "b\x13" "CTRL_VLAN\0"                   \
+       "b\x12" "CTRL_RX\0"                     \
+       "b\x11" "CTRL_VQ\0"                     \
+       "b\x10" "STATUS\0"                      \
+       "b\x0f" "MRG_RXBUF\0"                   \
+       "b\x0e" "HOST_UFO\0"                    \
+       "b\x0d" "HOST_ECN\0"                    \
+       "b\x0c" "HOST_TSO6\0"                   \
+       "b\x0b" "HOST_TSO4\0"                   \
+       "b\x0a" "GUEST_UFO\0"                   \
+       "b\x09" "GUEST_ECN\0"                   \
+       "b\x08" "GUEST_TSO6\0"                  \
+       "b\x07" "GUEST_TSO4\0"                  \
+       "b\x06" "GSO\0"                         \
+       "b\x05" "MAC\0"                         \
+       "b\x01" "GUEST_CSUM\0"                  \
+       "b\x00" "CSUM\0"
 
 /* Status */
 #define VIRTIO_NET_S_LINK_UP   1
diff -r 5046da7b2bc7 -r 20f8d023a0e0 sys/dev/pci/ld_virtio.c
--- a/sys/dev/pci/ld_virtio.c   Wed Apr 13 02:28:01 2022 +0000
+++ b/sys/dev/pci/ld_virtio.c   Wed Apr 13 10:42:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld_virtio.c,v 1.29 2021/01/20 19:46:48 reinoud Exp $   */
+/*     $NetBSD: ld_virtio.c,v 1.30 2022/04/13 10:42:12 uwe Exp $       */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.29 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.30 2022/04/13 10:42:12 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,18 +76,18 @@
 */
 #define        VIRTIO_BLK_MIN_SEGMENTS 2
 
-#define VIRTIO_BLK_FLAG_BITS \
-       VIRTIO_COMMON_FLAG_BITS \
-       "\x0c""CONFIG_WCE" \
-       "\x0b""TOPOLOGY" \
-       "\x0a""FLUSH" \
-       "\x08""SCSI" \
-       "\x07""BLK_SIZE" \
-       "\x06""RO" \
-       "\x05""GEOMETRY" \
-       "\x03""SEG_MAX" \
-       "\x02""SIZE_MAX" \
-       "\x01""BARRIER"
+#define VIRTIO_BLK_FLAG_BITS                   \
+       VIRTIO_COMMON_FLAG_BITS                 \
+       "b\x0b" "CONFIG_WCE\0"                  \
+       "b\x0a" "TOPOLOGY\0"                    \
+       "b\x09" "FLUSH\0"                       \
+       "b\x07" "SCSI\0"                        \
+       "b\x06" "BLK_SIZE\0"                    \
+       "b\x05" "RO\0"                          \
+       "b\x04" "GEOMETRY\0"                    \
+       "b\x02" "SEG_MAX\0"                     \
+       "b\x01" "SIZE_MAX\0"                    \
+       "b\x00" "BARRIER\0"
 
 /* Command */
 #define VIRTIO_BLK_T_IN                0
diff -r 5046da7b2bc7 -r 20f8d023a0e0 sys/dev/pci/viomb.c
--- a/sys/dev/pci/viomb.c       Wed Apr 13 02:28:01 2022 +0000
+++ b/sys/dev/pci/viomb.c       Wed Apr 13 10:42:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: viomb.c,v 1.12 2021/01/20 19:46:48 reinoud Exp $       */
+/*     $NetBSD: viomb.c,v 1.13 2022/04/13 10:42:12 uwe Exp $   */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.12 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.13 2022/04/13 10:42:12 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,10 +53,10 @@
 #define VIRTIO_BALLOON_F_MUST_TELL_HOST (1<<0)
 #define VIRTIO_BALLOON_F_STATS_VQ      (1<<1)
 
-#define VIRTIO_BALLOON_FLAG_BITS \
-       VIRTIO_COMMON_FLAG_BITS \
-       "\x02""STATS_VQ" \
-       "\x01""MUST_TELL_HOST"
+#define VIRTIO_BALLOON_FLAG_BITS               \
+       VIRTIO_COMMON_FLAG_BITS                 \
+       "b\x01" "STATS_VQ\0"                    \
+       "b\x00" "MUST_TELL_HOST\0"
 
 #define PGS_PER_REQ            (256) /* 1MB, 4KB/page */
 #define VQ_INFLATE     0
diff -r 5046da7b2bc7 -r 20f8d023a0e0 sys/dev/pci/virtioreg.h
--- a/sys/dev/pci/virtioreg.h   Wed Apr 13 02:28:01 2022 +0000
+++ b/sys/dev/pci/virtioreg.h   Wed Apr 13 10:42:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtioreg.h,v 1.7 2021/01/20 19:46:48 reinoud Exp $    */
+/*     $NetBSD: virtioreg.h,v 1.8 2022/04/13 10:42:12 uwe Exp $        */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -99,12 +99,13 @@
 #define  VIRTIO_CONFIG_ISR_CONFIG_CHANGE       2
 
 /* common device/guest features */
-#define VIRTIO_COMMON_FLAG_BITS \
-        "\20" \
-       "\x1f""BAD_FEATURE" \
-       "\x1e""EVENT_IDX" \
-       "\x1d""INDIRECT_DESC" \
-       "\x19""NOTIFY_ON_EMPTY"
+#define VIRTIO_COMMON_FLAG_BITS                        \
+        "\177\020"                             \
+       "b\x20" "V1\0"  /*XXX*/                 \
+       "b\x1e" "BAD_FEATURE\0"                 \
+       "b\x1d" "EVENT_IDX\0"                   \
+       "b\x1c" "INDIRECT_DESC\0"               \
+       "b\x18" "NOTIFY_ON_EMPTY\0"
 
 
 /*



Home | Main Index | Thread Index | Old Index