+\f
+/* A data structure for capturing packets received by a network device.
+ *
+ * This structure should be treated as opaque by network device
+ * implementations. */
+struct netdev_rx {
+ const struct netdev_rx_class *rx_class;
+ struct netdev_dev *netdev_dev;
+};
+
+void netdev_rx_init(struct netdev_rx *, struct netdev_dev *,
+ const struct netdev_rx_class *);
+void netdev_rx_uninit(struct netdev_rx *);
+struct netdev_dev *netdev_rx_get_dev(const struct netdev_rx *);
+
+struct netdev_rx_class {
+ /* Destroys 'rx'. */
+ void (*destroy)(struct netdev_rx *rx);
+
+ /* Attempts to receive a packet from 'rx' into the 'size' bytes in
+ * 'buffer'. If successful, returns the number of bytes in the received
+ * packet, otherwise a negative errno value. Returns -EAGAIN immediately
+ * if no packet is ready to be received.
+ *
+ * Must return -EMSGSIZE, and discard the packet, if the received packet
+ * is longer than 'size' bytes. */
+ int (*recv)(struct netdev_rx *rx, void *buffer, size_t size);
+
+ /* Registers with the poll loop to wake up from the next call to
+ * poll_block() when a packet is ready to be received with netdev_rx_recv()
+ * on 'rx'. */
+ void (*wait)(struct netdev_rx *rx);
+
+ /* Discards all packets waiting to be received from 'rx'. */
+ int (*drain)(struct netdev_rx *rx);
+};
+
+static inline void netdev_rx_assert_class(const struct netdev_rx *rx,
+ const struct netdev_rx_class *class_)
+{
+ ovs_assert(rx->rx_class == class_);
+}