- /* Arranges for 'cb' to be called whenever one of the attributes of
- * 'netdev' changes and sets '*notifierp' to a newly created
- * netdev_notifier that represents this arrangement. The created notifier
- * will have its 'netdev', 'cb', and 'aux' members set to the values of the
- * corresponding parameters. */
- int (*poll_add)(struct netdev *netdev,
- void (*cb)(struct netdev_notifier *notifier), void *aux,
- struct netdev_notifier **notifierp);
-
- /* Cancels poll notification for 'notifier'. */
- void (*poll_remove)(struct netdev_notifier *notifier);
+ /* Returns a sequence number which indicates changes in one of 'netdev''s
+ * properties. The returned sequence number must be nonzero so that
+ * callers have a value which they may use as a reset when tracking
+ * 'netdev'.
+ *
+ * Minimally, the returned sequence number is required to change whenever
+ * 'netdev''s flags, features, ethernet address, or carrier changes. The
+ * returned sequence number is allowed to change even when 'netdev' doesn't
+ * change, although implementations should try to avoid this. */
+ unsigned int (*change_seq)(const struct netdev *netdev);
+};
+\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);