From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70045.outbound.protection.outlook.com [40.107.7.45]) by dpdk.org (Postfix) with ESMTP id F37871B1D6 for ; Thu, 1 Nov 2018 22:21:58 +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=5pQelPLOA1VnToLSUukB2nJ6VnFu/4JFqnCUSVxuins=; b=RtJaIdHXykQvukLGGRvlZsQb4CzKtD+FRmhvsgb8Ccq0j5r4F8mUtxIG44sK80RzUueE7iL96eBljNsY2mpg/MjHcgyr3Z/HpyXpDFfKmGrg4XYKQ1XloaYMVWa6z8+wLaVgR3DuiWVhXmze7zDwtXR2dbZXf9aZoW/8f6hNqGc= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Thu, 1 Nov 2018 21:21:56 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.030; Thu, 1 Nov 2018 21:21:56 +0000 From: Yongseok Koh To: Slava Ovsiienko CC: Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH v3 09/13] net/mlx5: e-switch VXLAN netlink routines update Thread-Index: AQHUcd0kZpgSa4KZrEGVOwbya5o+JKU7bhMA Date: Thu, 1 Nov 2018 21:21:56 +0000 Message-ID: <20181101212101.GJ6118@mtidpdk.mti.labs.mlnx> References: <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-10-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541074741-41368-10-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR02CA0065.namprd02.prod.outlook.com (2603:10b6:a03:54::42) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3980; 6:IO+n28uXIx78cPsoXmSqckf+tSzMqqq/RLDOC+FubIWSgPji5Or/+BgcuXesfE65y2XiOvJ18t80HmqpR0gS8Jg65RGp6y41kHzzJnwrEs703Eg+QPtu/c6P6Ccv8+gwkXFMloSexNyU8X3IqwBimRpQdKDQCiWGONKH8JIKM4f+uQ/esjpdbauqgrrwBww3IJpaz8RDcojRZJr/uuw2jbhJUh97mryan1hhCnYI4CzfbgvnXTrsICdTZF2+qRxITj6kNcN26W3GyKh8c3Z+0sreE8JNNbQoBL9G/7zj8zRe/dHt877E2neFOdN0zPz98hKv8ptqWJDP67rahyOoTTwIpE4M0kP7y1+9leteqQZKi9r16prxolwEfGS0Hi17+m/9oRqaSRxVHkgxrrg14vyc8heUOAUhrIHEdJX1kMKpZIe3sYgMGQqClLmcGRQHnBMuAUCS+w+rJ2v56dJT4A==; 5:8NM8x21FFdK5JEQ4lk3e2YRlfYS4oIkAg4mDpqgb8qCxbMd65xxadvT5YjXfhggPDIjt8yQN+qH43bufG02QFecNvGd2RW2UKlR6L0eUesuSaXEU3fsqLT0F2pxYNBvRbK/RDoGJ3hqwAjDsKbqi8pfBetkUkevEuKwH7SAEx/o=; 7:AlmdXF17UFsNechrE1txNt5+UrarvMrr4NedJHNAH0B8wgTXuKv2NXlCM6iTfy+dqlOu57u+O3Hgq9gauHFdlzoqwZb5rkvogVrlEUB8+0XKQUi5/aMJ9sxcJfzmjuPxfFGcuAxtFioB39hAcZ4Adg== x-ms-office365-filtering-correlation-id: d92ae2e9-4480-43b4-4d16-08d640400d55 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3980; x-ms-traffictypediagnostic: DB3PR0502MB3980: 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)(93006095)(93001095)(10201501046)(3002001)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3980; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3980; x-forefront-prvs: 0843C17679 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(39860400002)(376002)(396003)(346002)(199004)(189003)(69234005)(9686003)(6512007)(81156014)(8936002)(8676002)(476003)(97736004)(81166006)(54906003)(15650500001)(2906002)(316002)(68736007)(478600001)(52116002)(6436002)(71190400001)(71200400001)(229853002)(6486002)(99286004)(102836004)(486006)(1076002)(5660300001)(6246003)(26005)(446003)(4326008)(6862004)(6506007)(386003)(2900100001)(106356001)(105586002)(33896004)(186003)(256004)(7736002)(305945005)(25786009)(14444005)(6116002)(53936002)(86362001)(6636002)(33656002)(3846002)(66066001)(14454004)(76176011)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3980; H:DB3PR0502MB3980.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: F23An1gvBDtQiIvcqUHhaDh+siXaj1HAaCTzifGbt/IlH5vG0f5xBKbIwmnCEA5FVUYmB0DfXhZINPCMwMRk5vM3YG4um1poukPUQegBTKLT5qXkSZeL19vVoexmFtWR+xRhO3LWLoGcUGI6UQE67WnHYT9/0yDrWM2GhCb5Dh//K8+MgUtq+6k4inGEAIA8Oei7ZONEqgwOrc+cJY8hoPR55jtCn/0motUcasJ4i4AIbIf0+INh2z1DovaxOazGr+FaRgklsApq+HarhDsUaDUPaUuoue/1evdunWcaduJPCCUeJLc6hZC6ieUBSX7lAJuVZHfxu35U9ysLhyKpTzDNdhqqAsC5P/0MXaupudE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <943652D1CEA08A4DA750E1C39573E4AD@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d92ae2e9-4480-43b4-4d16-08d640400d55 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2018 21:21:56.9056 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3980 Subject: Re: [dpdk-dev] [PATCH v3 09/13] net/mlx5: e-switch VXLAN netlink routines update 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: Thu, 01 Nov 2018 21:21:59 -0000 On Thu, Nov 01, 2018 at 05:19:31AM -0700, Slava Ovsiienko wrote: > 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. >=20 > Suggested-by: Adrien Mazarguil > Signed-off-by: Viacheslav Ovsiienko > --- I have acked this patch in v2. If this patch is changed since v2, you can d= rop my acked-by tag but if there's no change, please preserve the tag. Just FYI= :-) Acked-by: Yongseok Koh Thanks > drivers/net/mlx5/mlx5_flow_tcf.c | 83 +++++++++++++++++++++++++++++-----= ------ > 1 file changed, 61 insertions(+), 22 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index c404a63..67a6ff3 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -3678,37 +3678,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 bef= ore > * 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 len= gth. > + * @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 > /** > @@ -3739,7 +3778,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, > @@ -3778,7 +3817,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 > /** > @@ -4311,7 +4350,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, > @@ -4327,7 +4366,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 >=20