From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10060.outbound.protection.outlook.com [40.107.1.60]) by dpdk.org (Postfix) with ESMTP id A279C1B488 for ; Wed, 11 Jul 2018 21:57:36 +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=ilbwUdVQbwYkQuJ1jn4F+VGFGVFldXgtdcIHkY/5UsM=; b=rr7yOyObLx7Q/xNSwPMDtPeSvN7jCk4TjeVMwiHP/3NtVzOwpPZVfo2UVrweICEbtSCDGALJMol3mTJYqHp0dhbKZDMDtGvlLhmqJmXLae6zd07gKHIcb2QFld7djRmLoHLg2nN2+yZdVqqfqccmbkyF7xt/GLdt155HmZrc5no= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from yongseok-MBP.local (209.116.155.178) by AM5PR0501MB2034.eurprd05.prod.outlook.com (2603:10a6:203:1a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Wed, 11 Jul 2018 19:57:32 +0000 Date: Wed, 11 Jul 2018 12:57:19 -0700 From: Yongseok Koh To: Nelio Laranjeiro Cc: dev@dpdk.org, Adrien Mazarguil Message-ID: <20180711195716.GA69686@yongseok-MBP.local> References: <8b89f9d6ad4c0eeb9e1a050b8b0cc6562e16ca91.1531293415.git.nelio.laranjeiro@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8b89f9d6ad4c0eeb9e1a050b8b0cc6562e16ca91.1531293415.git.nelio.laranjeiro@6wind.com> User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BN6PR1001CA0005.namprd10.prod.outlook.com (2603:10b6:405:28::18) To AM5PR0501MB2034.eurprd05.prod.outlook.com (2603:10a6:203:1a::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41bd47ba-f920-4af0-8ada-08d5e7688abf X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM5PR0501MB2034; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2034; 3:L3Ps7EaWqLlKhUdxLmOKkdzWWsUTJR774cOfw1Q6tV+OELfQyPI+25yQ0bgmTKApXrLNQ5RuAdFCX1M3uAwy0ByW/87lFXlrMkrQhWb+oAVG79112OF9plWsPStDk1lxXP4E5Sn6+6VxyceGkOlcHaPlJw7rjEJXOSEHQbkJT6s0nLT6qyMPuCB1CxM/mVFWL1rbiERSGxM3FdLIo3aTKwAkzfrNnKhYyKysn43lXZv5s9waC8H63kpodxSPWK3g; 25:YkHqzDyuWHYb6EOxbWkpUkYhVrEWv71auMpnY0oH7FUtUOHzAtpq197/UlEhgDOPYyhRDcUtCGI+74WR2Fmj616vmhVyBVPJa/8Ns51ZY9tfVuavxPvJF0cwCOIX+AuxiYlgTqg3aNjFtMeAX70YQCnku9Sc9vU5D8CSU4Ld/R2DFLwNIodJsiFxP1qk7eVqMixFDrTvsIKEWQWd/9QXOBz5Hy+O55alSGs4K5vU4hK1fTLfcPCuHldpGc2DR0uR1kX4IDWFYLQPMjDNips6IorZpq/IZqZ8R11bG2j5VL0EsEq7TDZWE0KxRxm3RzhkZFxUgBU89XUVZNmESXIUVg==; 31:Nns6oeL3tpUBy7R7ZcFvIFEKPNRczr7lhuriuS93Sme/SlBDvwRKJrNSFjH3nc35TFm5vX4+6WjQ1AqoX19OhjjUQsw5yg5PXvkP6YsCp9H7tgrFlYSuH5gKNCj7dmR7QyZPD6BIaO6wjegEzouAGVWlZkeG3NzJ9JCVpjegvKlk7JoA/RrsYPPFXhopoqINGGN6Jm2t3up1KPlb30SJbizb2u74J5cwEASWjitzbTk= X-MS-TrafficTypeDiagnostic: AM5PR0501MB2034: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2034; 20:+99adsK+f+TrWBGOIuY94//CW//ETg5ecR5Oxr9A9/VFtxdHlJEYM3k0fOcC/2ZhC0WNrgOX3CVnBny4lSnC581EqwXLbz353yM+1iP2ntqZ3JdYJCwhsuGBgnNhAwlkdDFkYXAle72ZBEbHLKAguPHMAZ/PtVW5MU/XtnsJz5p6y0iOc0kDtWP3OuVyTUsD9amWeYoIG26iP2zu/4HESjUG6WDhCz3VtIrPtj/cDYBRfwGnuHVdp4VLBJ4Mp1aKbDvKGkVkx1Trbs0UmQrX2tkQNyBlAgy4Gpl3XHXj/aSzDgkc+moikwm7tWcTfQyNWPEuzKYbLwbn1aZqxBAQjz/bJ+oRJHnUB5CmnjtpwsiidYZv+zKoDUXZf2oIvJmmKJtQuimaBgvWjhdCco9gX0lwiP2Qfqxiw2qH34kc5HDqhEGWCicESibsskxcRhCLDkHeQyLZQPr4X0AuUwtBgHUt8YK/1SiebqL0R5z3EMRLAvdNf1uv7KXU9nkWGBtj; 4:oS2QRZ2zF5T7qgEtC9b86l5tfhCeFWQ44LeN5aKoimt1OMmUkcVDG3eXWv0iHuUoGLqcHHhQNbBf5tlYUaouUWBR7MtEP3Bj0aMTSn9T8PVAdynz1ku50iELtrUbTRq/oZblvzTooeet3+5XrUeEzPqh/4muzbjqA48faVQjD3tAQe2JQIohohKaAQEHpRNbKuUi8pBWLdt93EXNRuJg+D9FJVNSSHHgEH+q6dYTTyZmIpSRuekkvzfRdiwmbwYyxzYj3+RtiY1m5zp/eswULg== 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)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0501MB2034; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0501MB2034; X-Forefront-PRVS: 0730093765 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(136003)(366004)(39860400002)(376002)(396003)(189003)(199004)(6666003)(58126008)(16586007)(6916009)(33896004)(305945005)(386003)(6506007)(486006)(476003)(106356001)(446003)(956004)(11346002)(86362001)(316002)(2906002)(8936002)(8676002)(7696005)(478600001)(66066001)(26005)(186003)(76176011)(16526019)(7736002)(81156014)(47776003)(81166006)(52116002)(14444005)(5660300001)(105586002)(68736007)(50466002)(6246003)(97736004)(4326008)(98436002)(9686003)(33656002)(55016002)(1076002)(23726003)(53936002)(25786009)(6116002)(3846002)(229853002)(18370500001)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0501MB2034; H:yongseok-MBP.local; 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-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0501MB2034; 23:hU4PtpE8fIcU7jQyElenQJsnnW7cRWnjm2dPDbF?= =?us-ascii?Q?Y45SdDPBsHnuTw6oUyJaO71Ev7IJoLSnv9y6huUxqHNKbSR+/E7qkAB8IHTB?= =?us-ascii?Q?zJibm3/gnfY3daj6e6NB3LsrmTDewYewQAvldV90JjmzXvNd1HXAOjxz6EnX?= =?us-ascii?Q?e4YTgUVe2F2WtuqC3Nb9EP161NyK7ZFsf2VUVtbiW1bVXCgdR48mbOQ6yu6M?= =?us-ascii?Q?+TnUn58X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GWphqDnrrD98nGbCHz/6MYmt82ZJDCGjYiPugbBj1/0WTyB/QuS2has4YMZ2JratbdbG5oEsDXk0r4CiwQ==; 5:Shugl7MyBwalmebU/ojsA7qnipgWllxVWamoNezcVsz7vI42nuRw4F5GbaXLhtwKbKq17BBmuUWx9c4WdmnffYNO1ifwbIQOUb3yxBqJ1/k3Kc8Ct7rUf+c5jSm61XW24NpE1J/lijelrhTiNGOEj5DMoic40GQbvyok/qoaLZY=; 24:PnpyI/fSXIbfKxT+gAJs0BkRM62r3jGWHnPYwBUGLiKqmoD7343cH2SESSv5/40E0RkWwo1IVCh1/Fy+DXu+5eYvSleVv0mBpfR1ZzvuLcw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2034; 7:soguIBHPjjBSzmMywOV6la4CBc3iz6MthWWXL9ATGXXANRDyYl59Lpbr8V1+8osuPSCI+DEy0lxICWTZNj8ck6boyGzm006BomG2oLra3pQ/MkRgGnlZf1l0zwi/YrqB4DY+00BBFR8lDwOMswJPLhOWLMU3Oc6tZWGUh+pb6aBfmJSd+xE/rR351nHJTqHJ5wv5sl00Ql84VL/lLj9SS5FHrETvCz/jqic8ikGmn87Q6cUMTnbelUI5YVwPTMJ7 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2018 19:57:32.5200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41bd47ba-f920-4af0-8ada-08d5e7688abf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2034 Subject: Re: [dpdk-dev] [PATCH v3 14/21] net/mlx5: add RSS flow action 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: Wed, 11 Jul 2018 19:57:41 -0000 On Wed, Jul 11, 2018 at 09:22:47AM +0200, Nelio Laranjeiro wrote: > Signed-off-by: Nelio Laranjeiro > --- > drivers/net/mlx5/mlx5_flow.c | 682 +++++++++++++++++++++++++++-------- > 1 file changed, 537 insertions(+), 145 deletions(-) > [...] > @@ -1322,26 +1583,122 @@ mlx5_flow_merge(struct rte_eth_dev *dev, struct rte_flow *flow, > struct rte_flow_error *error) > { > struct rte_flow local_flow = { .layers = 0, }; > - size_t size = sizeof(*flow) + sizeof(struct ibv_flow_attr); > - int remain = (flow_size > size) ? flow_size - size : 0; > + size_t size = sizeof(*flow); > + union { > + struct rte_flow_expand_rss buf; > + uint8_t buffer[2048]; > + } expand_buffer; > + struct rte_flow_expand_rss *buf = &expand_buffer.buf; > + struct mlx5_flow_verbs *original_verbs = NULL; > + size_t original_verbs_size = 0; > + uint32_t original_layers = 0; > int ret; > + uint32_t i; > > - if (!remain) > + if (size > flow_size) > flow = &local_flow; > ret = mlx5_flow_attributes(dev, attributes, flow, error); > if (ret < 0) > return ret; > - ret = mlx5_flow_items(pattern, flow, remain, error); > - if (ret < 0) > - return ret; > - size += ret; > - remain = (flow_size > size) ? flow_size - size : 0; > - ret = mlx5_flow_actions(dev, actions, flow, remain, error); > + ret = mlx5_flow_actions(dev, actions, &local_flow, 0, error); > if (ret < 0) > return ret; > - size += ret; > + if (local_flow.rss.types) { > + ret = rte_flow_expand_rss(buf, sizeof(expand_buffer.buffer), > + pattern, local_flow.rss.types, > + mlx5_support_expansion, > + MLX5_EXPANSION_ROOT); > + assert(ret > 0 && > + (unsigned int)ret < sizeof(expand_buffer.buffer)); > + } else { > + buf->entries = 1; > + buf->entry[0].pattern = (void *)(uintptr_t)pattern; > + } > + size += RTE_ALIGN_CEIL(local_flow.rss.queue_num * sizeof(uint16_t), > + sizeof(void *)); > if (size <= flow_size) > - flow->verbs.attr->priority = flow->attributes.priority; > + flow->queue = (void *)(flow + 1); > + LIST_INIT(&flow->verbs); > + flow->layers = 0; > + flow->modifier = 0; > + flow->fate = 0; > + for (i = 0; i != buf->entries; ++i) { > + size_t off = size; > + size_t off2; > + int pattern_start_idx = 0; > + > + flow->layers = original_layers; > + size += sizeof(struct ibv_flow_attr) + > + sizeof(struct mlx5_flow_verbs); > + off2 = size; > + if (size < flow_size) { > + flow->cur_verbs = (void *)((uintptr_t)flow + off); > + flow->cur_verbs->attr = (void *)(flow->cur_verbs + 1); > + flow->cur_verbs->specs = > + (void *)(flow->cur_verbs->attr + 1); > + } > + /* First iteration convert the pattern into Verbs. */ > + if (i == 0) { > + /* Actions don't need to be converted several time. */ > + ret = mlx5_flow_actions(dev, actions, flow, > + (size < flow_size) ? > + flow_size - size : 0, > + error); > + if (ret < 0) > + return ret; > + size += ret; > + } else { > + /* > + * Next iteration means the pattern has already been > + * converted and an expansion is necessary to match > + * the user RSS request. For that only the expanded > + * items will be converted, the common part with the > + * user pattern are just copied into the next buffer > + * zone. > + */ > + const struct rte_flow_item *item = pattern; > + > + size += original_verbs_size; > + if (size < flow_size) { > + rte_memcpy(flow->cur_verbs->attr, > + original_verbs->attr, > + original_verbs_size + > + sizeof(struct ibv_flow_attr)); > + flow->cur_verbs->size = original_verbs_size; > + } > + if (pattern->type == RTE_FLOW_ITEM_TYPE_END) { > + pattern_start_idx++; > + } else { > + for (item = pattern; > + item->type != RTE_FLOW_ITEM_TYPE_END; > + ++item) > + pattern_start_idx++; > + } Small nit. Can't this be run once when? As pattern isn't changing, it might be run redundant from i > 1. And how about expanded_pattern_idx instead of pattern_start_idx? Acked-by: Yongseok Koh Thanks > + } > + ret = mlx5_flow_items > + ((const struct rte_flow_item *) > + &buf->entry[i].pattern[pattern_start_idx], > + flow, > + (size < flow_size) ? flow_size - size : 0, error); > + if (ret < 0) > + return ret; > + size += ret; > + if (size <= flow_size) { > + mlx5_flow_adjust_priority(dev, flow); > + LIST_INSERT_HEAD(&flow->verbs, flow->cur_verbs, next); > + } > + /* > + * Keep a pointer of the first verbs conversion and the layers > + * it has encountered. > + */ > + if (i == 0) { > + original_verbs = flow->cur_verbs; > + original_verbs_size = size - off2; > + original_layers = flow->layers; > + } > + } > + /* Restore the origin layers in the flow. */ > + flow->layers = original_layers; > return size; > } > > @@ -1359,12 +1716,17 @@ mlx5_flow_rxq_mark_set(struct rte_eth_dev *dev, struct rte_flow *flow) > struct priv *priv = dev->data->dev_private; > > if (flow->modifier & (MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK)) { > - struct mlx5_rxq_ctrl *rxq_ctrl = > - container_of((*priv->rxqs)[flow->queue], > - struct mlx5_rxq_ctrl, rxq); > + unsigned int i; > + > + for (i = 0; i != flow->rss.queue_num; ++i) { > + int idx = (*flow->queue)[i]; > + struct mlx5_rxq_ctrl *rxq_ctrl = > + container_of((*priv->rxqs)[idx], > + struct mlx5_rxq_ctrl, rxq); > > - rxq_ctrl->rxq.mark = 1; > - rxq_ctrl->flow_mark_n++; > + rxq_ctrl->rxq.mark = 1; > + rxq_ctrl->flow_mark_n++; > + } > } > } > > @@ -1383,12 +1745,17 @@ mlx5_flow_rxq_mark_trim(struct rte_eth_dev *dev, struct rte_flow *flow) > struct priv *priv = dev->data->dev_private; > > if (flow->modifier & (MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK)) { > - struct mlx5_rxq_ctrl *rxq_ctrl = > - container_of((*priv->rxqs)[flow->queue], > - struct mlx5_rxq_ctrl, rxq); > + unsigned int i; > + > + for (i = 0; i != flow->rss.queue_num; ++i) { > + int idx = (*flow->queue)[i]; > + struct mlx5_rxq_ctrl *rxq_ctrl = > + container_of((*priv->rxqs)[idx], > + struct mlx5_rxq_ctrl, rxq); > > - rxq_ctrl->flow_mark_n--; > - rxq_ctrl->rxq.mark = !!rxq_ctrl->flow_mark_n; > + rxq_ctrl->flow_mark_n--; > + rxq_ctrl->rxq.mark = !!rxq_ctrl->flow_mark_n; > + } > } > } > > @@ -1449,18 +1816,20 @@ mlx5_flow_validate(struct rte_eth_dev *dev, > static void > mlx5_flow_remove(struct rte_eth_dev *dev, struct rte_flow *flow) > { > - if (flow->fate & MLX5_FLOW_FATE_DROP) { > - if (flow->verbs.flow) { > - claim_zero(mlx5_glue->destroy_flow(flow->verbs.flow)); > - flow->verbs.flow = NULL; > + struct mlx5_flow_verbs *verbs; > + > + LIST_FOREACH(verbs, &flow->verbs, next) { > + if (verbs->flow) { > + claim_zero(mlx5_glue->destroy_flow(verbs->flow)); > + verbs->flow = NULL; > + } > + if (verbs->hrxq) { > + if (flow->fate & MLX5_FLOW_FATE_DROP) > + mlx5_hrxq_drop_release(dev); > + else > + mlx5_hrxq_release(dev, verbs->hrxq); > + verbs->hrxq = NULL; > } > - } > - if (flow->verbs.hrxq) { > - if (flow->fate & MLX5_FLOW_FATE_DROP) > - mlx5_hrxq_drop_release(dev); > - else if (flow->fate & MLX5_FLOW_FATE_QUEUE) > - mlx5_hrxq_release(dev, flow->verbs.hrxq); > - flow->verbs.hrxq = NULL; > } > } > > @@ -1481,46 +1850,68 @@ static int > mlx5_flow_apply(struct rte_eth_dev *dev, struct rte_flow *flow, > struct rte_flow_error *error) > { > - if (flow->fate & MLX5_FLOW_FATE_DROP) { > - flow->verbs.hrxq = mlx5_hrxq_drop_new(dev); > - if (!flow->verbs.hrxq) > - return rte_flow_error_set > - (error, errno, > - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > - NULL, > - "cannot allocate Drop queue"); > - } else if (flow->fate & MLX5_FLOW_FATE_QUEUE) { > - struct mlx5_hrxq *hrxq; > - > - hrxq = mlx5_hrxq_get(dev, rss_hash_default_key, > - MLX5_RSS_HASH_KEY_LEN, 0, > - &flow->queue, 1, 0, 0); > - if (!hrxq) > - hrxq = mlx5_hrxq_new(dev, rss_hash_default_key, > - MLX5_RSS_HASH_KEY_LEN, 0, > - &flow->queue, 1, 0, 0); > - if (!hrxq) > - return rte_flow_error_set(error, rte_errno, > - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > - NULL, > - "cannot create flow"); > - flow->verbs.hrxq = hrxq; > - } > - flow->verbs.flow = > - mlx5_glue->create_flow(flow->verbs.hrxq->qp, flow->verbs.attr); > - if (!flow->verbs.flow) { > - if (flow->fate & MLX5_FLOW_FATE_DROP) > - mlx5_hrxq_drop_release(dev); > - else > - mlx5_hrxq_release(dev, flow->verbs.hrxq); > - flow->verbs.hrxq = NULL; > - return rte_flow_error_set(error, errno, > - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > - NULL, > - "kernel module refuses to create" > - " flow"); > + struct mlx5_flow_verbs *verbs; > + int err; > + > + LIST_FOREACH(verbs, &flow->verbs, next) { > + if (flow->fate & MLX5_FLOW_FATE_DROP) { > + verbs->hrxq = mlx5_hrxq_drop_new(dev); > + if (!verbs->hrxq) { > + rte_flow_error_set > + (error, errno, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "cannot get drop hash queue"); > + goto error; > + } > + } else { > + struct mlx5_hrxq *hrxq; > + > + hrxq = mlx5_hrxq_get(dev, flow->key, > + MLX5_RSS_HASH_KEY_LEN, > + verbs->hash_fields, > + (*flow->queue), > + flow->rss.queue_num, 0, 0); > + if (!hrxq) > + hrxq = mlx5_hrxq_new(dev, flow->key, > + MLX5_RSS_HASH_KEY_LEN, > + verbs->hash_fields, > + (*flow->queue), > + flow->rss.queue_num, 0, 0); > + if (!hrxq) { > + rte_flow_error_set > + (error, rte_errno, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "cannot get hash queue"); > + goto error; > + } > + verbs->hrxq = hrxq; > + } > + verbs->flow = > + mlx5_glue->create_flow(verbs->hrxq->qp, verbs->attr); > + if (!verbs->flow) { > + rte_flow_error_set(error, errno, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "hardware refuses to create flow"); > + goto error; > + } > } > return 0; > +error: > + err = rte_errno; /* Save rte_errno before cleanup. */ > + LIST_FOREACH(verbs, &flow->verbs, next) { > + if (verbs->hrxq) { > + if (flow->fate & MLX5_FLOW_FATE_DROP) > + mlx5_hrxq_drop_release(dev); > + else > + mlx5_hrxq_release(dev, verbs->hrxq); > + verbs->hrxq = NULL; > + } > + } > + rte_errno = err; /* Restore rte_errno. */ > + return -rte_errno; > } > > /** > @@ -1550,42 +1941,43 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > const struct rte_flow_action actions[], > struct rte_flow_error *error) > { > - struct rte_flow *flow; > - size_t size; > + struct rte_flow *flow = NULL; > + size_t size = 0; > int ret; > > - ret = mlx5_flow_merge(dev, NULL, 0, attr, items, actions, error); > + ret = mlx5_flow_merge(dev, flow, size, attr, items, actions, error); > if (ret < 0) > return NULL; > size = ret; > - flow = rte_zmalloc(__func__, size, 0); > + flow = rte_calloc(__func__, 1, size, 0); > if (!flow) { > rte_flow_error_set(error, ENOMEM, > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > NULL, > - "cannot allocate memory"); > + "not enough memory to create flow"); > return NULL; > } > - flow->verbs.attr = (struct ibv_flow_attr *)(flow + 1); > - flow->verbs.specs = (uint8_t *)(flow->verbs.attr + 1); > ret = mlx5_flow_merge(dev, flow, size, attr, items, actions, error); > - if (ret < 0) > - goto error; > + if (ret < 0) { > + rte_free(flow); > + return NULL; > + } > assert((size_t)ret == size); > if (dev->data->dev_started) { > ret = mlx5_flow_apply(dev, flow, error); > - if (ret < 0) > - goto error; > + if (ret < 0) { > + ret = rte_errno; /* Save rte_errno before cleanup. */ > + if (flow) { > + mlx5_flow_remove(dev, flow); > + rte_free(flow); > + } > + rte_errno = ret; /* Restore rte_errno. */ > + return NULL; > + } > } > mlx5_flow_rxq_mark_set(dev, flow); > TAILQ_INSERT_TAIL(list, flow, next); > return flow; > -error: > - ret = rte_errno; /* Save rte_errno before cleanup. */ > - mlx5_flow_remove(dev, flow); > - rte_free(flow); > - rte_errno = ret; /* Restore rte_errno. */ > - return NULL; > } > > /** > @@ -1745,7 +2137,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, > struct priv *priv = dev->data->dev_private; > const struct rte_flow_attr attr = { > .ingress = 1, > - .priority = priv->config.flow_prio - 1, > + .priority = MLX5_FLOW_PRIO_RSVD, > }; > struct rte_flow_item items[] = { > { > -- > 2.18.0 >