c461a1
From 30ed4a7f03ef8820773f6eb7d63e982ad04aa8d6 Mon Sep 17 00:00:00 2001
c461a1
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
c461a1
Date: Sat, 13 Jul 2019 12:38:01 +0200
c461a1
Subject: [PATCH 2/4] bswap.h: Remove cpu_to_be16wu()
c461a1
MIME-Version: 1.0
c461a1
Content-Type: text/plain; charset=UTF-8
c461a1
Content-Transfer-Encoding: 8bit
c461a1
c461a1
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
c461a1
Message-id: <20190713123802.23932-2-philmd@redhat.com>
c461a1
Patchwork-id: 89507
c461a1
O-Subject: [RHEL-7.7 qemu-kvm PATCH 1/2] bswap.h: Remove cpu_to_be16wu()
c461a1
Bugzilla: 1270166
c461a1
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
c461a1
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
c461a1
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
c461a1
c461a1
From: Peter Maydell <peter.maydell@linaro.org>
c461a1
c461a1
Replace the legacy cpu_to_be16wu() with stw_be_p().
c461a1
c461a1
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
c461a1
Reviewed-by: Richard Henderson <rth@twiddle.net>
c461a1
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
c461a1
Message-id: 1383669517-25598-7-git-send-email-peter.maydell@linaro.org
c461a1
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
c461a1
(cherry picked from commit d8ee2591e495d5feb0e0250866222dedc805c8d8)
c461a1
[PMD: fix conflict in include/qemu/bswap.h]
c461a1
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
c461a1
c461a1
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c461a1
---
c461a1
 hw/block/cdrom.c     |  4 ++--
c461a1
 hw/ide/atapi.c       | 16 ++++++++--------
c461a1
 hw/net/e1000.c       | 19 ++++++++-----------
c461a1
 include/qemu/bswap.h |  5 -----
c461a1
 4 files changed, 18 insertions(+), 26 deletions(-)
c461a1
c461a1
diff --git a/hw/block/cdrom.c b/hw/block/cdrom.c
c461a1
index 38469fa..5c69f34 100644
c461a1
--- a/hw/block/cdrom.c
c461a1
+++ b/hw/block/cdrom.c
c461a1
@@ -77,7 +77,7 @@ int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track)
c461a1
         q += 4;
c461a1
     }
c461a1
     len = q - buf;
c461a1
-    cpu_to_be16wu((uint16_t *)buf, len - 2);
c461a1
+    stw_be_p(buf, len - 2);
c461a1
     return len;
c461a1
 }
c461a1
 
c461a1
@@ -150,6 +150,6 @@ int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num)
c461a1
     }
c461a1
 
c461a1
     len = q - buf;
c461a1
-    cpu_to_be16wu((uint16_t *)buf, len - 2);
c461a1
+    stw_be_p(buf, len - 2);
c461a1
     return len;
c461a1
 }
c461a1
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
c461a1
index a411748..490070a 100644
c461a1
--- a/hw/ide/atapi.c
c461a1
+++ b/hw/ide/atapi.c
c461a1
@@ -454,7 +454,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
c461a1
                 cpu_to_ube32(buf + 16, total_sectors - 1); /* l0 end sector */
c461a1
 
c461a1
                 /* Size of buffer, not including 2 byte size field */
c461a1
-                cpu_to_be16wu((uint16_t *)buf, 2048 + 2);
c461a1
+                stw_be_p(buf, 2048 + 2);
c461a1
 
c461a1
                 /* 2k data + 4 byte header */
c461a1
                 return (2048 + 4);
c461a1
@@ -465,7 +465,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
c461a1
             buf[5] = 0; /* no region restrictions */
c461a1
 
c461a1
             /* Size of buffer, not including 2 byte size field */
c461a1
-            cpu_to_be16wu((uint16_t *)buf, 4 + 2);
c461a1
+            stw_be_p(buf, 4 + 2);
c461a1
 
c461a1
             /* 4 byte header + 4 byte data */
c461a1
             return (4 + 4);
c461a1
@@ -475,7 +475,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
c461a1
 
c461a1
         case 0x04: /* DVD disc manufacturing information */
c461a1
             /* Size of buffer, not including 2 byte size field */
c461a1
-            cpu_to_be16wu((uint16_t *)buf, 2048 + 2);
c461a1
+            stw_be_p(buf, 2048 + 2);
c461a1
 
c461a1
             /* 2k data + 4 byte header */
c461a1
             return (2048 + 4);
