From patchwork Thu Mar 3 20:13:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 548371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCBB0C433F5 for ; Thu, 3 Mar 2022 20:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236202AbiCCUOJ (ORCPT ); Thu, 3 Mar 2022 15:14:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236162AbiCCUOI (ORCPT ); Thu, 3 Mar 2022 15:14:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BAF1C42A1; Thu, 3 Mar 2022 12:13:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC458B824B3; Thu, 3 Mar 2022 20:13:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B94C340EF; Thu, 3 Mar 2022 20:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646338399; bh=uwWraMZ+5Vaez+GGmc7m6MVYPejhXxGHYaXXvWLHTok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SqDpKXEnnVm1pcu9Vb7UDMyyjjnqmmM6a0nP8DBYapDyPZ3nSkxMqppRg/VmAb7DQ 9/B5lJjOf9n8PKVlJwtZb0odjITWc1ixslPWHwXFhGYyeo4sERjsGZtBmpOyp67W9r S+gV+4bsSWPexz+2SpdWxxXMUjx5YqRRdkqeTRoexl0gm9YOF18Qj2R7WKiC0E26AZ M1mvuHsjXLZkfXEuX0ZB8bsBFsw7BPDYTOqjf0T13e4fUjXBr1M90vJ6bwjIKgJ/Sd XAfSwD21vt1cp4tSY6V4p1oj81Sg4YW0I3xytSy1WkcG1MhW5TlNO29VjVPmjG+psa SRom+IVOSdFKA== From: Keith Busch To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com, Keith Busch , Hannes Reinecke , Chaitanya Kulkarni , Arnd Bergmann Subject: [PATCHv4 3/8] asm-generic: introduce be48 unaligned accessors Date: Thu, 3 Mar 2022 12:13:07 -0800 Message-Id: <20220303201312.3255347-4-kbusch@kernel.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20220303201312.3255347-1-kbusch@kernel.org> References: <20220303201312.3255347-1-kbusch@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The NVMe protocol extended the data integrity fields with unaligned 48-bit reference tags. Provide some helper accessors in preparation for these. Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Acked-by: Arnd Bergmann Signed-off-by: Keith Busch --- include/asm-generic/unaligned.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h index 1c4242416c9f..8fc637379899 100644 --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -126,4 +126,30 @@ static inline void put_unaligned_le24(const u32 val, void *p) __put_unaligned_le24(val, p); } +static inline void __put_unaligned_be48(const u64 val, __u8 *p) +{ + *p++ = val >> 40; + *p++ = val >> 32; + *p++ = val >> 24; + *p++ = val >> 16; + *p++ = val >> 8; + *p++ = val; +} + +static inline void put_unaligned_be48(const u64 val, void *p) +{ + __put_unaligned_be48(val, p); +} + +static inline u64 __get_unaligned_be48(const u8 *p) +{ + return (u64)p[0] << 40 | (u64)p[1] << 32 | p[2] << 24 | + p[3] << 16 | p[4] << 8 | p[5]; +} + +static inline u64 get_unaligned_be48(const void *p) +{ + return __get_unaligned_be48(p); +} + #endif /* __ASM_GENERIC_UNALIGNED_H */