Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2666099pxj; Mon, 31 May 2021 07:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFKl0UeO8rcDOj8FemZRnOWETDKnCB/6C9a1hqN1VH49Ntf1ms6cy+FCSJiV5qZUFtkbO9 X-Received: by 2002:a5e:870a:: with SMTP id y10mr5046240ioj.108.1622472444047; Mon, 31 May 2021 07:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472444; cv=none; d=google.com; s=arc-20160816; b=ssvyQd9idm8imlbvEtRAW/TRTRgzF7CEGXs34+2dllqJIWawiF+2z5GoXJEG7dMy7g 1Y4UM+o6m9ZMdRONUbjsdIFjta7H4xo1SZZqjaArmGSotsvOQUjIEPsHj0npvu45Xx/Q C1mOC7+J9tgYOgPxPcWVk4wAoWYE1/2o/BgHYAUzuWTUz53WmR2MsrrXtylv2Qv/tWH9 KeaUF57yXbMaj67kA8BpU+A+2T7S9AHfXPaXPUrYRlKvQyMkCWijAZsHrYeDR2t7+X65 lAi7E8Dlgs+3SR58Jhj+Eqrq/7oseVb9rzUAzyGu51OMvhAI38SLW62b8y7nbzpR8f16 hpxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aIdMk9maTBBh49sWeUAVic8+bWjInrs4amH60O3s54U=; b=PINgsA9E5dtg2N6o+F+XuYT0ZkZeLSdGnD1bX1M0X1R1HYkwyCwONEHk7zK1jwS9D9 ONg3Bca2c9Hpofqiq2xnviAGrRiDHwcaj4SfpgyTWqLRBS/8EkUweDQgyBf/BccOaW3z k102oVYReFw1p3zsyNn2yAMe8B0b4OYfGsk+c10fNT6gIcwON1/xb1CdxnFFfrT8Kw56 Fmt4MlA28EllDjcBLx3lK4mbNrc3q06nGIqpdpEL+I2ItfxZe9COMGnmZu5cMKXZwCdV 1zRqmi4iZb9rmmd8QTEM/AwMbp8kTU/Xzy1l+JU7cZ0+XSkDo9FizuDuo1tFQ3QPP1+Y vxkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z8d+AITy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si7481497ilm.140.2021.05.31.07.47.09; Mon, 31 May 2021 07:47:24 -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=@linuxfoundation.org header.s=korg header.b=z8d+AITy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbhEaOsH (ORCPT + 99 others); Mon, 31 May 2021 10:48:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:32912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbhEaOAz (ORCPT ); Mon, 31 May 2021 10:00:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 800B861943; Mon, 31 May 2021 13:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468198; bh=AIb1ypQvJEXd7UNZ+e+2vszULBi7y+iz7/mtflgTJWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z8d+AITyP3CU8iZRT5NoHdCG+Ksylv4LYdYIA0ghhb7KjIQYvLmpRvg0BVVd92+Mx 2z4axV/q9kos/Lk7MA0Lfp1Vac1YZUMHaFvwScEu3200wqk0EBT38DxNpMiAYN7Kna QY94qESQIERkhxK/WEvDdp8yb6r/grFOoqpDMock= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" Subject: [PATCH 5.10 119/252] net: dsa: sja1105: fix VL lookup command packing for P/Q/R/S Date: Mon, 31 May 2021 15:13:04 +0200 Message-Id: <20210531130702.037800440@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit ba61cf167cb77e54c1ec5adb7aa49a22ab3c9b28 upstream. At the beginning of the sja1105_dynamic_config.c file there is a diagram of the dynamic config interface layout: packed_buf | V +-----------------------------------------+------------------+ | ENTRY BUFFER | COMMAND BUFFER | +-----------------------------------------+------------------+ <----------------------- packed_size ------------------------> So in order to pack/unpack the command bits into the buffer, sja1105_vl_lookup_cmd_packing must first advance the buffer pointer by the length of the entry. This is similar to what the other *cmd_packing functions do. This bug exists because the command packing function for P/Q/R/S was copied from the E/T generation, and on E/T, the command was actually embedded within the entry buffer itself. Fixes: 94f94d4acfb2 ("net: dsa: sja1105: add static tables for virtual links") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/sja1105/sja1105_dynamic_config.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) --- a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c +++ b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c @@ -167,9 +167,10 @@ enum sja1105_hostcmd { SJA1105_HOSTCMD_INVALIDATE = 4, }; +/* Command and entry overlap */ static void -sja1105_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, - enum packing_op op) +sja1105et_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, + enum packing_op op) { const int size = SJA1105_SIZE_DYN_CMD; @@ -179,6 +180,20 @@ sja1105_vl_lookup_cmd_packing(void *buf, sja1105_packing(buf, &cmd->index, 9, 0, size, op); } +/* Command and entry are separate */ +static void +sja1105pqrs_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, + enum packing_op op) +{ + u8 *p = buf + SJA1105_SIZE_VL_LOOKUP_ENTRY; + const int size = SJA1105_SIZE_DYN_CMD; + + sja1105_packing(p, &cmd->valid, 31, 31, size, op); + sja1105_packing(p, &cmd->errors, 30, 30, size, op); + sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); + sja1105_packing(p, &cmd->index, 9, 0, size, op); +} + static size_t sja1105et_vl_lookup_entry_packing(void *buf, void *entry_ptr, enum packing_op op) { @@ -641,7 +656,7 @@ static size_t sja1105pqrs_cbs_entry_pack const struct sja1105_dynamic_table_ops sja1105et_dyn_ops[BLK_IDX_MAX_DYN] = { [BLK_IDX_VL_LOOKUP] = { .entry_packing = sja1105et_vl_lookup_entry_packing, - .cmd_packing = sja1105_vl_lookup_cmd_packing, + .cmd_packing = sja1105et_vl_lookup_cmd_packing, .access = OP_WRITE, .max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT, .packed_size = SJA1105ET_SIZE_VL_LOOKUP_DYN_CMD, @@ -725,7 +740,7 @@ const struct sja1105_dynamic_table_ops s const struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = { [BLK_IDX_VL_LOOKUP] = { .entry_packing = sja1105_vl_lookup_entry_packing, - .cmd_packing = sja1105_vl_lookup_cmd_packing, + .cmd_packing = sja1105pqrs_vl_lookup_cmd_packing, .access = (OP_READ | OP_WRITE), .max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT, .packed_size = SJA1105PQRS_SIZE_VL_LOOKUP_DYN_CMD,