+static_always_inline void
+dpdk_mbuf_init_from_template (struct rte_mbuf **mba, struct rte_mbuf *mt,
+ int count)
+{
+ /* Assumptions about rte_mbuf layout */
+ STATIC_ASSERT_OFFSET_OF (struct rte_mbuf, buf_addr, 0);
+ STATIC_ASSERT_OFFSET_OF (struct rte_mbuf, buf_iova, 8);
+ STATIC_ASSERT_SIZEOF_ELT (struct rte_mbuf, buf_iova, 8);
+ STATIC_ASSERT_SIZEOF_ELT (struct rte_mbuf, buf_iova, 8);
+ STATIC_ASSERT_SIZEOF (struct rte_mbuf, 128);
+
+ while (count--)
+ {
+ struct rte_mbuf *mb = mba[0];
+ int i;
+ /* bytes 0 .. 15 hold buf_addr and buf_iova which we need to preserve */
+ /* copy bytes 16 .. 31 */
+ *((u8x16 *) mb + 1) = *((u8x16 *) mt + 1);
+
+ /* copy bytes 32 .. 127 */
+#ifdef CLIB_HAVE_VEC256
+ for (i = 1; i < 4; i++)
+ *((u8x32 *) mb + i) = *((u8x32 *) mt + i);
+#else
+ for (i = 2; i < 8; i++)
+ *((u8x16 *) mb + i) = *((u8x16 *) mt + i);
+#endif
+ mba++;
+ }
+}
+