* Each "dealloc" function frees raw memory that was allocated by the the
* "alloc" function. The memory's base and derived members might not have ever
* been initialized (but if "construct" returned successfully, then it has been
- * "destruct"ed already). The "dealloc" function is not allowed to fail. */
+ * "destruct"ed already). The "dealloc" function is not allowed to fail.
+ *
+ *
+ * Device Change Notification
+ * ==========================
+ *
+ * Minimally, implementations are required to report changes to netdev flags,
+ * features, ethernet address or carrier through connectivity_seq. Changes to
+ * other properties are allowed to cause notification through this interface,
+ * although implementations should try to avoid this. connectivity_seq_get()
+ * can be used to acquire a reference to the struct seq. The interface is
+ * described in detail in seq.h. */
struct netdev_class {
/* Type of netdevs in this class, e.g. "system", "tap", "gre", etc.
*
const struct netdev_tunnel_config *
(*get_tunnel_config)(const struct netdev *netdev);
- /* Sends the 'size'-byte packet in 'buffer' on 'netdev'. Returns 0 if
- * successful, otherwise a positive errno value. Returns EAGAIN without
- * blocking if the packet cannot be queued immediately. Returns EMSGSIZE
- * if a partial packet was transmitted or if the packet is too big or too
- * small to transmit on the device.
+ /* Sends the buffer on 'netdev'.
+ * Returns 0 if successful, otherwise a positive errno value. Returns
+ * EAGAIN without blocking if the packet cannot be queued immediately.
+ * Returns EMSGSIZE if a partial packet was transmitted or if the packet
+ * is too big or too small to transmit on the device.
*
- * The caller retains ownership of 'buffer' in all cases.
+ * To retain ownership of 'buffer' caller can set may_steal to false.
*
* The network device is expected to maintain a packet transmission queue,
* so that the caller does not ordinarily have to do additional queuing of
* network device from being usefully used by the netdev-based "userspace
* datapath". It will also prevent the OVS implementation of bonding from
* working properly over 'netdev'.) */
- int (*send)(struct netdev *netdev, const void *buffer, size_t size);
+ int (*send)(struct netdev *netdev, struct ofpbuf *buffer, bool may_steal);
/* Registers with the poll loop to wake up from the next call to
* poll_block() when the packet transmission queue for 'netdev' has
int (*update_flags)(struct netdev *netdev, enum netdev_flags off,
enum netdev_flags on, enum netdev_flags *old_flags);
- /* 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);
-
/* ## ------------------- ## */
/* ## netdev_rx Functions ## */
/* ## ------------------- ## */
void (*rx_destruct)(struct netdev_rx *);
void (*rx_dealloc)(struct netdev_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.
+ /* Attempts to receive batch of packets from 'rx' and place array of pointers
+ * into '*pkt'. netdev is responsible for allocating buffers.
+ * '*cnt' points to packet count for given batch. Once packets are returned
+ * to caller, netdev should give up ownership of ofpbuf data.
*
- * Must return -EMSGSIZE, and discard the packet, if the received packet
- * is longer than 'size' bytes.
+ * Implementations should allocate buffer with DP_NETDEV_HEADROOM headroom
+ * and add a VLAN header which is obtained out-of-band to the packet.
*
- * Specify NULL if this */
- int (*rx_recv)(struct netdev_rx *rx, void *buffer, size_t size);
+ * Caller is expected to pass array of size MAX_RX_BATCH.
+ * This function may be set to null if it would always return EOPNOTSUPP
+ * anyhow. */
+ int (*rx_recv)(struct netdev_rx *rx, struct ofpbuf **pkt, int *cnt);
/* 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()