From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4373CA32A4 for ; Fri, 25 Oct 2019 19:55:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8DC861E87A; Fri, 25 Oct 2019 19:54:20 +0200 (CEST) Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730041.outbound.protection.outlook.com [40.107.73.41]) by dpdk.org (Postfix) with ESMTP id 8A74F1E556 for ; Fri, 25 Oct 2019 19:54:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V0VADqgVrgAR0RVCs7QyU96sRBLDSCtoOaq28B5aPS7GJ2io1Hujw5UF40S4QJb483JVDbex0e0oCVPzPJzbzY/pmVbbt2M/fpQE+fq9Rz2hzaj0qAl7+WisO56F8xBokx7noeymgHSOug61lhqvsWwAG+IZ4FlkM7BBp/FqFcWKHNsWMBx/X5wPP173lwU42wyd12g/5AOXgAChBdBHxpABtVh3T/FKSKkodoe4lHXZ+9XnXq+H8anVfy5XyPGdKntNxnDvDfB/1zgHqU3PQRl5ok0fX7+GVsio9en+h2fTcDUPA6uoXFbN6Snw27VTqGBRC/1rWIpZSLOeRfwwhw== 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-SenderADCheck; bh=Vv0nbO+yzh7mxJEG1YRbghmrMM2oNCrGYQ6bWoNABZI=; b=Ak8KbsQGLwyLolYkHwQoIr5PWyFE1T3c3B5I7HJoYLfCMnCf7pwIKThpbxaMViQ2xE+zBqr0CKuulZe6lvEIJ+AMamYdMFRyIdStzvxWOG/NzYBcnrPwcYhJ/Xm0+FVzR86+J3Psfk1jjxM3f6W+IE2OZakxX8PTLfiAJOHz3EecuW7vrM7BoJlq2M0SMBqbeV1AYas/6CmI3i+OD0RKZSC7AiguT+GUa0E0nhTHrKwnl7HNlQKbmON1tGYxffVcmZrdeIsEJeGrU+gs9qowQMgUmsft5K9FT/kFiXnhc9nqV7amF/AgBL4cd/5YYSMDEtR/DzQQEB+yjJVXhgYmow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=aquantia.com; dmarc=pass action=none header.from=aquantia.com; dkim=pass header.d=aquantia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector2-AQUANTIA1COM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vv0nbO+yzh7mxJEG1YRbghmrMM2oNCrGYQ6bWoNABZI=; b=WfK8rvczk5vknm09BQVmNPgHrMXrTasCnI299/0ufAHrb1YcMv65XUseo1OCpUZD4qwcZ//HngMXjDxI9sql1NeQIlL8F+Ow3DEMnWclhdUj6PhRETD878sgRMY/vAmG8m6JmThV6BD+Uv9cqWzcx0dXpjN4I5eX5qcUGJ+d3No= Received: from CY4PR1101MB2183.namprd11.prod.outlook.com (10.172.76.20) by CY4PR1101MB2311.namprd11.prod.outlook.com (10.174.53.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Fri, 25 Oct 2019 17:54:11 +0000 Received: from CY4PR1101MB2183.namprd11.prod.outlook.com ([fe80::55e:4921:90d1:670a]) by CY4PR1101MB2183.namprd11.prod.outlook.com ([fe80::55e:4921:90d1:670a%12]) with mapi id 15.20.2387.023; Fri, 25 Oct 2019 17:54:11 +0000 From: Pavel Belous To: "dev@dpdk.org" CC: Ferruh Yigit , Akhil Goyal , John McNamara , Declan Doherty , Konstantin Ananyev , Thomas Monjalon , Igor Russkikh , Fenilkumar Patel , Hitesh K Maisheri , Pavel Belous , Pavel Belous Thread-Topic: [RFC v2 7/7] app/testpmd: macsec adding RX/TX SC using rte_security interface Thread-Index: AQHVi101I4a37DFnF0Cldq3eqAchpg== Date: Fri, 25 Oct 2019 17:54:11 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR1PR01CA0020.eurprd01.prod.exchangelabs.com (2603:10a6:102::33) To CY4PR1101MB2183.namprd11.prod.outlook.com (2603:10b6:910:18::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Pavel.Belous@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7991cf32-6c47-464b-b930-08d759745764 x-ms-traffictypediagnostic: CY4PR1101MB2311: x-ld-processed: 83e2e134-991c-4ede-8ced-34d47e38e6b1,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:83; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(39850400004)(366004)(396003)(376002)(136003)(346002)(199004)(189003)(66476007)(66556008)(486006)(66446008)(64756008)(7736002)(476003)(36756003)(86362001)(2616005)(6486002)(446003)(71200400001)(118296001)(6512007)(5640700003)(71190400001)(44832011)(2906002)(6436002)(2351001)(11346002)(305945005)(66946007)(14454004)(5660300002)(508600001)(25786009)(4326008)(50226002)(66066001)(6116002)(2501003)(107886003)(3846002)(256004)(14444005)(54906003)(99286004)(6916009)(26005)(186003)(102836004)(76176011)(52116002)(386003)(6506007)(316002)(8676002)(1730700003)(81156014)(81166006)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1101MB2311; H:CY4PR1101MB2183.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +Y0uww6Hx/c6x9ITdjzZmhXTXRdzP0g16yljE8hCZEtAJLFUb5aQAeRvUO6OdTg/n5uLbYhga65WZg4XAe5vQjMxk6UBVFSaF7NFpAalAoNqv0XHATu/g08o5Lbzsycu/zlgsx1JdlX6H6EYRLmyic6TYK/JuBhsW9ciJJ8wmppFGKJEmk7nPEHyR15dC5WHTDdpM9NLiiWg6e/CZQQHJeteHWVx+I4O3B+K93fP0jRe1/sJuJOXwM9OMnIZdHCXh9raJ3woVkRYa2gXn2Izs5T2JOtTGrJgcFhhyo7/tXE837aO2vFt1BAgxlrK1Huc8XvRQqYehfOduxqt7Wm4GRimle1Qoot8vFsgbzp/ATTSMnl0uqvjt127b4Qe/tNIlUhOCU0Tl7zv1NFkqPLEZOePb0p8difNcocJn+XwQCQJOtQ+GTNZT918zWZ/OOCM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7991cf32-6c47-464b-b930-08d759745764 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 17:54:11.6090 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2AFQkHmIjcycYe5xFr2hEKoV2Q2Ru4aW6neJs15GKf8TxdF8JDgP3f8BwgaLxgebh03yXBE0mPZZJGkU0tzQPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2311 Subject: [dpdk-dev] [RFC v2 7/7] app/testpmd: macsec adding RX/TX SC using rte_security interface X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavel Belous Signed-off-by: Pavel Belous Signed-off-by: Igor Russkikh --- app/test-pmd/cmdline.c | 11 +++++----- app/test-pmd/macsec.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ app/test-pmd/macsec.h | 2 ++ 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 10f48f8..a1f895c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -14304,13 +14304,12 @@ cmd_set_macsec_sc_parsed( int ret =3D -ENOTSUP; int is_tx =3D (strcmp(res->tx_rx, "tx") =3D=3D 0) ? 1 : 0; =20 -#ifdef RTE_LIBRTE_IXGBE_PMD ret =3D is_tx ? - rte_pmd_ixgbe_macsec_config_txsc(res->port_id, - res->mac.addr_bytes) : - rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, - res->mac.addr_bytes, res->pi); -#endif + config_macsec_txsc(res->port_id, + res->mac) : + config_macsec_rxsc(res->port_id, + res->mac, res->pi); + RTE_SET_USED(is_tx); =20 switch (ret) { diff --git a/app/test-pmd/macsec.c b/app/test-pmd/macsec.c index fc7976d..ffba467 100644 --- a/app/test-pmd/macsec.c +++ b/app/test-pmd/macsec.c @@ -80,3 +80,59 @@ int set_macsec_on_off(portid_t port_id, int on, int en, = int rp) return err; } =20 +int config_macsec_txsc(portid_t port_id, struct rte_ether_addr mac) +{ + struct rte_security_session_conf macsec_conf; + struct rte_security_ctx *ctx; + int err =3D 0; + + ctx =3D rte_eth_dev_get_sec_ctx(port_id); + + if (!ctx) { + err =3D -ENOTSUP; + goto done; + } + + macsec_conf.action_type =3D RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL; + macsec_conf.protocol =3D RTE_SECURITY_PROTOCOL_MACSEC; + + macsec_conf.macsec.op =3D RTE_SECURITY_MACSEC_OP_ADD_TXSC; + + rte_memcpy(&macsec_conf.macsec.txsc_options.s_mac, mac.addr_bytes, sizeof= (struct rte_ether_addr)); + macsec_conf.macsec.txsc_options.encrypt =3D macsec_param.encryption_enabl= ed; + macsec_conf.macsec.txsc_options.protect =3D 1; + + err =3D rte_security_session_update(ctx, macsec_param.session, &macsec_co= nf); + +done: + return err; +} + +int config_macsec_rxsc(portid_t port_id, struct rte_ether_addr mac, uint16= _t pi) +{ + struct rte_security_session_conf macsec_conf; + struct rte_security_ctx *ctx; + int err =3D 0; + + ctx =3D rte_eth_dev_get_sec_ctx(port_id); + if (!ctx) { + err =3D -ENOTSUP; + goto done; + } + + macsec_conf.action_type =3D RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL; + macsec_conf.protocol =3D RTE_SECURITY_PROTOCOL_MACSEC; + macsec_conf.macsec.op =3D RTE_SECURITY_MACSEC_OP_ADD_RXSC; + + rte_memcpy(&macsec_conf.macsec.txsc_options.s_mac, mac.addr_bytes, sizeof= (struct rte_ether_addr)); + macsec_conf.macsec.rxsc_options.anti_replay_window =3D 0; + macsec_conf.macsec.rxsc_options.replay_protection =3D macsec_param.replay= _protection_enabled; + macsec_conf.macsec.rxsc_options.auto_rollover_enabled =3D true; + macsec_conf.macsec.rxsc_options.port_ident =3D pi; + + err =3D rte_security_session_update(ctx, macsec_param.session, &macsec_co= nf); + +done: + return err; +} + diff --git a/app/test-pmd/macsec.h b/app/test-pmd/macsec.h index 42a534f..e155937 100644 --- a/app/test-pmd/macsec.h +++ b/app/test-pmd/macsec.h @@ -8,5 +8,7 @@ #include "testpmd.h" =20 int set_macsec_on_off(portid_t port_id, int on, int en, int rp); +int config_macsec_txsc(portid_t port_id, struct rte_ether_addr mac); +int config_macsec_rxsc(portid_t port_id, struct rte_ether_addr mac, uint16= _t pi); =20 #endif --=20 2.7.4