Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp395810ybk; Wed, 13 May 2020 03:05:22 -0700 (PDT) X-Google-Smtp-Source: APiQypIxxIuR1QzegAd0Fyw9gY712Q8cCE7Ry08yFl3uEWn97U8Puexi1KzWXi1hVSnXwx8PVbTa X-Received: by 2002:a17:906:829a:: with SMTP id h26mr21042572ejx.133.1589364322537; Wed, 13 May 2020 03:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589364322; cv=none; d=google.com; s=arc-20160816; b=DkLl9NevsNJotSeX3/uSn+EGWqZJgd6om6twDO81Rc7kyjCqMkzJj5e9GNK7/DJHKO 5zqHkPwYNy5q1m5QcG2ve1tihwWfvX8NffhdFPJr+LtyyUgTPHd91MU2Qt9jXKi37FBw Bhjd/UFulUtmZOPe/QdncPL0dmvz1Vks+YyIBU/pbNztmRsFq+54mzEO14I8OqlJGGvV EjT36YQFFC4nTIS2P+k++Cwwa3Hw34Rdcj/NvvnpqKwUL4R0Y+C8G230jqFpoJj+DVf5 vYFaGEoiM/MQwM3mBu3qWnIxtJkpho+LLZK4nGPPQh9g0xTniMZp50iyJD1s73+9rTkl uHYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0XyNDNdPB0iXMX+OoCPiwxBcj02UrUnuovdmWFSpQFY=; b=K6zQZCNqIqIdnB+A+N639KBGsFXB5j3ooIxyx0M3inNiruBfOPQSFFTYbMq7pmepEA sbibaHHvKiYlfFdegcOSRiNq4mLIo/XluRotUsWS4TrNhXcr39tq/F8pftzatg0KSeqe zoVkf8FhIE6o+YJ61VFp7mMmfne/THd55xB0/+SZkPH/C8kAWs+91b2i8zZaTZxBy1PP rxMF9mrVW3xggtOWcKAwvf43FY123mVe7WhAD+Jnx902oEl5TamQfF+R33fvAP56LiLw 2TVHd3SKBfAXNPTLqO3hU6T7xCnpMK7Jj4zCgqVvLpg68z8D8AdVLquXkGbiWM9Dsl1N FVvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFLi1xka; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si4170162edx.48.2020.05.13.03.04.58; Wed, 13 May 2020 03:05:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFLi1xka; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387744AbgEMJwH (ORCPT + 99 others); Wed, 13 May 2020 05:52:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387742AbgEMJwE (ORCPT ); Wed, 13 May 2020 05:52:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B76B20753; Wed, 13 May 2020 09:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589363523; bh=IDIvI+1772k1Od1sxCmC/aHtQx79JKNpyEUnrjOlVXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFLi1xkaOkBO/l0NImxgnmPSbepuXh8tSbLVKOf2fT+Plik4NEazpGwLOMUUrQIzE nfhSxw/ac5U6mYcvXh3sxuF2ULwOy4P/ediPiiVPmB0vqM+zntUw9SfOFysuA6NPjS fOZAL03TZSs0BlmOA5Ygh3EwR0cZTcXAOHkp294s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Pirko , Ido Schimmel , "David S. Miller" Subject: [PATCH 5.6 019/118] mlxsw: spectrum_acl_tcam: Position vchunk in a vregion list properly Date: Wed, 13 May 2020 11:43:58 +0200 Message-Id: <20200513094419.427217170@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513094417.618129545@linuxfoundation.org> References: <20200513094417.618129545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Pirko [ Upstream commit 6ef4889fc0b3aa6ab928e7565935ac6f762cee6e ] Vregion helpers to get min and max priority depend on the correct ordering of vchunks in the vregion list. However, the current code always adds new chunk to the end of the list, no matter what the priority is. Fix this by finding the correct place in the list and put vchunk there. Fixes: 22a677661f56 ("mlxsw: spectrum: Introduce ACL core with simple TCAM implementation") Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -986,8 +986,9 @@ mlxsw_sp_acl_tcam_vchunk_create(struct m unsigned int priority, struct mlxsw_afk_element_usage *elusage) { + struct mlxsw_sp_acl_tcam_vchunk *vchunk, *vchunk2; struct mlxsw_sp_acl_tcam_vregion *vregion; - struct mlxsw_sp_acl_tcam_vchunk *vchunk; + struct list_head *pos; int err; if (priority == MLXSW_SP_ACL_TCAM_CATCHALL_PRIO) @@ -1025,7 +1026,14 @@ mlxsw_sp_acl_tcam_vchunk_create(struct m } mlxsw_sp_acl_tcam_rehash_ctx_vregion_changed(vregion); - list_add_tail(&vchunk->list, &vregion->vchunk_list); + + /* Position the vchunk inside the list according to priority */ + list_for_each(pos, &vregion->vchunk_list) { + vchunk2 = list_entry(pos, typeof(*vchunk2), list); + if (vchunk2->priority > priority) + break; + } + list_add_tail(&vchunk->list, pos); mutex_unlock(&vregion->lock); return vchunk;