From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6F7DC43381 for ; Tue, 26 Feb 2019 12:49:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 763DF217F9 for ; Tue, 26 Feb 2019 12:49:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HfYLRVj5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbfBZMtO (ORCPT ); Tue, 26 Feb 2019 07:49:14 -0500 Received: from mail-eopbgr10068.outbound.protection.outlook.com ([40.107.1.68]:40359 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726346AbfBZMtO (ORCPT ); Tue, 26 Feb 2019 07:49:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IvlfoPYBBAnbK/Cn/g6q2FdvahnRfIurg1BUFdvpcdM=; b=HfYLRVj5ZesQdlJ8augK6XRBys0NMW7bf3C620CDB/63moLJJBVuV3QKzSCQZtqWY/pgnaGWWYJDKzqwNk8tpLPQB01qQN5nkBXNhHyH7VgxurIK6g3spX1OMn7iDIu/oiaBh4ijDrcO5sA5NUAMHMcndCmZzKlh85H2P1qdLwQ= Received: from DB7PR04MB4252.eurprd04.prod.outlook.com (52.135.131.26) by DB7PR04MB5577.eurprd04.prod.outlook.com (20.178.106.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Tue, 26 Feb 2019 12:49:05 +0000 Received: from DB7PR04MB4252.eurprd04.prod.outlook.com ([fe80::9ca:d78:c154:25b5]) by DB7PR04MB4252.eurprd04.prod.outlook.com ([fe80::9ca:d78:c154:25b5%4]) with mapi id 15.20.1643.019; Tue, 26 Feb 2019 12:49:05 +0000 From: Vakul Garg To: Boris Pismenny , "aviadye@mellanox.com" , "davejwatson@fb.com" , "john.fastabend@gmail.com" , "daniel@iogearbox.net" , "netdev@vger.kernel.org" CC: "eranbe@mellanox.com" Subject: RE: [PATCH net 2/4] tls: Fix write space handling Thread-Topic: [PATCH net 2/4] tls: Fix write space handling Thread-Index: AQHUzcydwTjc6rHQZE6qevJYX1L3HaXyBvsw Date: Tue, 26 Feb 2019 12:49:05 +0000 Message-ID: References: <20190226121235.20784-1-borisp@mellanox.com> <20190226121235.20784-3-borisp@mellanox.com> In-Reply-To: <20190226121235.20784-3-borisp@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=vakul.garg@nxp.com; x-originating-ip: [160.202.37.40] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8a2add7d-c05a-4f70-7143-08d69be8cad2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB7PR04MB5577; x-ms-traffictypediagnostic: DB7PR04MB5577: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1;D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PObYm7ii57?= =?us-ascii?Q?50Io2R8Pez5caISk5VJfCJeQj+pl6FHxrHSqh1Nr/h9WNo8KV9T2PpBRj+FE?= =?us-ascii?Q?8eTIBdxaa+vNzJaG60yGblLZimLE+lzVWXfwmlTQqV+G0tX6xyPwZTkk3MaT?= =?us-ascii?Q?lcdpNX9FaGeFJVtEI3FDnidNonFNfX4C6CMsJtQd5R8VuQAlutuNNvk15/mf?= =?us-ascii?Q?9FDNMAe4PtjV6Z8OYHq/eplkqI13pDxK2vAv/TMPdcvNxFVHS/VwyK65IwtX?= =?us-ascii?Q?ePxBLTZjhBmkvbUHmloFpI/U5Pvv3fTa0tFX8RQ/HrKkUHPNpKYcnqnFddT1?= =?us-ascii?Q?pi+2d+FSyGxScK8WcW9032wg/Lt4ndo/2sGDD3Eyd71Ba0gXOBDr7T1QM7MX?= =?us-ascii?Q?2UDKeD/P7eUMPjoxnDyfTjJP+IFkAw08ZIqJOhfor3Ohl5LrVLVtXHLGdw4e?= =?us-ascii?Q?8DyW1xgtSC6mORG4WiO/qwc23xtChkSY/W7IY6DEr2M?= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(346002)(366004)(396003)(39860400002)(136003)(199004)(189003)(13464003)(11346002)(6436002)(446003)(55016002)(68736007)(4326008)(476003)(25786009)(9686003)(102836004)(53546011)(7696005)(6246003)(186003)(53936002)(6506007)(99286004)(106356001)(105586002)(52536013)(86362001)(5660300002)(2501003)(2201001)(2906002)(14454004)(71200400001)(110136005)(14444005)(66066001)(8936002)(256004)(8676002)(316002)(478600001)(76176011)(229853002)(26005)(44832011)(486006)(74316002)(6116002)(97736004)(71190400001)(7736002)(305945005)(3846002)(81166006)(81156014)(33656002)(309714004);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB5577;H:DB7PR04MB4252.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XJRtdqLu+7RipmfaySe9qW5GwZuilqQuTO+VdQH/YBM1ogCEm5nZWqgh2xWh4g8KrpHXBPaNl72Vg/DurNgBVS3o4O79MCXvwevTO+di5eqCRKmF2oPf9jnLNko8SzENPDvwt65df++fKOMJbRfQnf4kIhJkdmrKVYqAW2jcAv23xmNU4c8LvievBu+slD93td1v8sxVgq0D6XCdxexkoOfrvE4ht8XFQkgwao/Nk1PNbKFfqQvK7kem01O9tn0W02FkXae3oZRxnidaDR+A7AL17hoRiTr19QH2SjZI4zl0M6ml4QZBYq/ja3T5ccUJu2oYwRvfATt+ktiSbs7Fzj7ib5o9QMDZX8RktJWPvg8wkiGo0vrQ0URTVvfFvADFCvrRFfT3fcA3xhZXlhVgiUY9iIL4pW5oiNhepNo454c= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a2add7d-c05a-4f70-7143-08d69be8cad2 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 12:49:05.5870 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5577 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > -----Original Message----- > From: Boris Pismenny > Sent: Tuesday, February 26, 2019 5:43 PM > To: aviadye@mellanox.com; davejwatson@fb.com; > john.fastabend@gmail.com; daniel@iogearbox.net; Vakul Garg > ; netdev@vger.kernel.org > Cc: eranbe@mellanox.com; borisp@mellanox.com > Subject: [PATCH net 2/4] tls: Fix write space handling >=20 > TLS device cannot use the sw context. This patch returns the original > tls device write space handler and moves the sw/device specific portions > to the relevant files. >=20 > Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of record= s > for performance") > Signed-off-by: Boris Pismenny > Reviewed-by: Eran Ben Elisha > --- > include/net/tls.h | 3 +++ > net/tls/tls_device.c | 16 ++++++++++++++++ > net/tls/tls_main.c | 17 +++++++++-------- > net/tls/tls_sw.c | 15 +++++++++++++++ > 4 files changed, 43 insertions(+), 8 deletions(-) >=20 > diff --git a/include/net/tls.h b/include/net/tls.h > index a528a082da73..9d7c53737b13 100644 > --- a/include/net/tls.h > +++ b/include/net/tls.h > @@ -519,6 +519,9 @@ static inline bool tls_sw_has_ctx_tx(const struct soc= k > *sk) > return !!tls_sw_ctx_tx(ctx); > } >=20 > +int tls_sw_write_space(struct sock *sk, struct tls_context *ctx); > +int tls_device_write_space(struct sock *sk, struct tls_context *ctx); > + > static inline struct tls_offload_context_rx * > tls_offload_ctx_rx(const struct tls_context *tls_ctx) > { > diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c > index 3e5e8e021a87..e8988b3f3236 100644 > --- a/net/tls/tls_device.c > +++ b/net/tls/tls_device.c > @@ -546,6 +546,22 @@ static int tls_device_push_pending_record(struct > sock *sk, int flags) > return tls_push_data(sk, &msg_iter, 0, flags, > TLS_RECORD_TYPE_DATA); > } >=20 > +int tls_device_write_space(struct sock *sk, struct tls_context *ctx) > +{ > + int rc =3D 0; > + > + if (!sk->sk_write_pending && tls_is_partially_sent_record(ctx)) { > + gfp_t sk_allocation =3D sk->sk_allocation; > + > + sk->sk_allocation =3D GFP_ATOMIC; > + rc =3D tls_push_partial_record(sk, ctx, > + MSG_DONTWAIT | > MSG_NOSIGNAL); > + sk->sk_allocation =3D sk_allocation; > + } > + > + return rc; > +} > + > void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn) > { > struct tls_context *tls_ctx =3D tls_get_ctx(sk); > diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c > index 7e05af75536d..11c1980a75cb 100644 > --- a/net/tls/tls_main.c > +++ b/net/tls/tls_main.c > @@ -212,7 +212,7 @@ int tls_push_partial_record(struct sock *sk, struct > tls_context *ctx, > static void tls_write_space(struct sock *sk) > { > struct tls_context *ctx =3D tls_get_ctx(sk); > - struct tls_sw_context_tx *tx_ctx =3D tls_sw_ctx_tx(ctx); > + int rc; >=20 > /* If in_tcp_sendpages call lower protocol write space handler > * to ensure we wake up any waiting operations there. For example > @@ -223,14 +223,15 @@ static void tls_write_space(struct sock *sk) > return; > } >=20 > - /* Schedule the transmission if tx list is ready */ > - if (is_tx_ready(tx_ctx) && !sk->sk_write_pending) { > - /* Schedule the transmission */ > - if (!test_and_set_bit(BIT_TX_SCHEDULED, &tx_ctx- > >tx_bitmask)) > - schedule_delayed_work(&tx_ctx->tx_work.work, 0); > - } > +#ifdef CONFIG_TLS_DEVICE > + if (ctx->tx_conf =3D=3D TLS_HW) > + rc =3D tls_device_write_space(sk, ctx); > + else > +#endif > + rc =3D tls_sw_write_space(sk, ctx); >=20 > - ctx->sk_write_space(sk); > + if (!rc) Why do we need to check 'rc'? If it is required, then ' ctx->sk_write_space(sk)' can move to tls_device_w= rite_space() since tls_sw_write_space() always returns '0'. > + ctx->sk_write_space(sk); > } >=20 > static void tls_ctx_free(struct tls_context *ctx) > diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c > index 1cc830582fa8..4afa67b00aaf 100644 > --- a/net/tls/tls_sw.c > +++ b/net/tls/tls_sw.c > @@ -2126,6 +2126,21 @@ static void tx_work_handler(struct work_struct > *work) > release_sock(sk); > } >=20 > +int tls_sw_write_space(struct sock *sk, struct tls_context *ctx) > +{ > + struct tls_sw_context_tx *tx_ctx =3D tls_sw_ctx_tx(ctx); > + > + /* Schedule the transmission if tx list is ready */ > + if (is_tx_ready(tx_ctx) && !sk->sk_write_pending) { > + /* Schedule the transmission */ > + if (!test_and_set_bit(BIT_TX_SCHEDULED, > + &tx_ctx->tx_bitmask)) > + schedule_delayed_work(&tx_ctx->tx_work.work, 0); > + } > + > + return 0; > +} > + > int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) > { > struct tls_context *tls_ctx =3D tls_get_ctx(sk); > -- > 2.12.2