From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50065.outbound.protection.outlook.com [40.107.5.65]) by dpdk.org (Postfix) with ESMTP id AC99F7CDA for ; Fri, 2 Nov 2018 18:53:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O/ZQPUj7wYUJ/AbndNGJ3BhlegIAnC/PRyD5pxcsTfs=; b=M4yLwrGznrCPpyOR0iYJkUUa7Jd/JcwP2p66dTAk8acETs67gFVmcxDD6lG4/TtsKkg4/Lc+v8aIvrHpj2xypSReBqHX1g88ObgZNpSNeMtmZMnnEFsp5JbdbK7wdJaiTiOJeM+pDoER7riZBo7nru84IAW2aD9fJHmH4j/K6PY= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3203.eurprd05.prod.outlook.com (10.171.186.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.20; Fri, 2 Nov 2018 17:53:21 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e%2]) with mapi id 15.20.1294.024; Fri, 2 Nov 2018 17:53:21 +0000 From: Slava Ovsiienko To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , Slava Ovsiienko Thread-Topic: [PATCH v4 09/13] net/mlx5: update E-Switch VXLAN netlink routines Thread-Index: AQHUctTx7WvrB5+2iUa6VJEafPt6mQ== Date: Fri, 2 Nov 2018 17:53:21 +0000 Message-ID: <1541181152-15788-10-git-send-email-viacheslavo@mellanox.com> References: <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541181152-15788-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541181152-15788-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0112.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::28) To AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:4::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3203; 6:86loyrWJYHHjG/SjrSzhbQmvDaz9yjgNQ7aezgSP/jucf+hGnqnAl3zJGL+EAEAL3gsrrWKNTbgjBuZsocsYJrGk0XRhJffWAL6PM/ztmctwzX2ET2fpN6bBNhHwTEW0NqSpmIdWd1xW6M6vxLn8zeN193w36dJ5fL9wT0mSpu33p7UdCr35Mtzqmimpell0m0nItAjpwd/sM8iwIq3mBji1GSppDJZhq1YIyd07i7K8BveJWN5iQFWox6nX4UB9n1stHMMLEot60SDG99liv+2SJA4cIuyjJJvpa0v/9aFyARW0gv/EsBtSZa2aNFODFY47UsiMyxg4TNokaW1QPsLuYMl2uiuRnmtwOQf7a5vvzWeDAj3Su/DFvbC0j41bgoJ8uCPFvlIxQkGF9366OqT8nVb50kYrN0CRVa7vCT+mA7M7vrGdhgtMglFZaX28/IVX0UDatyxpHGdSKeZNEw==; 5:1HqDmgG+74pA0MrXKhwF2DsiB2cKn3QU2Ls2LdpegJtYowd2giX9SVJTDqvDymkgd91pOdw295jjYmFLqfDKwemthgqgbm5q6JEkDd4Fwl05BjhdMwG5s53Z75Zzw5G/MuydMGFGbyheKTmraAYGdbqM7plFd1LqKt3oFzc6AvE=; 7:05F9DvzDE7SisRPABchIYV0E4D5T/L2lZAOVd4XT1Jo6aI2iTjxtvLXFgL3Q2bQKB099peo9of2wC2B1CTg15Ajcp14nSAktdE/lM99jzo/kZSUO/kBwmhZkiFhe81JTNGVaiHi+MorFZDMalro+Wg== x-ms-office365-filtering-correlation-id: 3dee0791-a12c-47e3-2697-08d640ec1427 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3203; x-ms-traffictypediagnostic: AM4PR05MB3203: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3203; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3203; x-forefront-prvs: 08444C7C87 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(39860400002)(136003)(366004)(396003)(199004)(189003)(6636002)(11346002)(478600001)(446003)(2616005)(476003)(486006)(256004)(14444005)(386003)(6506007)(102836004)(26005)(99286004)(575784001)(86362001)(3846002)(6116002)(14454004)(6512007)(316002)(25786009)(53936002)(97736004)(71190400001)(37006003)(4326008)(6862004)(71200400001)(186003)(107886003)(6436002)(54906003)(6486002)(5660300001)(2906002)(106356001)(36756003)(66066001)(105586002)(15650500001)(2900100001)(8936002)(52116002)(76176011)(81166006)(305945005)(81156014)(8676002)(68736007)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3203; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: mWQbmWftavERJryixS7EDqfzfh6p+FsQJmZoLt6s2CS+I24oXyFSKJfkFFzLlCvtoifJzT+MektAhCHSEZrYLZq70hdbiBLXuDFt8WNAqjaeN7129zjnPTSpGJDG0UZtI21zfOG6pSB86U1r0kN1H584lx+ZPw3irqH5DPlDjTQecY552hl3Jg6JiI9EzgNYhkZSo5MKVx3dM8aAYHyZm9NGcHLICYUpeGkYBoUJVdFLItdu2sZrTl0KvF8ror9Ofj8RTRHki4K+JIe/7vfZD9vBG/F54oF1o3g69daEyMaNhLembty82tDi5d9phHDbVBzMU5mRkAqThlygUZoodszqvGHWC+ZBTGa+QEdVJnA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3dee0791-a12c-47e3-2697-08d640ec1427 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2018 17:53:21.6365 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3203 Subject: [dpdk-dev] [PATCH v4 09/13] net/mlx5: update E-Switch VXLAN netlink routines 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: , X-List-Received-Date: Fri, 02 Nov 2018 17:53:23 -0000 This part of patchset updates Netlink exchange routine. Message sequence numbers became not random ones, the multipart reply messages are supported, not propagating errors to the following socket calls, Netlink replies buffer size is increased to MNL_SOCKET_BUFFER_SIZE and now is preallocated at context creation time instead of stack usage. This update is needed to support Netlink query operations. Suggested-by: Adrien Mazarguil Signed-off-by: Viacheslav Ovsiienko Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow_tcf.c | 83 +++++++++++++++++++++++++++++-------= ---- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_= tcf.c index b7a0c72..b1d2d6b 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -3723,37 +3723,76 @@ struct pedit_parser { /** * Send Netlink message with acknowledgment. * - * @param ctx + * @param tcf * Flow context to use. * @param nlh * Message to send. This function always raises the NLM_F_ACK flag befor= e * sending. + * @param[in] msglen + * Message length. Message buffer may contain multiple commands and + * nlmsg_len field not always corresponds to actual message length. + * If 0 specified the nlmsg_len field in header is used as message lengt= h. + * @param[in] cb + * Callback handler for received message. + * @param[in] arg + * Context pointer for callback handler. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_tcf_nl_ack(struct mlx5_flow_tcf_context *ctx, struct nlmsghdr *nlh) +flow_tcf_nl_ack(struct mlx5_flow_tcf_context *tcf, + struct nlmsghdr *nlh, + uint32_t msglen, + mnl_cb_t cb, void *arg) { - alignas(struct nlmsghdr) - uint8_t ans[mnl_nlmsg_size(sizeof(struct nlmsgerr)) + - nlh->nlmsg_len - sizeof(*nlh)]; - uint32_t seq =3D ctx->seq++; - struct mnl_socket *nl =3D ctx->nl; - int ret; - - nlh->nlmsg_flags |=3D NLM_F_ACK; + unsigned int portid =3D mnl_socket_get_portid(tcf->nl); + uint32_t seq =3D tcf->seq++; + int err, ret; + + assert(tcf->nl); + assert(tcf->buf); + if (!seq) + /* seq 0 is reserved for kernel event-driven notifications. */ + seq =3D tcf->seq++; nlh->nlmsg_seq =3D seq; - ret =3D mnl_socket_sendto(nl, nlh, nlh->nlmsg_len); - if (ret !=3D -1) - ret =3D mnl_socket_recvfrom(nl, ans, sizeof(ans)); - if (ret !=3D -1) - ret =3D mnl_cb_run - (ans, ret, seq, mnl_socket_get_portid(nl), NULL, NULL); + if (!msglen) { + msglen =3D nlh->nlmsg_len; + nlh->nlmsg_flags |=3D NLM_F_ACK; + } + ret =3D mnl_socket_sendto(tcf->nl, nlh, msglen); + err =3D (ret <=3D 0) ? errno : 0; + nlh =3D (struct nlmsghdr *)(tcf->buf); + /* + * The following loop postpones non-fatal errors until multipart + * messages are complete. + */ if (ret > 0) + while (true) { + ret =3D mnl_socket_recvfrom(tcf->nl, tcf->buf, + tcf->buf_size); + if (ret < 0) { + err =3D errno; + if (err !=3D ENOSPC) + break; + } + if (!err) { + ret =3D mnl_cb_run(nlh, ret, seq, portid, + cb, arg); + if (ret < 0) { + err =3D errno; + break; + } + } + /* Will receive till end of multipart message */ + if (!(nlh->nlmsg_flags & NLM_F_MULTI) || + nlh->nlmsg_type =3D=3D NLMSG_DONE) + break; + } + if (!err) return 0; - rte_errno =3D errno; - return -rte_errno; + rte_errno =3D err; + return -err; } =20 /** @@ -3784,7 +3823,7 @@ struct pedit_parser { nlh =3D dev_flow->tcf.nlh; nlh->nlmsg_type =3D RTM_NEWTFILTER; nlh->nlmsg_flags =3D NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL; - if (!flow_tcf_nl_ack(ctx, nlh)) + if (!flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL)) return 0; return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -3823,7 +3862,7 @@ struct pedit_parser { nlh =3D dev_flow->tcf.nlh; nlh->nlmsg_type =3D RTM_DELTFILTER; nlh->nlmsg_flags =3D NLM_F_REQUEST; - flow_tcf_nl_ack(ctx, nlh); + flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL); } =20 /** @@ -4356,7 +4395,7 @@ struct pedit_parser { tcm->tcm_handle =3D TC_H_MAKE(TC_H_INGRESS, 0); tcm->tcm_parent =3D TC_H_INGRESS; /* Ignore errors when qdisc is already absent. */ - if (flow_tcf_nl_ack(ctx, nlh) && + if (flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL) && rte_errno !=3D EINVAL && rte_errno !=3D ENOENT) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -4372,7 +4411,7 @@ struct pedit_parser { tcm->tcm_handle =3D TC_H_MAKE(TC_H_INGRESS, 0); tcm->tcm_parent =3D TC_H_INGRESS; mnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, "ingress"); - if (flow_tcf_nl_ack(ctx, nlh)) + if (flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL)) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "netlink: failed to create ingress" --=20 1.8.3.1