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 E3990A00C4; Wed, 28 Sep 2022 20:24:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D0FA427F1; Wed, 28 Sep 2022 20:24:27 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 020F342686 for ; Wed, 28 Sep 2022 20:24:25 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28SFPZTx029114; Wed, 28 Sep 2022 11:24:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=QhAaFB63JT9SEkdtsfyXGhWXHN1k7aqzcWf+j5KgS2U=; b=Harj3+HScknu99bzW1oLjfLeKGIM/avRZE37F1ZA0ZWq2ot+5W1QRb8FlqOBVincRr+S pdpO3CrZThaMP3/XzM7GE+sBbxlWKweGi/AuVu6nsgAymDPuTWRFDF/YS9YS1UUVlYr3 gD6X2UDuL6wt9Ml4TDxVZxgNW7DwBFKNfC0l40KXcAcKYi8C9RZ7x+VVabIb8Zc/udBq qKHIrRejzZck7CkPlJCQIUoR4vF+bOjSGtCT33O1kCmHX4bf8H7OsM6I26BgT/WZYD4K gpQIFfE+gu53I+lz0ogdtlx+4OCwzpvpu01mzzQHKhgMC5ruWy6DBUmzDcZrUMVg2joU WA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jvrvjgu45-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 28 Sep 2022 11:24:24 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 28 Sep 2022 11:24:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 28 Sep 2022 11:24:22 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 089BD3F7101; Wed, 28 Sep 2022 11:24:17 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v3 1/3] net: add MACsec header Date: Wed, 28 Sep 2022 23:54:08 +0530 Message-ID: <20220928182410.309053-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928182410.309053-1-gakhil@marvell.com> References: <20220928122253.23108-1-gakhil@marvell.com> <20220928182410.309053-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: UNxMgQhEvpVIlmv__BHVNMgKSzSXM-Zf X-Proofpoint-ORIG-GUID: UNxMgQhEvpVIlmv__BHVNMgKSzSXM-Zf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-28_07,2022-09-28_01,2022-06-22_01 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 Added MACsec protocol header to be used for supporting MACsec protocol offload in hardware or directly in the application. Signed-off-by: Akhil Goyal Acked-by: Olivier Matz Acked-by: Ori Kam --- doc/api/doxy-api-index.md | 3 +- lib/net/meson.build | 1 + lib/net/rte_macsec.h | 61 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lib/net/rte_macsec.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index 186a258be4..99e49340d3 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -126,7 +126,8 @@ The public API headers are grouped by topics: [Geneve](@ref rte_geneve.h), [eCPRI](@ref rte_ecpri.h), [L2TPv2](@ref rte_l2tpv2.h), - [PPP](@ref rte_ppp.h) + [PPP](@ref rte_ppp.h), + [MACsec](@ref rte_macsec.h) - **QoS**: [metering](@ref rte_meter.h), diff --git a/lib/net/meson.build b/lib/net/meson.build index e899846578..3e63abaca8 100644 --- a/lib/net/meson.build +++ b/lib/net/meson.build @@ -21,6 +21,7 @@ headers = files( 'rte_geneve.h', 'rte_l2tpv2.h', 'rte_ppp.h', + 'rte_macsec.h', ) sources = files( diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h new file mode 100644 index 0000000000..c92b5fef48 --- /dev/null +++ b/lib/net/rte_macsec.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2022 Marvell. + */ + +#ifndef _RTE_MACSEC_H_ +#define _RTE_MACSEC_H_ + +/** + * @file + * + * MACsec-related defines + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_MACSEC_TCI_VER_MASK 0x80 /**< Version mask for MACsec. Should be 0. */ +#define RTE_MACSEC_TCI_ES 0x40 /**< Mask for End station (ES) bit - SCI is not valid. */ +#define RTE_MACSEC_TCI_SC 0x20 /**< Mask for SCI present bit. */ +#define RTE_MACSEC_TCI_SCB 0x10 /**< Mask for EPON single copy broadcast bit. */ +#define RTE_MACSEC_TCI_E 0x08 /**< Mask for encrypted user data bit. */ +#define RTE_MACSEC_TCI_C 0x04 /**< Mask for changed user data bit (because of encryption). */ +#define RTE_MACSEC_AN_MASK 0x03 /**< Association number mask in tci_an. */ + +/** + * MACsec Header(SecTAG) + */ +struct rte_macsec_hdr { + /** + * Tag control information and Association number of secure channel. + * Various bits of TCI and AN are masked using RTE_MACSEC_TCI_* and RTE_MACSEC_AN_MASK. + */ + uint8_t tci_an; +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t short_length:6; /**< Short Length. */ + uint8_t unused:2; +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t unused:2; + uint8_t short_length:6; /**< Short Length. */ +#endif + rte_be32_t packet_number; /**< Packet number to support replay protection. */ +} __rte_packed; + +/** SCI length in MACsec header if present. */ +#define RTE_MACSEC_SCI_LEN 8 + +/** + * MACsec SCI header(8 bytes) after the MACsec header which is present if SC bit is set in tci_an. + */ +struct rte_macsec_sci_hdr { + uint8_t sci[RTE_MACSEC_SCI_LEN]; /**< Optional secure channel id. */ +} __rte_packed; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MACSEC_H_ */ -- 2.25.1