> +/**
> + * tp4q_enqueue_from_array - Enqueue entries from packet array to tp4 queue
> + *
> + * @a: Pointer to the packet array to enqueue from
> + * @dcnt: Max number of entries to enqueue
> + *
> + * Returns 0 for success or an errno at failure
> + **/
> +static inline int tp4q_enqueue_from_array(struct tp4_packet_array *a,
> +                                         u32 dcnt)
> +{
> +       struct tp4_queue *q = a->tp4q;
> +       unsigned int used_idx = q->used_idx;
> +       struct tpacket4_desc *d = a->items;
> +       int i;
> +
> +       if (q->num_free < dcnt)
> +               return -ENOSPC;
> +
> +       q->num_free -= dcnt;

perhaps annotate with a lockdep_is_held to document which lock
ensures mutual exclusion on the ring. Different for tx and rx?

> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index b39be424ec0e..190598eb3461 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -189,6 +189,9 @@ static int packet_set_ring(struct sock *sk, union 
> tpacket_req_u *req_u,
>  #define BLOCK_O2PRIV(x)        ((x)->offset_to_priv)
>  #define BLOCK_PRIV(x)          ((void *)((char *)(x) + BLOCK_O2PRIV(x)))
>
> +#define RX_RING 0
> +#define TX_RING 1
> +

Not needed if using bool for tx_ring below. The test effectively already
treats it as bool: does not explicitly test these constants.

> +static void packet_clear_ring(struct sock *sk, int tx_ring)
> +{
> +       struct packet_sock *po = pkt_sk(sk);
> +       struct packet_ring_buffer *rb;
> +       union tpacket_req_u req_u;
> +
> +       rb = tx_ring ? &po->tx_ring : &po->rx_ring;


I meant here.

Reply via email to