Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2738067pxj; Mon, 31 May 2021 09:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMa+W9e1KHKYC/cxkmogC+CmqsD/Gx030LCSt/fSZL7qNwVikx9VJ8cr8sY4qDqnuvPra+ X-Received: by 2002:a5d:818b:: with SMTP id u11mr17409724ion.36.1622478581156; Mon, 31 May 2021 09:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478581; cv=none; d=google.com; s=arc-20160816; b=cPLkq0/dp4QI8A92+wTY+Tcmu2E8cRcXwXUu/EHTBMRPJfT87GZ1krV+znb8YCMqkE r0j2bZPzhjZ9mV+hdWhCOIXy7Hxac1nngUwXb7ZRMk4bTrq9Fs7C10XVSRpnb824cnbn bk8eCnGoUQGPBL2Q0RFFC//5+NHVCgMiM6DoEZKsXrPo5Gi8Yt7gItnIiIeeP7TVszdh Osh89SewPAgOx5artmMWLhl0B3ETDWIA2s4l6I5k+wBJIqjqVCuMMekdYSUrGXljFW0T RYe0O8GkKbTKrTfKzn/PuriioHrUGLj98/1EBUKqYE8TrJ13wn00mvNUrmzBdXk6UCbX 5K7w== 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=KjqBOoGzOQ0wClOuoqOcM04HgH0B3cRbv8HuxTjnqIdx0oV37KJfRPp4++e2ewNqac Ay5c8OaT38jYeGyGsrJBzm3i7gtxCTwtOPLWhPs9NAtlcqjZ9MXTWVEwIBSK5I8AwwTR JWYI5JJ1FLagrjLCFVwWXz/subet8UctD34PsuSNLlzHeXpFd77VycLZU6dMUTinXigc SOpMIsoaHvBM5uQ0+fANK+Qmvk1U9nAu4ihquK4OeuB2zlcGAB6MhRz4Gc+Mvnb971z0 l3laXI8WkvfhZlgujtQTxbx34xsCC6H1Vsg9M4qECzTZot1G6rmgwN/5CW6dDg98cmtf Q+Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MA1plq2m; 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 w12si14417524jad.49.2021.05.31.09.29.24; Mon, 31 May 2021 09:29:41 -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=MA1plq2m; 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 S232578AbhEaQ2L (ORCPT + 99 others); Mon, 31 May 2021 12:28:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234235AbhEaOpK (ORCPT ); Mon, 31 May 2021 10:45:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E072D61C85; Mon, 31 May 2021 13:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469305; bh=AIb1ypQvJEXd7UNZ+e+2vszULBi7y+iz7/mtflgTJWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MA1plq2my7e6pmjf3Z56Y2bh8mMpWRwfEUE72HYjpwuYZ5wz1f6WDvs0MBcyJkdAd AhjIuBnXJyYCSQ7dhux81qABPky/xQ2kOyN6so9wttrUUHhcLeWirmilSRdpxMIDC1 tPOqj9GxJMq/E0PbEVgRarQiDELQupekr/0ntNm0= 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.12 148/296] net: dsa: sja1105: fix VL lookup command packing for P/Q/R/S Date: Mon, 31 May 2021 15:13:23 +0200 Message-Id: <20210531130708.844653601@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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,