On Fri, May 23, 2014 at 11:04 AM, Daniele Di Proietto
<[email protected]> wrote:
> The netdev_send_batch function allows netdevs to send packets
> more efficiently. This will be useful for netdev-dpdk.
> If a netdev does not implement send_batch, netdev_send_batch
> calls send repeatedly.
>
....
>
> +/* Sends 'c' 'buffers' on 'netdev'. If 'netdev' supports batching, uses
> + * send_batch(), otherwise iterates through 'buffers' and uses send().
> + * Returns 0 if successful, otherwise a positive errno value.
> + *
> + * To retain ownership of 'buffer' caller can set may_steal to false.
> + *
> + * If any error occurs during the transmission of one buffer, the function
> + * stops and return the error. */
> +int
> +netdev_send_batch(struct netdev *netdev, struct ofpbuf **buffers, int c,
> + bool may_steal)
> +{
> + int error;
> +
> + error = (netdev->netdev_class->send_batch
> + ? netdev->netdev_class->send_batch(netdev, buffers, c,
> may_steal)
> + : EOPNOTSUPP);
> +
Can you just add extra parameter to send call. Lets not add extra
checks in fast path.
> + if (error == EOPNOTSUPP) {
> + int i;
> +
> + for (i = 0; i < c; i++) {
> + error = (netdev->netdev_class->send
> + ? netdev->netdev_class->send(netdev, buffers[i],
> may_steal)
> + : EOPNOTSUPP);
> + if (error) {
> + break;
> + }
> + }
> +
> + if (error && may_steal) {
> + int j;
> +
> + for (j = (error == EOPNOTSUPP) ? i : i+1; j < c; j++) {
> + ofpbuf_delete(buffers[j]);
> + }
> + }
> + }
> + if (!error) {
> + COVERAGE_INC(netdev_sent);
> + }
> + return error;
> +}
> +
> /* Registers with the poll loop to wake up from the next call to poll_block()
> * when the packet transmission queue has sufficient room to transmit a
> packet
> * with netdev_send().
> diff --git a/lib/netdev.h b/lib/netdev.h
> index a4bd01a..dff516f 100644
> --- a/lib/netdev.h
> +++ b/lib/netdev.h
> @@ -172,6 +172,7 @@ int netdev_rxq_drain(struct netdev_rxq *);
>
> /* Packet transmission. */
> int netdev_send(struct netdev *, struct ofpbuf *, bool may_steal);
> +int netdev_send_batch(struct netdev *, struct ofpbuf **, int c, bool
> may_steal);
> void netdev_send_wait(struct netdev *);
>
> /* Hardware address. */
> --
> 2.0.0.rc0
>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev