From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30056.outbound.protection.outlook.com [40.107.3.56]) by dpdk.org (Postfix) with ESMTP id 258AA2BF4 for ; Mon, 15 Oct 2018 16:14:14 +0200 (CEST) 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=FAkxRyI0HMX78Sue0juSB5dfAlejJiAqM1irBTVdyJg=; b=IMe8C0M1qDlCqhcfytZ3t6kWn4sCByureZXyxsZdcmB0MYnkB2WyUNJK2Aqe3Qo7EqQS//9XkilDu3NJi14JMCAlAz9SjJS/4j6cz97pJbEsYwFSlpHlJE9d4sQYauUczRGWoxWNWjHOZoEcByMYVOJ7iRFU2msNnyrtWOpPmkk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR05MB3277.eurprd05.prod.outlook.com (2603:10a6:802:1c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.24; Mon, 15 Oct 2018 14:14:12 +0000 From: Viacheslav Ovsiienko To: shahafs@mellanox.com, yskoh@mellanox.com Cc: dev@dpdk.org, Viacheslav Ovsiienko Date: Mon, 15 Oct 2018 14:13:32 +0000 Message-Id: <1539612815-47199-5-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> References: <1538461807-37507-1-git-send-email-viacheslavo@mellanox.com> <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: CWLP265CA0084.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:50::24) To VI1PR05MB3277.eurprd05.prod.outlook.com (2603:10a6:802:1c::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55839192-9d6c-4c12-8d75-08d632a87ba1 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:VI1PR05MB3277; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3277; 3:jLxHAYSYvpkan6As9ToBswWxCjIkvWwRxS2Q3eT9DpGNiPDathe768+kXgdW0ShvqZ3lyIGkv4KGBfSdy3dgV4wOKlpzKsZkVXlZ3imzTpLR2H7Pa3HJn7DpydUIkP1Z6q1nuVkmE8R/DUNdw8SHhhxK9cJT9CRAjFTAa1mUMYjy9A+PUkcNgTZWIGnyvP1+oSmvGlnt21YtekqnHvyFuKi2uLgRKe5U0ZNyMyW7vAQVWhcuWgWPsgnELIwLWfv3; 25:25YruTMJrVGzTwRukjOFiN0zS3IJkAVK2FoAlMcjMVxurG7Hf4gM+Y5KlPxutlKsuS12thX4d3Zul1Jqk7ehidQFyY/bG9xZc535Dhta3IVKzo2Vznmi/DUEB+0wmFIg73lEnh2a8qubaIjH6YUa/j/Iu4SNR3HsrlzJxVz/E+baGhuriOjf4Z+U1pdnxxwPTw2egDMYlbNMV4JFEm8tjh59DJ/zFfCqfDH9hKjj7cZb2ypKoutA+cHHOZMtMJBH/8we8uPIjZWfaa6P+zr9LkizDRV4oCpP1Rnc8BAUXAkAAhpqeahFCcHc8eOD3hDSrYsKBN/5A2PqTa75acJpAw==; 31:7hEZ9ipYKdA3CGj/ncHWlJF6jNJJIsQUC6y3gVCMr4R/V1MfxZkzid4VrPpT6D1Utv6NFy3R05MEHy/GfrA8fXpTKsAdMkceu7bR1+A477xodJ6qZTfxnYC2LGNwIo4vbyeA4XMYNE63GEExpoaGEbs0qyMqJXU+Jr3K6MW/wbUmHa9mq88ODDj4m0u2+sXw11ST+U6JWF7dtZBp6yu/E4JhgwD/4+EkfyEmG6lb8D4= X-MS-TrafficTypeDiagnostic: VI1PR05MB3277: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3277; 20:2XFmlMWJsydxDQR5v0qptBR3EtspmcYJkPtRP+r5JXWCWssOxDsZTPc3FluSHBnKTbFo1tzpBFkG/9FPw8PUI0Ihrghz6ZYLDhp4Wyf03wYvNNOtQfAohPmxV6xawIXywzxXBvzbleRVce/lIlE9KzvT1P/reMdu9l57P436ALULLV6Pdy4mrn0lfPlD8nCmT/hbgMP/Okg1S7dOyFWb4s+gspPBObw/BanqPeStOlRSvsM+uCq14L+eJL9KnPjE+wxYswh6ettzDmOnbdNynO85un8IwnEB9TZrNt9+hedVvavAXbaJEwCAx1wMQEOxlFLqgMVwnuq8DomvuZOiPaFfGZalQIPLh8T8gF4G+jbsQ08AamW5xDFIl3h3t+qPpp3k62oM2Ul2Yne+DR2xjC4xvYLk0Z9xfF/1rkvz2CO+z1B8KaKkxAidUhHtdfrWARlGtXKfY7W11IDmB7WiH6DzocVYu6qSLSKDeTQMoGVpN1o7HZounxkx3pU7AulE; 4:6Zorl+t9a9wayhpU0Up5XACvT60LoTpps3z4Od+0JLXTkAfKzqPTu4YP8VjnjnX4QSTqDsqLmGBgWqK0CGM3vOsGGHlaTWb0V09ZxrnL6aDeURMLLlHsnezL4J06kMk3Jv2DJWRm+D1YuPt5J31k+4IcCb2v4LtUcuRkR2U/BwAjA4K0OIQb1xVwAJcac3yEkc3sI/nOobLktuJyhiUIoTTBPN4bYUtudqSa+j3iPUQ9KDFM8c5SAtbNoCYsDUULExHB9D2oyX4BDgQPnD4POA== 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)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:VI1PR05MB3277; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB3277; X-Forefront-PRVS: 0826B2F01B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(376002)(346002)(366004)(396003)(199004)(189003)(107886003)(16526019)(66066001)(7736002)(8676002)(47776003)(106356001)(51416003)(7696005)(52116002)(15650500001)(25786009)(68736007)(105586002)(186003)(16586007)(305945005)(8936002)(3846002)(81166006)(81156014)(6116002)(386003)(50226002)(6666004)(50466002)(11346002)(86362001)(14444005)(446003)(76176011)(97736004)(6636002)(21086003)(36756003)(2906002)(33026002)(4720700003)(69596002)(53936002)(55016002)(48376002)(85306007)(478600001)(476003)(8886007)(316002)(26005)(4326008)(486006)(2616005)(5660300001)(956004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3277; H:mellanox.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-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB3277; 23:rNggLhYyO2yDNvyb8x9t98MS2AsLZnWz16Lz20Mi3?= =?us-ascii?Q?GoJfE+7SqFqeBsmsv0QoFX9qj/IgZMgBwQ8+q0lSCmW3iCbqYGftRNQ181SI?= =?us-ascii?Q?UE0UrD55U2pITIbMVuKSkHvZSDLPPmc6hoxbVeRRx4epAS3pP94Va+QNmhHj?= =?us-ascii?Q?EFOxQrV9YF3hj2l1Lj3c/jCb5CLIQH9SGfnKtIqE+pYXjkiZbINvrkJF+9dE?= =?us-ascii?Q?lN7V+EjkVTXn++cC6Zs7GUhzdffgqVFbuz707gFuDUxTvf6ornEr+LixXCkc?= =?us-ascii?Q?2o9ieItamboU+z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vemsWpYsLaT1wmwoMRtNNu9htgDLgC+TimUBK+5MRcuNYmhcWrclhqmeI3tGGng==; 5:TuFJYC/cjtWK08HsvzGv0ErAk8MuUy7kW/H+rVHbjPdVXHF0NeuOb6AZ3HSSJqJNwwBnp6tfqMdlfQUSYgimhjBVDmZtEzLPQfQc2lItMFQ/UMgaF3mbzWTLEulxw9JAC8XBRDywE60pek8lGu53BPrYLqJ6jOHZdjNULt1wh9s=; 7:1T8fbsxfZ23KKe1o5V/12wrZgpjGIVk/kQnhSuqQCDMi9gVAR3pixuGJYy0CWdEZkMZdddf1xFZBNkc6/km5CqFmuNAqeXetcSmZvfATHPUyWVzrFVcM6kZFYU7LWxESEibNfFdb/RM9sfT4PAT1PFMf3HywLTPDFHy9+hbKr+h/P0iPJWEfVap9wgVPp3MI2gAIM9QukuueOIy1Xvl/zkZOsC5mKTTD1xv+UiJk7BRrob0I+KPL0e6Y+rtme8Jw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2018 14:14:12.3802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55839192-9d6c-4c12-8d75-08d632a87ba1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3277 Subject: [dpdk-dev] [PATCH v2 4/7] 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: Mon, 15 Oct 2018 14:14:14 -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 --- drivers/net/mlx5/mlx5_flow_tcf.c | 82 +++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 660d45e..d6840d5 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -3372,37 +3372,75 @@ 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 before * 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 length. + * @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 = ctx->seq++; - struct mnl_socket *nl = ctx->nl; - int ret; - - nlh->nlmsg_flags |= NLM_F_ACK; + unsigned int portid = mnl_socket_get_portid(tcf->nl); + uint32_t seq = tcf->seq++; + int err, ret; + + assert(tcf->nl); + assert(tcf->buf); + if (!seq) + seq = tcf->seq++; nlh->nlmsg_seq = seq; - ret = mnl_socket_sendto(nl, nlh, nlh->nlmsg_len); - if (ret != -1) - ret = mnl_socket_recvfrom(nl, ans, sizeof(ans)); - if (ret != -1) - ret = mnl_cb_run - (ans, ret, seq, mnl_socket_get_portid(nl), NULL, NULL); + if (!msglen) { + msglen = nlh->nlmsg_len; + nlh->nlmsg_flags |= NLM_F_ACK; + } + ret = mnl_socket_sendto(tcf->nl, nlh, msglen); + err = (ret <= 0) ? errno : 0; + nlh = (struct nlmsghdr *)(tcf->buf); + /* + * The following loop postpones non-fatal errors until multipart + * messages are complete. + */ if (ret > 0) + while (true) { + ret = mnl_socket_recvfrom(tcf->nl, tcf->buf, + tcf->buf_size); + if (ret < 0) { + err = errno; + if (err != ENOSPC) + break; + } + if (!err) { + ret = mnl_cb_run(nlh, ret, seq, portid, + cb, arg); + if (ret < 0) { + err = errno; + break; + } + } + /* Will receive till end of multipart message */ + if (!(nlh->nlmsg_flags & NLM_F_MULTI) || + nlh->nlmsg_type == NLMSG_DONE) + break; + } + if (!err) return 0; - rte_errno = errno; - return -rte_errno; + rte_errno = err; + return -err; } /** @@ -3433,7 +3471,7 @@ struct pedit_parser { nlh = dev_flow->tcf.nlh; nlh->nlmsg_type = RTM_NEWTFILTER; nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL; - if (!flow_tcf_nl_ack(nl, nlh)) + if (!flow_tcf_nl_ack(nl, nlh, 0, NULL, NULL)) return 0; return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -3466,7 +3504,7 @@ struct pedit_parser { nlh = dev_flow->tcf.nlh; nlh->nlmsg_type = RTM_DELTFILTER; nlh->nlmsg_flags = NLM_F_REQUEST; - flow_tcf_nl_ack(nl, nlh); + flow_tcf_nl_ack(nl, nlh, 0, NULL, NULL); } /** @@ -3842,7 +3880,7 @@ struct pedit_parser { tcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0); tcm->tcm_parent = TC_H_INGRESS; /* Ignore errors when qdisc is already absent. */ - if (flow_tcf_nl_ack(nl, nlh) && + if (flow_tcf_nl_ack(nl, nlh, 0, NULL, NULL) && rte_errno != EINVAL && rte_errno != ENOENT) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -3858,7 +3896,7 @@ struct pedit_parser { tcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0); tcm->tcm_parent = TC_H_INGRESS; mnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, "ingress"); - if (flow_tcf_nl_ack(nl, nlh)) + if (flow_tcf_nl_ack(nl, nlh, 0, NULL, NULL)) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "netlink: failed to create ingress" -- 1.8.3.1