c461a1
@@ -488,22 +488,22 @@ static int ide_dvd_read_structure(IDEState *s, int format,
c461a1
 
c461a1
             buf[4] = 0x00; /* Physical format */
c461a1
             buf[5] = 0x40; /* Not writable, is readable */
c461a1
-            cpu_to_be16wu((uint16_t *)(buf + 6), 2048 + 4);
c461a1
+            stw_be_p(buf + 6, 2048 + 4);
c461a1
 
c461a1
             buf[8] = 0x01; /* Copyright info */
c461a1
             buf[9] = 0x40; /* Not writable, is readable */
c461a1
-            cpu_to_be16wu((uint16_t *)(buf + 10), 4 + 4);
c461a1
+            stw_be_p(buf + 10, 4 + 4);
c461a1
 
c461a1
             buf[12] = 0x03; /* BCA info */
c461a1
             buf[13] = 0x40; /* Not writable, is readable */
c461a1
-            cpu_to_be16wu((uint16_t *)(buf + 14), 188 + 4);
c461a1
+            stw_be_p(buf + 14, 188 + 4);
c461a1
 
c461a1
             buf[16] = 0x04; /* Manufacturing info */
c461a1
             buf[17] = 0x40; /* Not writable, is readable */
c461a1
-            cpu_to_be16wu((uint16_t *)(buf + 18), 2048 + 4);
c461a1
+            stw_be_p(buf + 18, 2048 + 4);
c461a1
 
c461a1
             /* Size of buffer, not including 2 byte size field */
c461a1
-            cpu_to_be16wu((uint16_t *)buf, 16 + 2);
c461a1
+            stw_be_p(buf, 16 + 2);
c461a1
 
c461a1
             /* data written + 4 byte header */
c461a1
             return (16 + 4);
c461a1
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
c461a1
index 2cd38bc..711d369 100644
c461a1
--- a/hw/net/e1000.c
c461a1
+++ b/hw/net/e1000.c
c461a1
@@ -442,8 +442,7 @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse)
c461a1
         n = cse + 1;
c461a1
     if (sloc < n-1) {
c461a1
         sum = net_checksum_add(n-css, data+css);
c461a1
-        cpu_to_be16wu((uint16_t *)(data + sloc),
c461a1
-                      net_checksum_finish(sum));
c461a1
+        stw_be_p(data + sloc, net_checksum_finish(sum));
c461a1
     }
c461a1
 }
c461a1
 
c461a1
@@ -504,13 +503,11 @@ xmit_seg(E1000State *s)
c461a1
         DBGOUT(TXSUM, "frames %d size %d ipcss %d\n",
c461a1
                frames, tp->size, css);
c461a1
         if (tp->ip) {		// IPv4
c461a1
-            cpu_to_be16wu((uint16_t *)(tp->data+css+2),
c461a1
-                          tp->size - css);
c461a1
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4),
c461a1
+            stw_be_p(tp->data+css+2, tp->size - css);
c461a1
+            stw_be_p(tp->data+css+4,
c461a1
                           be16_to_cpup((uint16_t *)(tp->data+css+4))+frames);
c461a1
         } else			// IPv6
c461a1
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4),
c461a1
-                          tp->size - css);
c461a1
+            stw_be_p(tp->data+css+4, tp->size - css);
c461a1
         css = tp->tucss;
c461a1
         len = tp->size - css;
c461a1
         DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->tcp, css, len);
c461a1
@@ -521,14 +518,14 @@ xmit_seg(E1000State *s)
c461a1
             if (tp->paylen - sofar > tp->mss)
c461a1
                 tp->data[css + 13] &= ~9;		// PSH, FIN
c461a1
         } else	// UDP
c461a1
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
c461a1
+            stw_be_p(tp->data+css+4, len);
c461a1
         if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
c461a1
             unsigned int phsum;
c461a1
             // add pseudo-header length before checksum calculation
c461a1
             sp = (uint16_t *)(tp->data + tp->tucso);
c461a1
             phsum = be16_to_cpup(sp) + len;
c461a1
             phsum = (phsum >> 16) + (phsum & 0xffff);
c461a1
-            cpu_to_be16wu(sp, phsum);
c461a1
+            stw_be_p(sp, phsum);
c461a1
         }
c461a1
         tp->tso_frames++;
c461a1
     }
c461a1
@@ -596,9 +593,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
c461a1
     if (vlan_enabled(s) && is_vlan_txd(txd_lower) &&
c461a1
         (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) {
c461a1
         tp->vlan_needed = 1;
c461a1
-        cpu_to_be16wu((uint16_t *)(tp->vlan_header),
c461a1
+        stw_be_p(tp->vlan_header,
c461a1
                       le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
c461a1
-        cpu_to_be16wu((uint16_t *)(tp->vlan_header + 2),
c461a1
+        stw_be_p(tp->vlan_header + 2,
c461a1
                       le16_to_cpu(dp->upper.fields.special));
c461a1
     }
c461a1
         
c461a1
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
c461a1
index 14a5f65..91734ad 100644
c461a1
--- a/include/qemu/bswap.h
c461a1
+++ b/include/qemu/bswap.h
c461a1
@@ -437,11 +437,6 @@ static inline uint32_t be32_to_cpupu(const uint32_t *p)
c461a1
     return ldl_be_p(p);
c461a1
 }
c461a1
 
c461a1
-static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
c461a1
-{
c461a1
-    stw_be_p(p, v);
c461a1
-}
c461a1
-
c461a1
 static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
c461a1
 {
c461a1
     stl_be_p(p, v);
c461a1
-- 
c461a1
1.8.3.1
c461a1