Re: [PATCH V6 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets
From: Paolo Abeni
Date: Tue Sep 03 2024 - 08:08:40 EST
On 8/30/24 14:16, Jijie Shao wrote:
@@ -119,6 +122,20 @@ static void hbg_buffer_free_skb(struct hbg_buffer *buffer)
buffer->skb = NULL;
}
+static int hbg_buffer_alloc_skb(struct hbg_buffer *buffer)
+{
+ u32 len = hbg_spec_max_frame_len(buffer->priv, buffer->dir);
+ struct hbg_priv *priv = buffer->priv;
+
+ buffer->skb = netdev_alloc_skb(priv->netdev, len);
+ if (unlikely(!buffer->skb))
+ return -ENOMEM;
It's preferable to allocate the skbuff at packet reception time, inside
the poll() function, just before passing the skb to the upper stack, so
that the header contents are fresh in the cache. Additionally that
increases the change for the allocator could hit its fastpath.
+
+ buffer->skb_len = len;
+ memset(buffer->skb->data, 0, HBG_PACKET_HEAD_SIZE);
Out of sheer ignorace, why do you need to clear the packet data?
thanks,
Paolo