summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen.py9
-rw-r--r--src/vnet/devices/virtio/virtio.h10
-rw-r--r--src/vnet/devices/virtio/virtio_pci_modern.c10
3 files changed, 18 insertions, 11 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py
index 9d74a5b0357..bfc77ca7019 100755
--- a/src/tools/vppapigen/vppapigen.py
+++ b/src/tools/vppapigen/vppapigen.py
@@ -11,7 +11,7 @@ import os
import sys
from subprocess import Popen, PIPE
-assert sys.version_info >= (3, 6), \
+assert sys.version_info >= (3, 5), \
"Not supported Python version: {}".format(sys.version)
log = logging.getLogger('vppapigen')
@@ -780,12 +780,13 @@ class VPPAPI(object):
def parse_filename(self, filename, debug=0):
if self.revision:
- git_show = f'git show {self.revision}:{filename}'
+ git_show = 'git show {}:{}'.format(self.revision, filename)
proc = Popen(git_show.split(), stdout=PIPE, encoding='utf-8')
try:
data, errs = proc.communicate()
if proc.returncode != 0:
- print(f'File not found: {self.revision}:{filename}', file=sys.stderr)
+ print('File not found: {}:{}'.format(self.revision,
+ filename), file=sys.stderr)
sys.exit(2)
return self.parse_string(data, debug=debug)
except Exception as e:
@@ -795,7 +796,7 @@ class VPPAPI(object):
with open(filename, encoding='utf-8') as fd:
return self.parse_fd(fd, None)
except FileNotFoundError:
- print(f'File not found: {filename}', file=sys.stderr)
+ print('File not found: {}'.format(filename), file=sys.stderr)
sys.exit(2)
def autoreply_block(self, name, parent):
diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h
index f1eaa07fe5d..b00e1eceb85 100644
--- a/src/vnet/devices/virtio/virtio.h
+++ b/src/vnet/devices/virtio/virtio.h
@@ -129,7 +129,15 @@ typedef struct
/* error */
clib_error_t *error;
- u8 mac_addr[6];
+ union
+ {
+ struct
+ {
+ u32 mac_addr32;
+ u16 mac_addr16;
+ };
+ u8 mac_addr[6];
+ };
union
{
struct /* tun/tap interface */
diff --git a/src/vnet/devices/virtio/virtio_pci_modern.c b/src/vnet/devices/virtio/virtio_pci_modern.c
index 0d86ff2acda..4eb0ff102ae 100644
--- a/src/vnet/devices/virtio/virtio_pci_modern.c
+++ b/src/vnet/devices/virtio/virtio_pci_modern.c
@@ -311,19 +311,17 @@ virtio_pci_modern_del_queue (vlib_main_t * vm, virtio_if_t * vif,
static void
virtio_pci_modern_get_device_mac (vlib_main_t * vm, virtio_if_t * vif)
{
- *((u32 *) vif->mac_addr) =
- virtio_pci_reg_read_u32 (vif, VIRTIO_MAC_OFFSET (vif));
- *((u16 *) (vif->mac_addr + 4)) =
+ vif->mac_addr32 = virtio_pci_reg_read_u32 (vif, VIRTIO_MAC_OFFSET (vif));
+ vif->mac_addr16 =
virtio_pci_reg_read_u16 (vif, VIRTIO_MAC_OFFSET (vif) + 4);
}
static void
virtio_pci_modern_set_device_mac (vlib_main_t * vm, virtio_if_t * vif)
{
- virtio_pci_reg_write_u32 (vif, VIRTIO_MAC_OFFSET (vif),
- *((u32 *) vif->mac_addr));
+ virtio_pci_reg_write_u32 (vif, VIRTIO_MAC_OFFSET (vif), vif->mac_addr32);
virtio_pci_reg_write_u16 (vif, VIRTIO_MAC_OFFSET (vif) + 4,
- *((u16 *) (vif->mac_addr + 4)));
+ vif->mac_addr16);
}
static u16