From patchwork Mon Nov 12 20:01:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 48009 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 13F094CB1; Mon, 12 Nov 2018 21:01:46 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80047.outbound.protection.outlook.com [40.107.8.47]) by dpdk.org (Postfix) with ESMTP id 0527A3256 for ; Mon, 12 Nov 2018 21:01:41 +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=Y5so+jpxdnGwaUywL1J/JbBlq60u7Rqs/fulAjTtPpI=; b=JV7OluhraEBRu6vGuBODUyvSXyRwd1OosQSA+rnusdv9wznhptOwg/tiKZHjR3l5LskwA/4wUNX+my0hkqbBbqzOapuDc44voT9Ux0UJO1sDz+nTPPIyiCerGUGUfI91JlnCTGnAKAuQWedbuQEQMY+3FDBTRdtp3Qdz7S4A2Wc= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3377.eurprd05.prod.outlook.com (10.171.187.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 20:01:40 +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.044; Mon, 12 Nov 2018 20:01:39 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Slava Ovsiienko Thread-Topic: [PATCH 1/4] net/mlx5: prepare Netlink communication routine to fix Thread-Index: AQHUesKGMwi7PdEf40a/Lxl/2duO3w== Date: Mon, 12 Nov 2018 20:01:39 +0000 Message-ID: <1542052877-41512-2-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1542052877-41512-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: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) 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; AM4PR05MB3377; 6:ZsekJ/VxmVkrX+HITOoNWdbPe5twHfa/IYXDoeqIBUK7Dk4bYQefjDotCENF7qSeUgx8N3acyfV4YhylOSWM9q2wDnWchN0qIUgfIPVv2hp4Ihwwf/Ax+ngl12agaI/zgH5SdJkt24Ft8/MKkqAnW62Kl1aof6IguaCTD/uOY6Q9rhsUSRtF1gOkrZTXyAJqQ/OxAy6FgX2sKc1Ehh8HOuVO1VBYTmpqv0Ayut20tCi1XiM3iRIPnIzdw9w2AgCetyUaJhTFh5cSleNKoUy/35j7R4YE8f+9z67xSUo8VjEJPneoC4ij321zHmtxmGfUd793t8VJmHiXxW2lPYXiHof2laNb/xQTGHd+utn5yWJ4UhXYu/l3GMauP2RJuPohVClWgq4Rg7XFYtRJBHJoP05y+J+0OlL4WmDYWdm9lPqAbCIYRPoIvez4GrCKyVZVgWNWSc+wr3rx4NW/xrbofw==; 5:NJj4xNCEAIOLAhqK+tyOFny6y1HXQGLifNKWgMIZFo/5oVIks1T2TUvOmBMUnDl59DOsoI4g9jI9vunP+M5hvBne/I6W0GdGIwZYp+jmGWowIJWGJb+8HDepMlRcNYqlmTplZjCB05tS8SSqg9Cw8WV7MY51CX9AQTyj/WycBVA=; 7:veBW7qdPDKIkrNb/0JDJIZQ7f1S48aC5qhq0/LkXC+YSVxL1lqur4EsFLfCPd8Wb0fNwJQiVM4s5Wd8Fcz7LOL+1x+G05dVauwwIPk7XCBqsbFSVdK60WQBJuOGZSR1RcWNjffS3hvdppsuPLtxTRw== x-ms-office365-filtering-correlation-id: f84c761f-0398-4f7d-ef10-08d648d9a8c7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3377; x-ms-traffictypediagnostic: AM4PR05MB3377: 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)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3377; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3377; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(71200400001)(86362001)(71190400001)(97736004)(6486002)(446003)(478600001)(256004)(6636002)(14444005)(486006)(36756003)(2616005)(110136005)(54906003)(105586002)(68736007)(85306007)(316002)(25786009)(99286004)(2906002)(14454004)(106356001)(8676002)(102836004)(81166006)(107886003)(81156014)(2900100001)(6116002)(3846002)(66066001)(305945005)(7736002)(386003)(186003)(6436002)(53936002)(76176011)(6512007)(8936002)(4326008)(11346002)(5660300001)(6506007)(52116002)(476003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3377; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: wMy69oUr3C6HsHB3zivQfx+Fv6HY3iI20+lOscUtD/8boObtbl7bLic45Q1sC1EHINWi/evWGaTDxiph9bAue1gtjYRYRM5oWKthmAOAH5wA52ibaK1NksNWajq45LncHzozIP9Cc2tIGHktBLDr1abL/SHUSAEfVcBHJafQfHXSbPrqw38ATs/rFU0YeTc5tyC595aOgyfpdmKU0KEi8GvfBsk/jfi+sEYhP+yFDZSshXfwFV1t1bd9POFf+te0gVFjSoe2fAARgI6U+hIzY0+BPHmAyN4N7x3Uogxknun0+0RwTHRgHiIXbFCJoS0gOw/gtCBm067T8pfi+b4VIQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f84c761f-0398-4f7d-ef10-08d648d9a8c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 20:01:39.8673 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3377 Subject: [dpdk-dev] [PATCH 1/4] net/mlx5: prepare Netlink communication routine to fix 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" This patch removes the unused message length parameter, we do not send multiple commands in the single message anymore, message length can be taken from the prepared message header, so length parameter can be removed. Signed-off-by: Viacheslav Ovsiienko Acked-by: Shahaf Shuler --- drivers/net/mlx5/mlx5_flow_tcf.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 97d2a54..5a38940 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -3717,10 +3717,6 @@ struct pedit_parser { * @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 @@ -3732,7 +3728,6 @@ struct pedit_parser { static int flow_tcf_nl_ack(struct mlx5_flow_tcf_context *tcf, struct nlmsghdr *nlh, - uint32_t msglen, mnl_cb_t cb, void *arg) { unsigned int portid = mnl_socket_get_portid(tcf->nl); @@ -3745,11 +3740,8 @@ struct pedit_parser { /* seq 0 is reserved for kernel event-driven notifications. */ seq = tcf->seq++; nlh->nlmsg_seq = seq; - if (!msglen) { - msglen = nlh->nlmsg_len; - nlh->nlmsg_flags |= NLM_F_ACK; - } - ret = mnl_socket_sendto(tcf->nl, nlh, msglen); + nlh->nlmsg_flags |= NLM_F_ACK; + ret = mnl_socket_sendto(tcf->nl, nlh, nlh->nlmsg_len); err = (ret <= 0) ? errno : 0; nlh = (struct nlmsghdr *)(tcf->buf); /* @@ -3886,7 +3878,7 @@ struct tcf_nlcb_context { nlh = (struct nlmsghdr *)&bc->msg[msg]; assert((bc->size - msg) >= nlh->nlmsg_len); msg += nlh->nlmsg_len; - rc = flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL); + rc = flow_tcf_nl_ack(tcf, nlh, NULL, NULL); if (rc) { DRV_LOG(WARNING, "netlink: cleanup error %d", rc); @@ -4019,7 +4011,7 @@ struct tcf_nlcb_context { ifa->ifa_family = AF_UNSPEC; ifa->ifa_index = ifindex; ifa->ifa_scope = RT_SCOPE_LINK; - ret = flow_tcf_nl_ack(tcf, nlh, 0, flow_tcf_collect_local_cb, &ctx); + ret = flow_tcf_nl_ack(tcf, nlh, flow_tcf_collect_local_cb, &ctx); if (ret) DRV_LOG(WARNING, "netlink: query device list error %d", ret); ret = flow_tcf_send_nlcmd(tcf, &ctx); @@ -4140,7 +4132,7 @@ struct tcf_nlcb_context { ndm->ndm_family = AF_UNSPEC; ndm->ndm_ifindex = ifindex; ndm->ndm_state = NUD_PERMANENT; - ret = flow_tcf_nl_ack(tcf, nlh, 0, flow_tcf_collect_neigh_cb, &ctx); + ret = flow_tcf_nl_ack(tcf, nlh, flow_tcf_collect_neigh_cb, &ctx); if (ret) DRV_LOG(WARNING, "netlink: query device list error %d", ret); ret = flow_tcf_send_nlcmd(tcf, &ctx); @@ -4269,7 +4261,7 @@ struct tcf_nlcb_context { nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm)); ifm->ifi_family = AF_UNSPEC; - ret = flow_tcf_nl_ack(tcf, nlh, 0, flow_tcf_collect_vxlan_cb, &ctx); + ret = flow_tcf_nl_ack(tcf, nlh, flow_tcf_collect_vxlan_cb, &ctx); if (ret) DRV_LOG(WARNING, "netlink: query device list error %d", ret); ret = flow_tcf_send_nlcmd(tcf, &ctx); @@ -4341,7 +4333,7 @@ struct tcf_nlcb_context { sizeof(encap->ipv6.dst), &encap->ipv6.dst); } - if (!flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL)) + if (!flow_tcf_nl_ack(tcf, nlh, NULL, NULL)) return 0; return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -4404,7 +4396,7 @@ struct tcf_nlcb_context { if (encap->mask & FLOW_TCF_ENCAP_ETH_DST) mnl_attr_put(nlh, NDA_LLADDR, sizeof(encap->eth.dst), &encap->eth.dst); - if (!flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL)) + if (!flow_tcf_nl_ack(tcf, nlh, NULL, NULL)) return 0; return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -4679,7 +4671,7 @@ struct tcf_nlcb_context { ifm->ifi_family = AF_UNSPEC; ifm->ifi_index = vtep->ifindex; assert(sizeof(buf) >= nlh->nlmsg_len); - ret = flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL); + ret = flow_tcf_nl_ack(tcf, nlh, NULL, NULL); if (ret) DRV_LOG(WARNING, "netlink: error deleting vxlan" " encap/decap ifindex %u", @@ -4769,7 +4761,7 @@ struct tcf_nlcb_context { mnl_attr_nest_end(nlh, na_vxlan); mnl_attr_nest_end(nlh, na_info); assert(sizeof(buf) >= nlh->nlmsg_len); - ret = flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL); + ret = flow_tcf_nl_ack(tcf, nlh, NULL, NULL); if (ret) { DRV_LOG(WARNING, "netlink: VTEP %s create failure (%d)", @@ -4811,7 +4803,7 @@ struct tcf_nlcb_context { ifm->ifi_index = vtep->ifindex; ifm->ifi_flags = IFF_UP; ifm->ifi_change = IFF_UP; - ret = flow_tcf_nl_ack(tcf, nlh, 0, NULL, NULL); + ret = flow_tcf_nl_ack(tcf, nlh, NULL, NULL); if (ret) { rte_flow_error_set(error, -errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -5120,7 +5112,7 @@ struct tcf_nlcb_context { *dev_flow->tcf.tunnel->ifindex_ptr = dev_flow->tcf.tunnel->vtep->ifindex; } - if (!flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL)) { + if (!flow_tcf_nl_ack(ctx, nlh, NULL, NULL)) { dev_flow->tcf.applied = 1; return 0; } @@ -5163,7 +5155,7 @@ struct tcf_nlcb_context { nlh = dev_flow->tcf.nlh; nlh->nlmsg_type = RTM_DELTFILTER; nlh->nlmsg_flags = NLM_F_REQUEST; - flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL); + flow_tcf_nl_ack(ctx, nlh, NULL, NULL); if (dev_flow->tcf.tunnel) { assert(dev_flow->tcf.tunnel->vtep); flow_tcf_vtep_release(ctx, @@ -5714,7 +5706,7 @@ struct tcf_nlcb_context { tcm->tcm_parent = TC_H_INGRESS; assert(sizeof(buf) >= nlh->nlmsg_len); /* Ignore errors when qdisc is already absent. */ - if (flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL) && + if (flow_tcf_nl_ack(ctx, nlh, NULL, NULL) && rte_errno != EINVAL && rte_errno != ENOENT) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -5731,7 +5723,7 @@ struct tcf_nlcb_context { tcm->tcm_parent = TC_H_INGRESS; mnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, "ingress"); assert(sizeof(buf) >= nlh->nlmsg_len); - if (flow_tcf_nl_ack(ctx, nlh, 0, NULL, NULL)) + if (flow_tcf_nl_ack(ctx, nlh, NULL, NULL)) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "netlink: failed to create ingress" From patchwork Mon Nov 12 20:01:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 48010 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CDDBE4CC5; Mon, 12 Nov 2018 21:01:47 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80089.outbound.protection.outlook.com [40.107.8.89]) by dpdk.org (Postfix) with ESMTP id 96CF04CA5 for ; Mon, 12 Nov 2018 21:01:41 +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=5P8PW36CvtoIgORzVqz61rxDlvLX79BqXVoqaaKB2f4=; b=w8dp5iOurGssssu1d+0mgeb3rTmzoNZA7lzWf0CwbzQuHzqWa6hfN8WLPxoLnBzk30Bf6WSpocI877SWhmL8ilAGJ0Jd4YXkcRfcJNYFB2EYN9MsWfH7t3ZTmnRct398d41I2xaXOFA0BoF5E+08G76PGWwe54qGpjiGtyEokSA= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3377.eurprd05.prod.outlook.com (10.171.187.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 20:01:40 +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.044; Mon, 12 Nov 2018 20:01:40 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Slava Ovsiienko Thread-Topic: [PATCH 2/4] net/mlx5: fix Netlink communication routine Thread-Index: AQHUesKGE1AKtqM02Uml+gaw0faa8Q== Date: Mon, 12 Nov 2018 20:01:40 +0000 Message-ID: <1542052877-41512-3-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1542052877-41512-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: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) 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; AM4PR05MB3377; 6:KHWGkUHwfp0Wy0kAbRJDiksK8gQrCxAQfBLO892j+CAnn0QWeI+6YIGU33rbriA881n9TQ7inDblR0nKKQpyrLmxlorE/fC5yyBBFhTkm/mTphlFwXdqTYPQm+tqLSwdhZ9pAufcdDpNLcyKsJHIODClfOdpPX49IxaC5og34oL/yuaC/wYlIgQxerEwwmtFJHKNtbMrqWo36B1Rt9gHxq82TaV/cL4QyHHAo7MjLn55e2aAu+yG69bsIGctDgKWg7dYsjABhErFEcpb78pemz3wGcBPrGFInNZDVzDtF9yy37gf+pTg9yO7HmM9nRHwSNgJ1Vt9ZmVq4JYpf2bdq6koFraSjT0gMC4CXxGI6xLCjk8TPilqr4nB0PsMYOoiTi5BiNvx/yhNNij6VCtEGwQXAsY0QxVgb1mvmDShYKJECQNZG/xfwHBg768xzTYU1xiM4J0iH31m0Jy8UT6lSA==; 5:5jOGlVxP1UEE0VaGg4Dtn7+7DGZkGVfgb/hBEEkmJ3YCfoVPa8h1mSoeYteTDDmsZsGmFRAtSWf/q2a/fvfDyyYL73RpBCTwZDsXJd48vZJeGKEINQmEPnk+JAf/eKw/w0FwxYJNioWJ+MNlZZ9juxPcXRIiL9pq5KGfy0fZVf8=; 7:uolDrbGkNOf16rospolSqgmo9wbJgmkFbdsDhdE0UoCjHya8AWsbpHilXV8x9IZKsxd0UKdHQfZZDohKM4USrp5cLaP1Ly2bfmnY8kL9GXF72g3nxTF2KWOLfzvtDA8BRlitXpiXyVGfzba2tEd/tQ== x-ms-office365-filtering-correlation-id: 0773cfda-9a25-4eea-e602-08d648d9a93c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3377; x-ms-traffictypediagnostic: AM4PR05MB3377: 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)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3377; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3377; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(71200400001)(86362001)(71190400001)(97736004)(6486002)(446003)(478600001)(256004)(6636002)(14444005)(486006)(36756003)(2616005)(110136005)(54906003)(105586002)(68736007)(85306007)(316002)(25786009)(99286004)(2906002)(14454004)(106356001)(8676002)(102836004)(81166006)(107886003)(81156014)(2900100001)(6116002)(3846002)(66066001)(305945005)(7736002)(386003)(186003)(6436002)(53936002)(76176011)(6512007)(8936002)(4326008)(11346002)(5660300001)(6506007)(52116002)(476003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3377; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: CUB5T9TEEeH4i9kuyn49ExP0HvxAtzGfq6MMlg9Ylr/pM9U3SWaA1vEsFdBKFKF5wxCSjW2M3Oky/V5YGfzD4mbHtDPxoe73tvqIAVq/y0tRRkq65J1L63ptzyCv5IsVnC3Q1I2xYcs4NpR7M7yo2uxlTrXuZKcwVXo1zChbtWLeUJYyIDFOSr8qAzAbE2IlUsrY0plVqybR2fEJLyIHxDhAhFZSVcU5cdp0djsug0yvTFW16ZxOU2GQ0OwqIHVt0iz4z+NLGlcebHe/kI3jdhfjRL9p9ah6CixmG3y6z/Ux04gCDfuBzcn1NWSGkxtTh/V/L2daJEpKhjwA+CHhSbv4tXRp8tLso9vMulNB5Yo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0773cfda-9a25-4eea-e602-08d648d9a93c X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 20:01:40.6709 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3377 Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: fix Netlink communication routine 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" While receiving the Netlink reply messages we should stop at DONE or ACK message. The existing implementation stops at DONE message or if no multiple message flag set ( NLM_F_MULTI). It prevents the single query requests from working, these requests send the single reply message without multi-message flag followed by ACK message. This patch fixes receiving part of Netlink communication routine. Fixes: 6e74990b3463 ("net/mlx5: update E-Switch VXLAN netlink routines") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_tcf.c | 58 +++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 5a38940..4d154b6 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -3732,44 +3732,60 @@ struct pedit_parser { { unsigned int portid = mnl_socket_get_portid(tcf->nl); uint32_t seq = tcf->seq++; - int err, ret; + int ret, err = 0; assert(tcf->nl); assert(tcf->buf); - if (!seq) + if (!seq) { /* seq 0 is reserved for kernel event-driven notifications. */ seq = tcf->seq++; + } nlh->nlmsg_seq = seq; nlh->nlmsg_flags |= NLM_F_ACK; ret = mnl_socket_sendto(tcf->nl, nlh, nlh->nlmsg_len); - err = (ret <= 0) ? errno : 0; + if (ret <= 0) { + /* Message send error occurres. */ + rte_errno = errno; + return -rte_errno; + } 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); + while (true) { + ret = mnl_socket_recvfrom(tcf->nl, tcf->buf, tcf->buf_size); + if (ret < 0) { + err = errno; + /* + * In case of overflow Will receive till + * end of multipart message. We may lost part + * of reply messages but mark and return an error. + */ + if (err != ENOSPC || + !(nlh->nlmsg_flags & NLM_F_MULTI) || + nlh->nlmsg_type == NLMSG_DONE) + break; + } else { + ret = mnl_cb_run(nlh, ret, seq, portid, cb, arg); + if (!ret) { + /* + * libmnl returns 0 if DONE or + * success ACK message found. + */ + break; + } if (ret < 0) { + /* + * ACK message with error found + * or some error occurred. + */ 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; + } + /* We should continue receiving. */ } + } if (!err) return 0; rte_errno = err; From patchwork Mon Nov 12 20:01:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 48011 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB59E4F91; Mon, 12 Nov 2018 21:01:49 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80072.outbound.protection.outlook.com [40.107.8.72]) by dpdk.org (Postfix) with ESMTP id 8202E4CAD for ; Mon, 12 Nov 2018 21:01:42 +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=0GFiPvYzEK+eig+eqmYLPtjX+WHyeAFzRRH4/w5B/H8=; b=UuRV+8G+IRhKnCeny7xB9a2oXRqjV9wcLih6OwwJBs95EHWcV5DI3svOMexZtsJA0Un9NoPzQHA8bCliNKNmy3qs2NwaJ+ULOqyL2CcUriqSUMFqp+2E12yr56FHY/fQWqA6b0yoSZVdyKd6MZ+PFia+qvqujhF1WF0Q2tn9oKc= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3377.eurprd05.prod.outlook.com (10.171.187.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 20:01:41 +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.044; Mon, 12 Nov 2018 20:01:41 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Slava Ovsiienko Thread-Topic: [PATCH 3/4] net/mlx5: prepare to add E-switch rule flags check Thread-Index: AQHUesKH/8EtegG8bku1I0zT1VoLwQ== Date: Mon, 12 Nov 2018 20:01:41 +0000 Message-ID: <1542052877-41512-4-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1542052877-41512-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: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) 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; AM4PR05MB3377; 6:oAvOEChN4nSDN8B7rUOATV7OJiJ1AD8EGxDES+t448+wylPfwaCXc8JGgtOc23Z5C0HExyBBJiPcw0EoAl2VD7D4UUYEXEab4M3DCT4t2uvYQHNt9cmWd1GOtFg3k9xyw2zi44ZwtLyj5eIS/awPZE595zSunB9F7jr88YGtGb2Ey8DxgPRIvRZfZSocB+JOD5kwmXxFnUG450JAncBHXwrFZPU/2wrqw9J8ZhaotMxVA8r2Og1SljLW99OPpgllnT2QeGzuLALslvdQoWnkGtmDSQBVigP9Big/3Wi3TUVy4B5UHE39pfbI7U7olMugHhtFSWjyD8sUsG84/lStI3Q3vVRnk3MCTeb+HTm+Wi6CodnkqXziAj8xXsZgeNzoHnwfduI/Va87B6BdCnGuInAW/PuHoqpmX2GqesyBro3toGtDZ/0S9EfciAzifcgCFvTPjf8j44QmZl6OEb+b5g==; 5:bURrn+WD9kvYEtenn/sr+2F1/mKlT3pCPMJ+KAcxvzr9xIwN19X0xibvU1z5AtsTHNLoZEANLK4bsTndlzsgy01JdzO27EhUVhpDnZ5ZgeRwZG1rmdMCHo2EyXCwFYkSZ4d8F9ssSLmNiBk6L8RhOFaH52wds7JbE1RZUsd4FiI=; 7:Grc2xBOCx1qU6p9u+AGhl6LCduPnZ1zlL2HSBrnsFHpPXvMJxgVfRspjp8R04PA2oh7WjcEWMjbeQYmeTd0Z4F3FAYQxHJ7sAXfAh37TxHUfMe5ncpymAIJweeS0lGNsJMuo9iAa8ut1/yc70UedDQ== x-ms-office365-filtering-correlation-id: 04aa70b1-30bc-4508-aa64-08d648d9a9b7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3377; x-ms-traffictypediagnostic: AM4PR05MB3377: 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)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3377; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3377; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(71200400001)(86362001)(71190400001)(97736004)(6486002)(446003)(478600001)(256004)(6636002)(14444005)(486006)(36756003)(2616005)(110136005)(54906003)(105586002)(68736007)(85306007)(316002)(25786009)(99286004)(2906002)(14454004)(106356001)(8676002)(102836004)(81166006)(107886003)(81156014)(2900100001)(6116002)(3846002)(66066001)(305945005)(7736002)(386003)(186003)(6436002)(53936002)(76176011)(6512007)(8936002)(4326008)(11346002)(5660300001)(6506007)(52116002)(476003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3377; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: T0D8f3e1o9+Yj2MXPjDljLhtbKMovmE1mTHCgppV8WPhiaZzb+m6/RXJQogoJJaWmiBvMEXDEejKCZxxM4hMYPyLjxNnDeo7XUeBEzruFZSp8FVJlYJmKCDSl9tQfSBh82xEzGigqdtznPdb22Q6wowS/A6IV5uSUeGBxtow7POAlTzr9Q6ctT4VQusS1tlrF5IMZUls6L4h1HunnRCdEGIUDa7P40ZdNqqJBAYUXN2F2tKHQ0tYyd4l397TmGIE/qabH32yuBjQlYRoU5Kqed4oDNSzXjBGheM1ka/yNkLv+r19Bb7VUr5vAfL4mQm653QCdUmeoYm9mRd39X1sLZxIzpFXDRVwBC0KK2F4d2Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04aa70b1-30bc-4508-aa64-08d648d9a9b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 20:01:41.5335 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3377 Subject: [dpdk-dev] [PATCH 3/4] net/mlx5: prepare to add E-switch rule flags check 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" The tc flower filter rules are used to control E-switch from the application side. In order to gain garanteed rule hardware offload the skip_sw flag should be specified while applying the rule. But some tc rules is rejected by kernel if skip_sw flag is set by design. Currently this regards VXLAN tunneling rules, which are applied to special VXLAN virtual devices. Albeit these rules are applied with skip_sw flag reset kernel tries to perform hardware offload. If kernel succeeded the in_hw flag is set in rule properties and application should check this flag to get know whether the applied rule is actually hardware offloaded. This patch prepares for the rule flags query and check in_hw flag. The driver checks only the rules with skip_sw flag reset, so we need to test the actual flags of rule is being applied. The pointer to flags field into translated rule is introduced and flags are tested directly in the rule body. It is more reliable than save and check flags copy. Also patch swaps the flow_tcf_apply() and flow_tcf_remove(), we are going to call flow_tcf_remove() from flow_tcf_appy() if no in_hw flag set found in applied rule. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_tcf.c | 82 +++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 51ab47f..57b312e 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -219,6 +219,7 @@ struct mlx5_flow_dv { struct mlx5_flow_tcf { struct nlmsghdr *nlh; struct tcmsg *tcm; + uint32_t *ptc_flags; /**< tc rule applied flags. */ union { /**< Tunnel encap/decap descriptor. */ struct flow_tcf_tunnel_hdr *tunnel; struct flow_tcf_vxlan_decap *vxlan_decap; diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 4d154b6..5bfb2d8 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -160,6 +160,9 @@ struct tc_tunnel_key { #ifndef TCA_CLS_FLAGS_SKIP_SW #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) #endif +#ifndef TCA_CLS_FLAGS_IN_HW +#define TCA_CLS_FLAGS_IN_HW (1 << 2) +#endif #ifndef HAVE_TCA_CHAIN #define TCA_CHAIN 11 #endif @@ -3699,6 +3702,8 @@ struct pedit_parser { assert(na_flower); assert(na_flower_act); mnl_attr_nest_end(nlh, na_flower_act); + dev_flow->tcf.ptc_flags = mnl_attr_get_payload + (mnl_nlmsg_get_payload_tail(nlh)); mnl_attr_put_u32(nlh, TCA_FLOWER_FLAGS, decap.vxlan ? 0 : TCA_CLS_FLAGS_SKIP_SW); mnl_attr_nest_end(nlh, na_flower); @@ -5077,6 +5082,44 @@ struct tcf_nlcb_context { pthread_mutex_unlock(&vtep_list_mutex); } +/** + * Remove flow from E-Switch by sending Netlink message. + * + * @param[in] dev + * Pointer to Ethernet device. + * @param[in, out] flow + * Pointer to the sub flow. + */ +static void +flow_tcf_remove(struct rte_eth_dev *dev, struct rte_flow *flow) +{ + struct priv *priv = dev->data->dev_private; + struct mlx5_flow_tcf_context *ctx = priv->tcf_context; + struct mlx5_flow *dev_flow; + struct nlmsghdr *nlh; + + if (!flow) + return; + dev_flow = LIST_FIRST(&flow->dev_flows); + if (!dev_flow) + return; + /* E-Switch flow can't be expanded. */ + assert(!LIST_NEXT(dev_flow, next)); + if (dev_flow->tcf.applied) { + nlh = dev_flow->tcf.nlh; + nlh->nlmsg_type = RTM_DELTFILTER; + nlh->nlmsg_flags = NLM_F_REQUEST; + flow_tcf_nl_ack(ctx, nlh, NULL, NULL); + if (dev_flow->tcf.tunnel) { + assert(dev_flow->tcf.tunnel->vtep); + flow_tcf_vtep_release(ctx, + dev_flow->tcf.tunnel->vtep, + dev_flow); + dev_flow->tcf.tunnel->vtep = NULL; + } + dev_flow->tcf.applied = 0; + } +} /** * Apply flow to E-Switch by sending Netlink message. @@ -5145,45 +5188,6 @@ struct tcf_nlcb_context { } /** - * Remove flow from E-Switch by sending Netlink message. - * - * @param[in] dev - * Pointer to Ethernet device. - * @param[in, out] flow - * Pointer to the sub flow. - */ -static void -flow_tcf_remove(struct rte_eth_dev *dev, struct rte_flow *flow) -{ - struct priv *priv = dev->data->dev_private; - struct mlx5_flow_tcf_context *ctx = priv->tcf_context; - struct mlx5_flow *dev_flow; - struct nlmsghdr *nlh; - - if (!flow) - return; - dev_flow = LIST_FIRST(&flow->dev_flows); - if (!dev_flow) - return; - /* E-Switch flow can't be expanded. */ - assert(!LIST_NEXT(dev_flow, next)); - if (dev_flow->tcf.applied) { - nlh = dev_flow->tcf.nlh; - nlh->nlmsg_type = RTM_DELTFILTER; - nlh->nlmsg_flags = NLM_F_REQUEST; - flow_tcf_nl_ack(ctx, nlh, NULL, NULL); - if (dev_flow->tcf.tunnel) { - assert(dev_flow->tcf.tunnel->vtep); - flow_tcf_vtep_release(ctx, - dev_flow->tcf.tunnel->vtep, - dev_flow); - dev_flow->tcf.tunnel->vtep = NULL; - } - dev_flow->tcf.applied = 0; - } -} - -/** * Remove flow from E-Switch and release resources of the device flow. * * @param[in] dev From patchwork Mon Nov 12 20:01:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 48012 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D83764F9C; Mon, 12 Nov 2018 21:01:51 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80050.outbound.protection.outlook.com [40.107.8.50]) by dpdk.org (Postfix) with ESMTP id 66D0C4CAD for ; Mon, 12 Nov 2018 21:01:43 +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=81c9MYZ+mKc4xxeDsn3mIJg3I8uBn9syCJ6P+7QqiwQ=; b=HPOG9EFsRqeSIeemmIM4eHchutA4o60bQYfN9UsuI6flb69znApWSsIPUHt0rEXjPQwCe4/DHac7P4BBqwI+ClAU6g2TrRSb2LDmdXgzoGRnQkFae8cIkI0Zk1BGjJHarPrY/iSBX3IK1TfCQ9sm/95smtiNZ2oudaih3y3RMdw= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3377.eurprd05.prod.outlook.com (10.171.187.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 20:01:42 +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.044; Mon, 12 Nov 2018 20:01:42 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Slava Ovsiienko Thread-Topic: [PATCH 4/4] net/mlx5: add E-switch rule hardware offload flag check Thread-Index: AQHUesKHT/ly+14K3Ue8Lo61d0IE1w== Date: Mon, 12 Nov 2018 20:01:42 +0000 Message-ID: <1542052877-41512-5-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1542052877-41512-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: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) 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; AM4PR05MB3377; 6:heamtGp3L8uhabYLUkCDTdP2GLLi1FtCCcyV+U6TMOV2clmuvreeIpybv1X6SPwNx7ib7EPs4hyqFiUvmi+hb5lXpEu8Z5RP/Gn/4fFCbyb9M2ICC0JXPVGgGUyzPZggv42pjA7OlWSh20gdCKr0mShuLORtqh43vgW7TpOM3Bs6H8Z/vcbwHdvyVSrJar7F6U0WLm16v7tFctwVwQcYf+i6VMBLK3hNbUrZi8UAOSUacmIT2csXke5RGwpra0f8jkRA1cB6vyoLxWrvxBDUJ/+HT4jeNBwniGejwOnsElFPNEhS8s1DLqyXVZZ8RmYTlU2c0SOigmwN/KnKiMspCtMwmMgo7uVmIxNjG5vCFccgtskIL3d9KuLNR81lQScCWINYIFpH2k4n/05fMzr2Xa4eeavRQ3F4qbQ7zOGhlqJX2ATXz69Dg/7FKQe90XlqlK6O8nKlyV024mF+9OTXuw==; 5:8CEPiH0+sRTPx5QK+aw8U7XexMIQT/c/2owBlLTqJ4T1j9nomkmWxNyBeUz5lSlUEi5EZJtZUx2oMptsrEQidPBt4AqE3JiyU6alvUSNcx98qhaX0JjxPn0YAA5eoQwwqyl2bWzYZ08pZi82mOOV9Lcgrl52+03R3DPTX+Z1HuE=; 7:BdcxdeTqT+9MawOivkKUAyls2Dp1NaX0OC8v0NhchIt+lqQFpwd4Wp6Mk2QMsjVx6kqSW7Hr8ZtdmkXwdlZEaByfyDnqnEMdQhAJcDG4y7oxVZOBpR9X+AlVjvs6ui0MHhL4cBYs00qceexDW4kSSA== x-ms-office365-filtering-correlation-id: 4363eece-cdca-460c-49fa-08d648d9aa3b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3377; x-ms-traffictypediagnostic: AM4PR05MB3377: 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)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3377; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3377; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(71200400001)(86362001)(71190400001)(97736004)(6486002)(446003)(478600001)(256004)(6636002)(14444005)(486006)(36756003)(2616005)(110136005)(54906003)(105586002)(68736007)(85306007)(316002)(25786009)(99286004)(2906002)(14454004)(106356001)(8676002)(102836004)(81166006)(107886003)(81156014)(2900100001)(6116002)(3846002)(66066001)(305945005)(7736002)(386003)(186003)(6436002)(53936002)(76176011)(6512007)(8936002)(4326008)(11346002)(5660300001)(6506007)(52116002)(476003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3377; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +vcmw6S2PGZSRnR3hizs7s9gXm2o7Q/5KJ3RbmSZAAXOlGBbtF1VR6ecCtkouiVbvgJbpLDxC+UtX35wmnOYb1CcgRtZ2JLjpULioXy1o7cr25qjubSqimmGmu3rmwyPg4J0uNcMSNJIhqPsJbghFJWLdoYClcwvyFZB7t3BIjHAqO7BYtCKbPPcds8UHKYy4oFUjXTm5CBCwYwdk/lmvSxWA/UYExosY9JzZVCIQycwKl3ZnKxhqTXqa0FUS0+3Fp/nPRTF/I4RqnoE+09FWdd2H8Utz1SItgAlPE2B+X7ArnoSeMgqqQKSbAF5lkRSw7K74fwS5PF8PCFrd7nE9HYgtUbigTgezKO0JEnoC24= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4363eece-cdca-460c-49fa-08d648d9aa3b X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 20:01:42.3921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3377 Subject: [dpdk-dev] [PATCH 4/4] net/mlx5: add E-switch rule hardware offload flag check 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" This patch adds the in_hw flag check for tc flower filter rules. If rule is applied without skip_sw flag set driver should check whether the in_hw flag is set after rule applying. If no in_hw flag set found it means the rule is not hardware offloaded and error should be returned to application. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_tcf.c | 142 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 5bfb2d8..91deb88 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -5082,6 +5082,134 @@ struct tcf_nlcb_context { pthread_mutex_unlock(&vtep_list_mutex); } +struct tcf_nlcb_query { + uint32_t handle; + uint32_t tc_flags; + uint32_t flags_valid:1; +}; + +/** + * Collect queried rule attributes. This is callback routine called by + * libmnl mnl_cb_run() in loop for every message in received packet. + * Current implementation collects the flower flags only. + * + * @param[in] nlh + * Pointer to reply header. + * @param[in, out] arg + * Context pointer for this callback. + * + * @return + * A positive, nonzero value on success (required by libmnl + * to continue messages processing). + */ +static int +flow_tcf_collect_query_cb(const struct nlmsghdr *nlh, void *arg) +{ + struct tcf_nlcb_query *query = arg; + struct tcmsg *tcm = mnl_nlmsg_get_payload(nlh); + struct nlattr *na, *na_opt; + bool flower = false; + + if (nlh->nlmsg_type != RTM_NEWTFILTER || + tcm->tcm_handle != query->handle) + return 1; + mnl_attr_for_each(na, nlh, sizeof(*tcm)) { + switch (mnl_attr_get_type(na)) { + case TCA_KIND: + if (strcmp(mnl_attr_get_payload(na), "flower")) { + /* Not flower filter, drop entire message. */ + return 1; + } + flower = true; + break; + case TCA_OPTIONS: + if (!flower) { + /* Not flower options, drop entire message. */ + return 1; + } + /* Check nested flower options. */ + mnl_attr_for_each_nested(na_opt, na) { + switch (mnl_attr_get_type(na_opt)) { + case TCA_FLOWER_FLAGS: + query->flags_valid = 1; + query->tc_flags = + mnl_attr_get_u32(na_opt); + break; + } + } + break; + } + } + return 1; +} + +/** + * Query a TC flower rule flags via netlink. + * + * @param[in] tcf + * Context object initialized by mlx5_flow_tcf_context_create(). + * @param[in] dev_flow + * Pointer to the flow. + * @param[out] pflags + * pointer to the data retrieved by the query. + * + * @return + * 0 on success, a negative errno value otherwise. + */ +static int +flow_tcf_query_flags(struct mlx5_flow_tcf_context *tcf, + struct mlx5_flow *dev_flow, + uint32_t *pflags) +{ + struct nlmsghdr *nlh; + struct tcmsg *tcm; + struct tcf_nlcb_query query = { + .handle = dev_flow->tcf.tcm->tcm_handle, + }; + + nlh = mnl_nlmsg_put_header(tcf->buf); + nlh->nlmsg_type = RTM_GETTFILTER; + nlh->nlmsg_flags = NLM_F_REQUEST; + tcm = mnl_nlmsg_put_extra_header(nlh, sizeof(*tcm)); + memcpy(tcm, dev_flow->tcf.tcm, sizeof(*tcm)); + /* + * Ignore Netlink error for filter query operations. + * The reply length is sent by kernel as errno. + * Just check we got the flags option. + */ + flow_tcf_nl_ack(tcf, nlh, flow_tcf_collect_query_cb, &query); + if (!query.flags_valid) { + *pflags = 0; + return -ENOENT; + } + *pflags = query.tc_flags; + return 0; +} + +/** + * Query and check the in_hw set for specified rule. + * + * @param[in] tcf + * Context object initialized by mlx5_flow_tcf_context_create(). + * @param[in] dev_flow + * Pointer to the flow to check. + * + * @return + * 0 on success, a negative errno value otherwise. + */ +static int +flow_tcf_check_inhw(struct mlx5_flow_tcf_context *tcf, + struct mlx5_flow *dev_flow) +{ + uint32_t flags; + int ret; + + ret = flow_tcf_query_flags(tcf, dev_flow, &flags); + if (ret) + return ret; + return (flags & TCA_CLS_FLAGS_IN_HW) ? 0 : -ENOENT; +} + /** * Remove flow from E-Switch by sending Netlink message. * @@ -5173,6 +5301,20 @@ struct tcf_nlcb_context { } if (!flow_tcf_nl_ack(ctx, nlh, NULL, NULL)) { dev_flow->tcf.applied = 1; + if (*dev_flow->tcf.ptc_flags & TCA_CLS_FLAGS_SKIP_SW) + return 0; + /* + * Rule was applied without skip_sw flag set. + * We should check whether the rule was acctually + * accepted by hardware (have look at in_hw flag). + */ + if (flow_tcf_check_inhw(ctx, dev_flow)) { + flow_tcf_remove(dev, flow); + return rte_flow_error_set + (error, ENOENT, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "netlink: rule has no in_hw flag set"); + } return 0; } if (dev_flow->tcf.tunnel) {