Re: [net-next v5 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices
From: David Miller
Date: Tue Aug 25 2020 - 20:20:18 EST
From: Vadym Kochan <vadym.kochan@xxxxxxxxxxx>
Date: Tue, 25 Aug 2020 15:20:08 +0300
> +int prestera_dsa_parse(struct prestera_dsa *dsa, const u8 *dsa_buf)
> +{
> + __be32 *dsa_words = (__be32 *)dsa_buf;
> + enum prestera_dsa_cmd cmd;
> + u32 words[4] = { 0 };
> + u32 field;
> +
> + words[0] = ntohl(dsa_words[0]);
> + words[1] = ntohl(dsa_words[1]);
> + words[2] = ntohl(dsa_words[2]);
> + words[3] = ntohl(dsa_words[3]);
All 4 elements of words[] are explicitly and unconditionally set to something,
so you don't need the "= { 0 }" initializer.
> + INIT_LIST_HEAD(&sw->port_list);
What locking protects this list?
> + new_skb = alloc_skb(len, GFP_ATOMIC | GFP_DMA);
> + if (!new_skb)
> + goto err_alloc_skb;
This seems very costly to do copies on every packet. There should be
something in the dma_*() API that would allow you to avoid this.
And since you just need the buffer to DMA map it into the device,
allocating an entire SKB object is overkill. You can instead just
allocate a ring of TX bounce buffers once, and then you just copy
each packet there. No allocations per packet.