+static void store_udp_seq(struct netio_data *nd, struct io_u *io_u)
+{
+ struct udp_seq *us;
+
+ if (io_u->xfer_buflen < sizeof(*us))
+ return;
+
+ us = io_u->xfer_buf + io_u->xfer_buflen - sizeof(*us);
+ us->magic = cpu_to_le64((uint64_t) FIO_UDP_SEQ_MAGIC);
+ us->bs = cpu_to_le64((uint64_t) io_u->xfer_buflen);
+ us->seq = cpu_to_le64(nd->udp_send_seq++);
+}
+
+static void verify_udp_seq(struct thread_data *td, struct netio_data *nd,
+ struct io_u *io_u)
+{
+ struct udp_seq *us;
+ uint64_t seq;
+
+ if (io_u->xfer_buflen < sizeof(*us))
+ return;
+
+ if (nd->seq_off)
+ return;
+
+ us = io_u->xfer_buf + io_u->xfer_buflen - sizeof(*us);
+ if (le64_to_cpu(us->magic) != FIO_UDP_SEQ_MAGIC)
+ return;
+ if (le64_to_cpu(us->bs) != io_u->xfer_buflen) {
+ nd->seq_off = 1;
+ return;
+ }
+
+ seq = le64_to_cpu(us->seq);
+
+ if (seq != nd->udp_recv_seq)
+ td->ts.drop_io_u[io_u->ddir] += seq - nd->udp_recv_seq;
+
+ nd->udp_recv_seq = seq + 1;
+}
+