net: mvneta: add support for multiplying Tx packets using SO_MARK

Sometimes it's quite convenient to be able to emit wire-rate packets,
but passing via skbs is very expensive and generally makes this
impossible.

Here we use a different approach. The xmit function checks if the
skb belongs to a SOCK_PACKET, and if so, then it uses sk->sk_mark as
a number of replicas to send (0 by default). It then iterates over
the same skb for the announced number of replicas and decrements
sk_mark as it adds them.

In order to know when to release the DMA mapping, an extra skb_get()
is performed. That way we can check the skb_shared() upon Tx completion
and release the skb and DMA mapping when we reach the last packet for
the skb.

The caller just has to set the desired number of replicas by issuing
a setsockopt(SOL_SOCKET, SO_MARK) on the socket. It knows how many of
them were left to be sent on return, so it can count the effective
number of packets sent (1+initial-final).

Using this mechanism, it is possible to produce 1.485 Mpps on a very
small fanless machine.
1 file changed