From: Andy Green <andy@warmcat.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 02/40] drivers/bus/dpaa: fix inconsistent struct alignment
Date: Thu, 10 May 2018 10:46:29 +0800 [thread overview]
Message-ID: <152592038925.119328.7339714951968208684.stgit@localhost.localdomain> (raw)
In-Reply-To: <152591991920.119328.14523975619615362920.stgit@localhost.localdomain>
The actual descriptor for qm_mr_entry is 64-byte aligned.
But the original code plays a trick, and puts a u8 common
to the three descriptor subtypes in the union afterwards
outside their structure definitions.
Unfortunately since they compose a struct qm_fd with
alignment 8, this trick destroys the ability of the compiler
to understand what has happened, resulting in this kind of
problem:
/home/agreen/projects/dpdk/drivers/bus/dpaa/include/
fsl_qman.h:354:3: error: alignment 1 of ‘struct <anonymous>’
is less than 8 [-Werror=packed-not-aligned]
} __packed dcern;
on gcc 8 / Fedora 28 out of the box.
This patch moves the u8 verb into the structure definitions
composed into the union, so the alignment of the parent struct
containing the alignment 8 object can also be seen to be
alignment 8 by the compiler. Uses of .verb are fixed up to use
.ern.verb (the same offset of +0 inside all the structs in
the union).
The final struct layout should be unchanged.
Signed-off-by: Andy Green <andy@warmcat.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Tested-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/bus/dpaa/base/qbman/qman.c | 14 +++++++-------
drivers/bus/dpaa/include/fsl_qman.h | 24 +++++++++++++-----------
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index 2810fdd26..27d98cc10 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -314,9 +314,9 @@ static int drain_mr_fqrni(struct qm_portal *p)
if (!msg)
return 0;
}
- if ((msg->verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) {
+ if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) {
/* We aren't draining anything but FQRNIs */
- pr_err("Found verb 0x%x in MR\n", msg->verb);
+ pr_err("Found verb 0x%x in MR\n", msg->ern.verb);
return -1;
}
qm_mr_next(p);
@@ -483,7 +483,7 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal)
/* when accessing 'verb', use __raw_readb() to ensure that compiler
* inlining doesn't try to optimise out "excess reads".
*/
- if ((__raw_readb(&res->verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+ if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
if (!mr->pi)
mr->vbit ^= QM_MR_VERB_VBIT;
@@ -832,7 +832,7 @@ static u32 __poll_portal_slow(struct qman_portal *p, u32 is)
goto mr_done;
swapped_msg = *msg;
hw_fd_to_cpu(&swapped_msg.ern.fd);
- verb = msg->verb & QM_MR_VERB_TYPE_MASK;
+ verb = msg->ern.verb & QM_MR_VERB_TYPE_MASK;
/* The message is a software ERN iff the 0x20 bit is set */
if (verb & 0x20) {
switch (verb) {
@@ -1666,7 +1666,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
*/
struct qm_mr_entry msg;
- msg.verb = QM_MR_VERB_FQRNI;
+ msg.ern.verb = QM_MR_VERB_FQRNI;
msg.fq.fqs = mcr->alterfq.fqs;
msg.fq.fqid = fq->fqid;
#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
@@ -2643,7 +2643,7 @@ int qman_shutdown_fq(u32 fqid)
qm_mr_pvb_update(low_p);
msg = qm_mr_current(low_p);
while (msg) {
- if ((msg->verb &
+ if ((msg->ern.verb &
QM_MR_VERB_TYPE_MASK)
== QM_MR_VERB_FQRN)
found_fqrn = 1;
@@ -2711,7 +2711,7 @@ int qman_shutdown_fq(u32 fqid)
qm_mr_pvb_update(low_p);
msg = qm_mr_current(low_p);
while (msg) {
- if ((msg->verb & QM_MR_VERB_TYPE_MASK) ==
+ if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) ==
QM_MR_VERB_FQRL)
orl_empty = 1;
qm_mr_next(low_p);
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index e9793f30d..e4ad7ae48 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -284,20 +284,20 @@ static inline dma_addr_t qm_sg_addr(const struct qm_sg_entry *sg)
} while (0)
/* See 1.5.8.1: "Enqueue Command" */
-struct qm_eqcr_entry {
+struct __rte_aligned(8) qm_eqcr_entry {
u8 __dont_write_directly__verb;
u8 dca;
u16 seqnum;
u32 orp; /* 24-bit */
u32 fqid; /* 24-bit */
u32 tag;
- struct qm_fd fd;
+ struct qm_fd fd; /* this has alignment 8 */
u8 __reserved3[32];
} __packed;
/* "Frame Dequeue Response" */
-struct qm_dqrr_entry {
+struct __rte_aligned(8) qm_dqrr_entry {
u8 verb;
u8 stat;
u16 seqnum; /* 15-bit */
@@ -305,7 +305,7 @@ struct qm_dqrr_entry {
u8 __reserved2[3];
u32 fqid; /* 24-bit */
u32 contextB;
- struct qm_fd fd;
+ struct qm_fd fd; /* this has alignment 8 */
u8 __reserved4[32];
};
@@ -323,18 +323,19 @@ struct qm_dqrr_entry {
/* "ERN Message Response" */
/* "FQ State Change Notification" */
struct qm_mr_entry {
- u8 verb;
union {
struct {
+ u8 verb;
u8 dca;
u16 seqnum;
u8 rc; /* Rejection Code */
u32 orp:24;
u32 fqid; /* 24-bit */
u32 tag;
- struct qm_fd fd;
- } __packed ern;
+ struct qm_fd fd; /* this has alignment 8 */
+ } __packed __rte_aligned(8) ern;
struct {
+ u8 verb;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
u8 colour:2; /* See QM_MR_DCERN_COLOUR_* */
u8 __reserved1:4;
@@ -349,18 +350,19 @@ struct qm_mr_entry {
u32 __reserved3:24;
u32 fqid; /* 24-bit */
u32 tag;
- struct qm_fd fd;
- } __packed dcern;
+ struct qm_fd fd; /* this has alignment 8 */
+ } __packed __rte_aligned(8) dcern;
struct {
+ u8 verb;
u8 fqs; /* Frame Queue Status */
u8 __reserved1[6];
u32 fqid; /* 24-bit */
u32 contextB;
u8 __reserved2[16];
- } __packed fq; /* FQRN/FQRNI/FQRL/FQPN */
+ } __packed __rte_aligned(8) fq; /* FQRN/FQRNI/FQRL/FQPN */
};
u8 __reserved2[32];
-} __packed;
+} __packed __rte_aligned(8);
#define QM_MR_VERB_VBIT 0x80
/*
* ERNs originating from direct-connect portals ("dcern") use 0x20 as a verb
next prev parent reply other threads:[~2018-05-10 2:46 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 2:46 [dpdk-dev] [PATCH v3 00/40] Fix build on gcc8 and various bugs Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 01/40] drivers/bus/pci: fix strncpy dangerous code Andy Green
2018-05-10 12:55 ` De Lara Guarch, Pablo
2018-05-10 2:46 ` Andy Green [this message]
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 03/40] drivers/net/axgbe: fix broken eeprom string comp Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 04/40] drivers/net/nfp/nfpcore: fix strncpy misuse Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 05/40] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 06/40] drivers/net/nfp: don't memcpy out of source range Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 07/40] drivers/net/nfp: fix buffer overflow in fw_name Andy Green
2018-05-10 2:46 ` [dpdk-dev] [PATCH v3 08/40] drivers/net/qede: fix strncpy constant and NUL Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 09/40] drivers/net/qede: fix broken strncpy Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 10/40] drivers/net/sfc: fix strncpy length Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 11/40] drivers/net/sfc: fix strncpy size and NUL Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 12/40] drivers/net/vdev: readlink inputs cannot be aliased Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 13/40] drivers/net/vdev: fix 3 x strncpy misuse Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 14/40] app/test-pmd: can't find include Andy Green
2018-05-10 13:50 ` De Lara Guarch, Pablo
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 15/40] app/proc-info: fix sprintf overrun bug Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 16/40] app/test-bbdev: test-bbdev: strcpy ok for allocated string Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 17/40] app/test-bbdev: " Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 18/40] rte_common.h: cast gcc builtin result to avoid complaints Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 19/40] rte_memcpy.h: explicit tmp cast Andy Green
2018-05-10 2:47 ` [dpdk-dev] [PATCH v3 20/40] lib/librte_eal/common/include/rte_lcore.h: explicit cast for signed change Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 21/40] /lib/librte_eal/common/include/rte_random.h: stage cast from uint64_t to long Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 22/40] rte_spinlock.h: stack declarations before code Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 23/40] rte_ring_generic.h: " Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 24/40] rte_ring.h: remove signed type flipflopping Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 25/40] rte_dev.h: stack declaration at top of own basic block Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 26/40] rte_mbuf.h: avoid truncation warnings from inadvertant int16_t to int promotion Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 27/40] rte_mbuf.h: explicit casts for flipping between int16_t and uint16_t Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 28/40] rte_mbuf.h: make sure RTE_MIN compares same types Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 29/40] rte_mbuf.h: explicit cast restricting ptrdiff to uint16_t Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 30/40] rte_mbuf.h: explicit cast for size_t to uint32_t Andy Green
2018-05-10 2:48 ` [dpdk-dev] [PATCH v3 31/40] rte_mbuf.h: explicit casts to uint16_t to avoid truncation warnings Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 32/40] rte_byteorder.h: explicit cast for return promotion Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 33/40] rte_ether.h: explicit cast avoiding truncation warning Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 34/40] rte_ether.h: stack vars declared at top of function Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 35/40] rte_ethdev.h: fix sign and scope of temp var Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 36/40] rte_ethdev.h: explicit cast for return type Andy Green
2018-05-10 19:18 ` Stephen Hemminger
2018-05-10 23:48 ` Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 37/40] rte_ethdev.h: explicit cast for truncation Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 38/40] rte_hash_crc.h: stack vars declared at top of function Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 39/40] rte_hash_crc.h: explicit casts for truncation Andy Green
2018-05-10 2:49 ` [dpdk-dev] [PATCH v3 40/40] rte_string_fns.h: explicit cast for int return to size_t Andy Green
2018-05-10 19:17 ` Stephen Hemminger
2018-05-11 0:13 ` Andy Green
2018-05-10 6:12 ` [dpdk-dev] [PATCH v3 00/40] Fix build on gcc8 and various bugs Jerin Jacob
2018-05-10 7:11 ` Andy Green
2018-05-10 9:19 ` Jerin Jacob
2018-05-10 6:17 ` Jerin Jacob
2018-05-10 6:46 ` Andy Green
2018-05-10 9:11 ` Jerin Jacob
2018-05-10 11:44 ` Andy Green
2018-05-10 11:58 ` Jerin Jacob
2018-05-10 12:13 ` Andy Green
2018-05-10 15:01 ` Stephen Hemminger
2018-05-11 0:29 ` Andy Green
2018-05-11 1:37 ` Andy Green
2018-05-13 13:58 ` Thomas Monjalon
2018-05-10 9:52 ` De Lara Guarch, Pablo
2018-05-10 11:57 ` Andy Green
2018-05-10 10:21 ` Luca Boccassi
2018-05-10 12:23 ` Andy Green
2018-05-10 12:35 ` Luca Boccassi
2018-05-10 13:36 ` Bruce Richardson
2018-05-10 13:49 ` Luca Boccassi
2018-05-10 13:53 ` Andy Green
2018-05-10 14:20 ` Andy Green
2018-05-10 13:59 ` Andy Green
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=152592038925.119328.7339714951968208684.stgit@localhost.localdomain \
--to=andy@warmcat.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).