From patchwork Thu Jan 30 10:00:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniket Limaye X-Patchwork-Id: 56284 X-Patchwork-Delegate: reatmon@ti.com 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 508B2C0218A for ; Thu, 30 Jan 2025 10:01:19 +0000 (UTC) Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) by mx.groups.io with SMTP id smtpd.web11.12265.1738231271624612704 for ; Thu, 30 Jan 2025 02:01:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=sC6EFomA; spf=pass (domain: ti.com, ip: 198.47.23.234, mailfrom: a-limaye@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 50UA1BdA2327338 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 30 Jan 2025 04:01:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1738231271; bh=KOYkbPYK2+AR0eR6g3WF5JEjWStfSny9B/gcSnFGBc8=; h=From:To:CC:Subject:Date; b=sC6EFomApx7FcXmHJsPxQ3VUbIGcbuVprM7lUSGTDpoQ/Qnb5qWxD7LUluzxjaRdu baXX6id8vI7DLI7FmmgJTYJaHRBgFNqfuwPHw1qhrtp1gTzmo+Jn/C+gsbskoe6ZQa O6JqIPdkwdllmj/DUtdOFNdQ0wvQekaDB2r4GeQQ= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50UA1BX8079979 for ; Thu, 30 Jan 2025 04:01:11 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 30 Jan 2025 04:01:10 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 30 Jan 2025 04:01:10 -0600 Received: from psdkl-workstation0.dhcp.ti.com (psdkl-workstation0.dhcp.ti.com [172.24.227.91]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50UA18Tp030975; Thu, 30 Jan 2025 04:01:09 -0600 From: Aniket Limaye To: CC: , , Aniket Limaye Subject: [meta-arago][master][PATCH] ti-test: Add mcrc64 test application Date: Thu, 30 Jan 2025 15:30:48 +0530 Message-ID: <20250130100105.507586-1-a-limaye@ti.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 30 Jan 2025 10:01:19 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/15783 From: Udit Kumar Add mcrc64 test application recipe. This application is documented at[0]. [0]: https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-j722s/10_01_00_04/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/MCRC64.html Signed-off-by: Aniket Limaye Signed-off-by: Udit Kumar --- .../recipes-core/packagegroups/ti-test.bb | 1 + .../recipes-kernel/mcrc64/files/mcrc64.c | 114 ++++++++++++++++++ .../recipes-kernel/mcrc64/mcrc64.bb | 19 +++ 3 files changed, 134 insertions(+) create mode 100644 meta-arago-test/recipes-kernel/mcrc64/files/mcrc64.c create mode 100644 meta-arago-test/recipes-kernel/mcrc64/mcrc64.bb diff --git a/meta-arago-test/recipes-core/packagegroups/ti-test.bb b/meta-arago-test/recipes-core/packagegroups/ti-test.bb index 814e3ea6..1399a267 100644 --- a/meta-arago-test/recipes-core/packagegroups/ti-test.bb +++ b/meta-arago-test/recipes-core/packagegroups/ti-test.bb @@ -55,6 +55,7 @@ TI_TEST_BASE = "\ tcpdump \ v4l-utils \ yavta \ + mcrc64 \ " TI_TEST_EXTRAS = " \ diff --git a/meta-arago-test/recipes-kernel/mcrc64/files/mcrc64.c b/meta-arago-test/recipes-kernel/mcrc64/files/mcrc64.c new file mode 100644 index 00000000..fc7a75d6 --- /dev/null +++ b/meta-arago-test/recipes-kernel/mcrc64/files/mcrc64.c @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ + +#include +#include +#include +#include +#include +#include + +#define BUFFER_SIZE 4096 +#define SECTOR 4096 + +int main (int argc, char **argv) { + + int desc[2] = { -1, -1 }; + + struct sockaddr_alg sock = { + .salg_family = AF_ALG, + .salg_type = "hash", + .salg_name = "crc64-iso3309" + }; + + if ((desc[0] = socket(AF_ALG, SOCK_SEQPACKET, 0)) == -1 ) { + perror("socket"); + return -1; + } + + if( bind(desc[0], (struct sockaddr *) &sock, sizeof(sock)) != 0 ) { + perror("bind"); + return -1; + } + + if( (desc[1] = accept(desc[0], NULL, 0)) == -1 ) + return -1; + + if (argc != 2 || strlen(argv[1]) == 0) { + printf("Please specify filename\n"); + return -1; // empty string + } + + FILE* file; + unsigned char *buffer; + if(posix_memalign((void *)&buffer, SECTOR, BUFFER_SIZE)) { + perror("posix_memalign failed"); + return -1; + } + + file = fopen(argv[1], "rb"); + if(file == NULL) + { + printf("An error occured while opening file: %s\n", argv[1]); + free(buffer); + return -1; + } + + while(!feof(file)) + { + unsigned int count = fread(buffer, sizeof(char), BUFFER_SIZE, file); + if(ferror(file)) + { + printf("An error occurred while accessing the file: %s\n", argv[1]); + fclose(file); + free(buffer); + return -1; + } + + if (send(desc[1], buffer, count, MSG_MORE) != count) { + free(buffer); + return -1; + } + } + + long int crc64 = 0x0000000000000000; + if(read(desc[1], &crc64, 8) != 8) { + free(buffer); + return -1; + } + + printf("0x%llx\n", crc64); + free(buffer); + return 0; +} diff --git a/meta-arago-test/recipes-kernel/mcrc64/mcrc64.bb b/meta-arago-test/recipes-kernel/mcrc64/mcrc64.bb new file mode 100644 index 00000000..b0352585 --- /dev/null +++ b/meta-arago-test/recipes-kernel/mcrc64/mcrc64.bb @@ -0,0 +1,19 @@ +DESCRIPTION = "Application to test MCRC64 driver" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://mcrc64.c;beginline=1;endline=33;md5=070547e79367134fcfdf7fdb5e3ef7e3" + +SRC_URI = "file://mcrc64.c" + +S = "${WORKDIR}/sources" +UNPACKDIR = "${S}" + +do_compile() { + ${CC} ${CFLAGS} ${LDFLAGS} ${UNPACKDIR}/mcrc64.c -o mcrc64 +} + + +do_install() { + install -d ${D}${bindir} + install -m 0755 mcrc64 ${D}${bindir} +}