From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9AD5F45C4B; Fri, 1 Nov 2024 14:57:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DA1E4027C; Fri, 1 Nov 2024 14:57:30 +0100 (CET) Received: from FR4P281CU032.outbound.protection.outlook.com (mail-germanywestcentralazon11022130.outbound.protection.outlook.com [40.107.149.130]) by mails.dpdk.org (Postfix) with ESMTP id E07564003C for ; Fri, 1 Nov 2024 14:57:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rm1qIKm0jtrJkDvzEgGcUiGrzhC5RIfooAtxxLu60wOup8zrR7B2D/n1Ap8jeoY78QOe/bkSj2b9ZAxGu4tDmGRBxtMLKAlDVd8UD4F0wf3eAZZwRcxLBs1rP/1ROGj0XznK1ziI6Gkme7WqgzUDBuhP/Yl42l+NgWv5lbA8PvciUP08p5S5zsB3Lxn5WcSyciH2nwWeg4F+z+lkZsG5G1SF9pujD8Fb49TBKCly/YzbL6Vzl/Y2ES8Tj8zRWorw0m2hBVJX2RLokSlRIyGXHdXx7yegOwH8ZE3wAUUt0o/qwfOHIuYTnm8DXkjtXDDojWCRFmopdw+p01kKenYBsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KfvTriHUi+KB/TfLKGQh34L6wFHU43hJEi5c349UrIM=; b=cPhji5eAl4hVnfLm7TdyRrE3HN/t93C7kHrMjA2EFTQvgWD8AHWeaweel6fqzrCZnJPbKSRA+3vUU7iS75AUmCqBBpMwKq9N2jByRQjRFe3mOoLz3JXEDk0gsl0Sdt+tCphVqlXVDbt5bz/g9DMGMZNSNSayUPryFh56acq1IC/7lfbVRzmK3ukqH2rSPsYZXHZWa9+b4CyanYSSX4mW2grMUybWZX58NC39pKzPH3NYH+sU8yMsK14QqtPymRW4sg0Dr1YpvfvT487UrO24tFe1IId9Z2f0fKQ5cvfTUzWa04jVeJn5LkugWxBci/uPZaClTg+654QUPa6cLa8LeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=allegro-packets.com; dmarc=pass action=none header.from=allegro-packets.com; dkim=pass header.d=allegro-packets.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=allegro-packets.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KfvTriHUi+KB/TfLKGQh34L6wFHU43hJEi5c349UrIM=; b=lRETWf7+STSvo1S9X5dgfR/C6uoH8JWY6kN5nBBHx/obLgieVRpMK4GXIMW+tPTOWhOIhd+2zX+VKTnoczdPa1+2qOjjjyGBZkivJJGT5vUF3cXjLQbyn/c7k/h+myW40LEHrl5JWyX7UclqYJB0EK+MFQIaokAF+Jh3K5dVNShWWlOJS8xOyfjOZRRcex7rc02T4BLGqUD5io65O+/m3j6xGBYpgG2eT111qiLtY+NveH5FvUO+SR7RaPTd1pQv8CmYpWtbtcwaAfSqSRbrgkbe5m9mmbnVyfI6ZnbIIPXUMYdCx7QVvd/68mwvmQV9O7LG4xBlrPuDW5cFdS7wIw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=allegro-packets.com; Received: from BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:60::13) by FR4P281MB3936.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:100::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.24; Fri, 1 Nov 2024 13:57:27 +0000 Received: from BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM ([fe80::e877:d319:1b52:4c53]) by BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM ([fe80::e877:d319:1b52:4c53%7]) with mapi id 15.20.8114.015; Fri, 1 Nov 2024 13:57:27 +0000 Message-ID: <00f78eba-8eff-4c67-8ecf-3bef5f25b9f6@allegro-packets.com> Date: Fri, 1 Nov 2024 14:57:26 +0100 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Bruce Richardson Cc: dev@dpdk.org From: Martin Weiser Subject: [PATCH v2] igc: fix invalid length and corrupted multi-segment mbufs Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0079.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::7) To BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:60::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BE1P281MB3111:EE_|FR4P281MB3936:EE_ X-MS-Office365-Filtering-Correlation-Id: c62baf53-3d47-4f7c-6d36-08dcfa7d1eaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|10070799003|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dElSekNFYzRpR1M2NWQzTGZSTXF5MG9Oa2s2MVFESkRRL1dPdk9EekQvbmJK?= =?utf-8?B?Tk5pOE9kMFN0U3ZNenlYUUZVS0RsNHhwanhkK05TWlRwN3NmNVdodFJhUEo0?= =?utf-8?B?Z1BCN3daenVmWWVEK1pnanZra1ZoWmxpZ051TXdXdEtyUklmZHRBRWlXYXgx?= =?utf-8?B?b05mZ2NIU0tETy9maGpUZ0NVdGhwSFRTN0p0YW5OTUxIM21Sd21QdDdNOXk2?= =?utf-8?B?c09EeWFrV0JCN2JkOFNxbXVqWS9xR1ZsNUtPNW1zVFhESk9NWUdv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FVVYTFwQmNaVEtyZENDZ2tG?= =?utf-8?B?Y01CdWwwT29iQ0EvS1F3NnEyc0IyTFRnUk94K1d4ckNvNHhITWhCL2FvSlVy?= =?utf-8?B?NE5udmV2MnF6cG0rRUpGa3NIRG5WUVVHRXlVemg3a0ZodjBaRWZoL0ZSYmJp?= =?utf-8?B?Wmo5TjdiV29aaWRCTmM2TEloKzM3MFJXbk1uaTIxaHN0RWNYNUN6eW12OHNM?= =?utf-8?B?U3h4YU9rSkIzc2JFaEtWNzl3RFdWTzVNK21keVhmUDJYVUd2SmVqbXZ1Rnpt?= =?utf-8?B?NE00TVVZV1ByRnQ5N2FKS3hYYzFUQThwdUpCenNITG1HTGhWekwvdlJiOGcy?= =?utf-8?B?bWF6TStUL0pWRUVzT1N3YTZZOWhmelFXVDM1N3RlK3dwVXFZT0dNU0lmMm5u?= =?utf-8?B?RTdyRCs5b1Vpa0dtaGhPRW1yaDdhaW5TcGZNdzkybi91Vy9vYk5mS1pxT1pk?= =?utf-8?B?OEtXVDNpNHR5Z2JBMnpFTzJtRXEvT1BpWW1SYjNCeXZWTEswb0d2ekx4S0lL?= =?utf-8?B?STJHZ0ZRYnhpZE9nQzJmWmpBZEpDbEt3T1I4WVA5M09mc1p5KzJ3SXdJTkxJ?= =?utf-8?Q?JKuYsJKeviudAOy7QMO6v3OIh8bAeCPeL1OoVmX?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(376014)(10070799003)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aThSQ0J0RldxRTBmQjBrbkh4SWUyV3lUSjJmdHJ6a1NQbXpDNjF5emtkWkRG?= =?utf-8?B?SUFacWRCdjk5cFpNNDNZS29XTUkzcj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?MGdPQXZwM2k5dWM3VWdueTg4UmJVZUJHVnVIMGxrTG9LVWRiZFRSL2FzeXNj?= =?utf-8?B?aTNrR1Z1dWJOTGtLRjhOVVRiUEFBaGZFcEVNaHBsWnBIaXdQQ2lqS05iN3Y2?= =?utf-8?B?TFN3U2Yvbk9qVWs1NFRCR1k5ZVMxYnViYkE3NVp3bGErRytEUGpmcWVNL1A2?= =?utf-8?B?SEFJWVl3aHhsOWJyMVFoQkovSW5WMG5nQ1lOZDUvM2lBNlNudGcrZXpuR1ZU?= =?utf-8?B?RE5NdnJWdVQycnR2dUU4a0tON3lPU21rcUJOMHRQVUZPQ3FtMVBSZytQdUFu?= =?utf-8?B?WW5hSnNlREVDUnFJRkxXWkhjR0lOQ0hVSUJUb3QvNnFsT2RSZGNPSEpqZG1w?= =?utf-8?B?dWtEUEtEZHVncWpBaHFWTS9Ha0x3PT0=?= X-OriginatorOrg: allegro-packets.com X-MS-Exchange-CrossTenant-Network-Message-Id: c62baf53-3d47-4f7c-6d36-08dcfa7d1eaf X-MS-Exchange-CrossTenant-AuthSource: BE1P281MB3111.DEUP281.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 13:57:27.3634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c65709ba-d173-4248-a752-2f88437ee1ad X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3aIvpvEzi5OTCxjt19FQB85LmzSySF74I4dixiIzWI2gnZ/5o0dbA8ZN1mzMc2oXeJv8IBFpRxfVGwoU4l8/3SR4DgmSwFg2xjSViOc3wqOckdac83idYq0CiyAW1FCz X-MS-Exchange-Transport-CrossTenantHeadersStamped: FR4P281MB3936 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The issue only appeared with hardware-timestamping enabled (RTE_ETH_RX_OFFLOAD_TIMESTAMP). The length of the prepended hardware timestamp was not subtracted from the data length so that received packets were 16 bytes longer than expected. In scatter-gather mode only the first mbuf has a timestamp but the data offset of the follow-up mbufs was not adjusted accordingly. This caused 16 bytes of packet data to be missing between the segments. Signed-off-by: Martin Weiser --- v2: * Added comments for clarification. drivers/net/igc/igc_txrx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c index d0cee1b016..fabab5b1a3 100644 --- a/drivers/net/igc/igc_txrx.c +++ b/drivers/net/igc/igc_txrx.c @@ -347,6 +347,13 @@ igc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->data_off = RTE_PKTMBUF_HEADROOM; data_len = rte_le_to_cpu_16(rxd.wb.upper.length) - rxq->crc_len; + /* + * When the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload is enabled the + * length in the descriptor still accounts for the timestamp so + * it must be subtracted. + */ + if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) + data_len -= IGC_TS_HDR_LEN; rxm->data_len = data_len; rxm->pkt_len = data_len; rxm->nb_segs = 1; @@ -509,6 +516,24 @@ igc_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, */ rxm->data_off = RTE_PKTMBUF_HEADROOM; data_len = rte_le_to_cpu_16(rxd.wb.upper.length); + if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) { + /* + * When the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload is enabled + * the pkt_addr of all software ring entries is moved forward + * by IGC_TS_HDR_LEN (see igc_alloc_rx_queue_mbufs()) so that + * when the hardware writes the packet with a prepended + * timestamp the actual packet data still starts at the + * normal data offset. The length in the descriptor still + * accounts for the timestamp so it needs to be subtracted. + * Follow-up mbufs do not have the timestamp so the data + * offset must be adjusted to point to the start of the packet + * data. + */ + if (first_seg == NULL) + data_len -= IGC_TS_HDR_LEN; + else + rxm->data_off -= IGC_TS_HDR_LEN; + } rxm->data_len = data_len; /* @@ -557,6 +582,7 @@ igc_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, last_seg->data_len = last_seg->data_len - (RTE_ETHER_CRC_LEN - data_len); last_seg->next = NULL; + rxm = last_seg; } else { rxm->data_len = (uint16_t) (data_len - RTE_ETHER_CRC_LEN); -- 2.47.0