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 98F2E41CF0; Mon, 20 Feb 2023 21:10:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 806BF430D2; Mon, 20 Feb 2023 21:10:58 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 5D21640395 for ; Mon, 20 Feb 2023 21:10:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676923857; x=1708459857; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=3bWBtXALRepgodQ2l3fSNGG4PUrGInJj6UXRqXwPEZ8=; b=mhHcTqdyLwHNWOq0U4dfCjg7vPJND4b65q0AH7C61QCtz54dKCY6PJm+ P4FpG8qMKl+shNHWd2aAJpimjxC+NZYQkG8wWoM0r43x7ASf298yP+htE 9SNeBwIB+qREbJ6bBd4PHSnDiM5/f7PboHaFMJtAg++X50vT3wVWrBSJd yIs3ceEz7i10tvGK2vzfmEGcURhdr7ubZfHQBMv8kVSyFOkOijowv2NXR P1O4DzFR6KFJb0q0VtNCfzAKpvVGhPpnGUtGRp29BCGyLm2sBiIs9Khyr OMYCcuHWLdSpuNKLl++O1PH3Fo8E7ckS5yeKWuF6yYtmDRgAyoTtekrz1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="312112959" X-IronPort-AV: E=Sophos;i="5.97,313,1669104000"; d="scan'208";a="312112959" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2023 12:10:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="648931893" X-IronPort-AV: E=Sophos;i="5.97,313,1669104000"; d="scan'208";a="648931893" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga006.jf.intel.com with ESMTP; 20 Feb 2023 12:10:56 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 20 Feb 2023 12:10:55 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 20 Feb 2023 12:10:55 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.47) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 20 Feb 2023 12:10:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7eDekvweltdeCsSg8ccnPlQUudTvWHlNC8tKKyP2Jn2YntWxDaj/J0SPFQgtokWL1nOax8xMtDCiyAFr+2cnD/rTauxX7Xb3iMltj3bpnx3XfZ5Y3dHanqYMhXpFLetUGI/7mcPvn3+xvN9hw/KrZ64mrJU3i2ATVIglAxax01W5qK2KsG6J8eSSGp3Sa/GykggNHbsq20X+r8QaytMVtWKEjnJB9BuW3/jEs+BMvKhWyaU6uo4RANEDlkqde15Al/Ioa7oaG1GCqRottw7BYrlwOV3CNHpkGnxSUVqND66Cv4UPh1aG7rMYEEwGr+o4BJ04SfDBqHt34JT6xsTqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=eCmDv4I1VqH8MenEdCsjeS0Zb7v0ovgZuRi8Htwlc6s=; b=bQLoDIi8meaiqVDrFUb+EINxG3C0AmYwKdhtjcSpWhyC/EZO2TZBP81lqnqQ+0UeIYo3ueYQVTlLVfOfQzix84gP7HVP9d8qp2d2jmb/NHWBHiWE0p6OpAjLS2X4SONaKksAh1Pu7+M7Z1lPOw5LKZAEvxFUJmN11czv/TK+uBU2MWGDqd4vGmdnuMhX14GehaaMgTCa00peXfKmVrqcWlcMND7q2S4ZigWyPDFFJboptgUtlriPeaFhh3kgtpSsiuLGC+gIAEdN7+SYiihcncrPZ3/WSsllid1/RO+uu+xeYS9P7yk8rSAXvlcVhLTwOzoWALd0Dnh7zEgrsrmYfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8) by IA1PR11MB7677.namprd11.prod.outlook.com (2603:10b6:208:3fd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 20:10:53 +0000 Received: from SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::d8e2:d192:9b46:bc2c]) by SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::d8e2:d192:9b46:bc2c%5]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 20:10:53 +0000 Message-ID: <18974072-6d67-c82b-bd69-3eb54f631573@intel.com> Date: Mon, 20 Feb 2023 20:10:45 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [PATCH v3] hash: add XOR32 hash function To: Bili Dong , CC: , References: <20230215105442.3878441-1-qobilidop@gmail.com> <20230215110630.3885175-1-qobilidop@gmail.com> Content-Language: en-US From: "Medvedkin, Vladimir" In-Reply-To: <20230215110630.3885175-1-qobilidop@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO6P123CA0009.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:338::12) To SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR11MB5772:EE_|IA1PR11MB7677:EE_ X-MS-Office365-Filtering-Correlation-Id: c8d31132-7d16-46aa-5d00-08db137e911f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bUsrZFO0gNqAxAbyYEcsuaQAnJvLJzpwdSzG0eYik7cIJCnqb4ZqCy0wwS6wo4GfMalMDN0tDHVRM6PdcEQYHVN0LyFThY8+hGHaRPqSeCLld+CzQ2TH79jk+knKy0Df9WuJKdmNbI3T53uAy/WFjFEgzxi3LpK9WNJmnIctiX78ncqTSEVkfE8znsFozmJCu4e2WxFFmaA7oSj0CiyLPuyv3cRTgEw+ahNLjR1N/megDRbMjw3SJ7npdzdMOnkDIPN/0XfgIkGgpvWFmIQ3TiLI65P1x03jn+95p9owlETm1tjpRRhr+4Xepn0IaKyJUGM+bUie/0KcQ5GIPn9iH6/PXkwVbb0znu0VIsrnuH2NOZbPnBK3NTeDZSJfXX15GNWARIDOGNMSqqjZzM6g2uPvPufai0VmaHRH5Jp/R1vbkJiPfveuX8N5/7b29vHm27HJDCvJTcgGrimBo8JU07IGMuKDxIRofAe+GYs6YkB41Rrep64VMYLYL7A9XBjlyR2WLGM4sgS47AsKxYvZIXH9RVxfv8RUgT9SED9URpYlRxVG2BWuOXYk1t6DVC/lWi/LryU0XNcKBgQU3VK2SnFYNafbEqGPopFTxb7byYNwZgl7HuL6ZQyCREbr2/etVyR2taWVwUstQ1Vnm985gu0NnlhXdqYEj8AvqVu60plhknH9X4wXP6dqqC2K59q+wFymZev+fh4FGVrs8wa4LT25K95shbAyUYM9atJk1DQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB5772.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(396003)(346002)(136003)(376002)(39860400002)(366004)(451199018)(316002)(66476007)(66556008)(41300700001)(6636002)(8936002)(5660300002)(6666004)(107886003)(8676002)(4326008)(2616005)(66946007)(53546011)(26005)(186003)(6512007)(478600001)(6486002)(6506007)(36756003)(31696002)(2906002)(82960400001)(38100700002)(31686004)(86362001)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Y09heHZ2MkZZS1dkRUo4M1VmTnJ1eFRPUjRXMFJJM2hZMU9IbUhUMTdDQ0d1?= =?utf-8?B?S0M3QU5mQVpLaTN3U093K2NMa1lCTEZqNVBGWHQyRXJqdDREMnh0WG5qOFJt?= =?utf-8?B?eHFxcE9HWGYwdmpDZjhVRm5JOHZ5YSszc0xpck5zanJmR2MvRDZ3VlRsWG1X?= =?utf-8?B?OFJaVCtzdXpWT3ltdTdXRWg3a2ViL01reTRKMW0xaUxRNkdBUDROK0FidzRa?= =?utf-8?B?WFlBWklJNlI5YnUvNjNnQ2sxRGF4Z2NzV1huUFFRUjljQnk5L0RIQmQ5RDV5?= =?utf-8?B?anNGMGhxSC9Ubkh0c0VYYmV5VU9MTVN2Mkl2dEdRK2tSUkxiZE5uVG0zeHNs?= =?utf-8?B?Mm9IcUMreXVFS1Z4KzNSQU0wWEZ0ZUl6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9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: c8d31132-7d16-46aa-5d00-08db137e911f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5772.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 20:10:52.7740 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0u32Fi0osVRGVnRD1UPjjyZlxN7SxandGHjLS84VdV9/eZy7r0vnDEaYVmaYygRkk28QDsa0sYlORtFcFf/hKFutp6x9xnbh+6vQ9q73Mcg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7677 X-OriginatorOrg: intel.com 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 Hi Bill, On 15/02/2023 11:06, Bili Dong wrote: > An XOR32 hash is needed in the Software Switch (SWX) Pipeline for its > use case in P4. We implement it in this patch so it could be easily > registered in the pipeline later. > > Signed-off-by: Bili Dong > --- > +static inline uint32_t > +rte_hash_xor(const void *data, uint32_t data_len, uint32_t init_val) > +{ > + uint32_t i; > + uintptr_t pd = (uintptr_t) data; > + init_val = rte_cpu_to_be_32(init_val); > + > + for (i = 0; i < data_len / 4; i++) { > + init_val ^= *(const uint32_t *)pd; > + pd += 4; > + } > + > + if (data_len & 0x2) { > + init_val ^= *(const uint32_t *)pd & LEFT16b_MASK; Here you are reading 2 bytes after the data buffer, which can sometimes lead to segfault. I think it would be better just to: init_val ^= *(const uint16_t *)pd << 16; The same with the section bellow > + pd += 2; > + } > + > + if (data_len & 0x1) > + init_val ^= *(const uint32_t *)pd & LEFT8b_MASK; > + > + init_val = rte_be_to_cpu_32(init_val); > + return init_val; > +} > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTE_HASH_XOR_H_ */ -- Regards, Vladimir