lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e25187c-ce88-4415-91ee-4c636964b674@huawei.com>
Date: Tue, 3 Sep 2024 20:57:34 +0800
From: Jijie Shao <shaojijie@...wei.com>
To: Paolo Abeni <pabeni@...hat.com>, <davem@...emloft.net>,
	<edumazet@...gle.com>, <kuba@...nel.org>
CC: <shaojijie@...wei.com>, <shenjian15@...wei.com>,
	<wangpeiyang1@...wei.com>, <liuyonglong@...wei.com>, <chenhao418@...wei.com>,
	<sudongming1@...wei.com>, <xujunsheng@...wei.com>, <shiyongbang@...wei.com>,
	<libaihan@...wei.com>, <andrew@...n.ch>, <jdamato@...tly.com>,
	<horms@...nel.org>, <jonathan.cameron@...wei.com>,
	<shameerali.kolothum.thodi@...wei.com>, <salil.mehta@...wei.com>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V6 net-next 07/11] net: hibmcge: Implement rx_poll
 function to receive packets


on 2024/9/3 20:08, Paolo Abeni wrote:
> 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.

In hibmcge driver, we alloc the skb memory first, after dma, and then set the dam address to the MAC for receiving packets.
After receiving a packet, MAC fills the hw rx descriptor and packet content to skb->data, and then reports an RX interrupt to trigger the driver to receive the packet.
In poll(), we use skb_reserve() to adjust the size of the SKB headroom. The skb->data is moved backward by the descriptor length(HBG_PACKET_HEAD_SIZE) to ensure
the skb->data is at the start position of the packet.

    ┌─────────────────┬────────────────────────────────────┐
    │hw rx descriptor │                packet              │
    │                 │                                    │
    └─────────────────┴────────────────────────────────────┘
    ^
   skb->data

>
>> +
>> +    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?
>
>
The length of HBG_PACKET_HEAD_SIZE is exactly the size of the rx descriptor. Therefore, we want to clear before receiving packets to ensure that the descriptor is correct.

	Thanks
	Jijie Shao


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