net/hns3: add compile-time verification on Rx vector
[dpdk.git] / drivers / net / hns3 / hns3_rxtx_vec.c
index 08a86e0..dc1e1ae 100644 (file)
@@ -147,6 +147,28 @@ hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq)
        mb_def.port = rxq->port_id;
        rte_mbuf_refcnt_set(&mb_def, 1);
 
+       /* compile-time verifies the rearm_data first 8bytes */
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) <
+                        offsetof(struct rte_mbuf, rearm_data));
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) <
+                        offsetof(struct rte_mbuf, rearm_data));
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) <
+                        offsetof(struct rte_mbuf, rearm_data));
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) <
+                        offsetof(struct rte_mbuf, rearm_data));
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) <
+                        offsetof(struct rte_mbuf, rearm_data));
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) -
+                        offsetof(struct rte_mbuf, rearm_data) > 6);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) -
+                        offsetof(struct rte_mbuf, rearm_data) > 6);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) -
+                        offsetof(struct rte_mbuf, rearm_data) > 6);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) -
+                        offsetof(struct rte_mbuf, rearm_data) > 6);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) -
+                        offsetof(struct rte_mbuf, rearm_data) > 6);
+
        /* prevent compiler reordering: rearm_data covers previous fields */
        rte_compiler_barrier();
        p = (uintptr_t)&mb_def.rearm_data;