Received: by 10.213.65.68 with SMTP id h4csp788796imn; Tue, 13 Mar 2018 23:17:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELvdDm7Q9LzCzEgGXJR9GTAIXkrPFqH9X1gpnselcyiRh34h0iW5IXKKywwUNYGdbyYrrsgv X-Received: by 10.99.178.6 with SMTP id x6mr2743874pge.98.1521008276122; Tue, 13 Mar 2018 23:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521008276; cv=none; d=google.com; s=arc-20160816; b=AgmIlwXXGLMlh+K01tivfKN68Gs6fclLeHCk81OLQ2bevIk7jN5MGRSpKhWFRF7hgy rCtSPzNm7OB0X9RlYiUviWLHIqb+Jq5Ar6JjlqbWeiLPHyxWVvd9fbRvwM//QYPkxXQI SuAYZMHtDHLfwXfa7Ux1bx2CTTTBZjX4E+98iyJ0Ah7FetyC69l/IgbDei+SU2W2pQZt ke6WSwvh0s+Aafd4e6H/bZIj0ItyB5uvXqPItOot0afCkDqI/y6wbSHaykBYjWfXiDL2 r8PyM3YIjrdNkaWHalE0SnNhS+L7BF1cpn66ElK5Bg8TufCcZoitXHaCcQCfQgb4e3fp 9OBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:references:in-reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UISlp0MkS2lfyrGWVSICfUrKxVkU6MJI+Ds3s7Iealo=; b=xC5CWfCHhlOakP/Pa+FXgfWIREAUHBddef/oF8htA8v3mTxkQN0MkuJDWjDWofMrId iT2GKa8lXlEx1+aAX80uamPZSCcPy4rlTLQEzcEXnpwVrJnNGQtJpiqGiCdM7HbehDcV bB4KOlfBZIeMxFJDZuRfTF14o4USMA+zhtT2DNAQiQBdPsBlc6fwcL+hHh6Cgw0MtmVp hPs51vLfCyiQSGQclRwzORdOG663ZdYsfqt3IcNPL82CYYMIIVjBjxlawuOVxsJEGxPV 7ac6JyyKu6+KhOLmm/FWe7sbBBTR8oWTimvSc1Lq/1RdYSqmJmTf2Qpb+JM4+9VfMZUU u7zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23si1339242pge.500.2018.03.13.23.17.42; Tue, 13 Mar 2018 23:17:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933384AbeCNGQh (ORCPT + 99 others); Wed, 14 Mar 2018 02:16:37 -0400 Received: from mx-rz-2.rrze.uni-erlangen.de ([131.188.11.21]:59291 "EHLO mx-rz-2.rrze.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933184AbeCNGQc (ORCPT ); Wed, 14 Mar 2018 02:16:32 -0400 Received: from mx-rz-2.rrze.uni-erlangen.de (mx-rz-2.rrze.uni-erlangen.de [IPv6:2001:638:a000:1025::15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx-rz-2.rrze.uni-erlangen.de (Postfix) with ESMTPS id 401M1W1fC2zPkDS; Wed, 14 Mar 2018 07:16:31 +0100 (CET) Authentication-Results: mx-rz-2.rrze.uni-erlangen.de; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Quarantine-ID: X-Virus-Scanned: amavisd-new at boeck1.rrze.uni-erlangen.de (RRZE) X-Amavis-Alert: BAD HEADER SECTION, Header field occurs more than once: "References" occurs 3 times X-RRZE-Flag: Not-Spam X-RRZE-Submit-IP: 2003:d5:3e7:2500:bfbd:dba3:49d6:7204 Received: from fau.de (p200300D503E72500BFBDDBA349D67204.dip0.t-ipconnect.de [IPv6:2003:d5:3e7:2500:bfbd:dba3:49d6:7204]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: U2FsdGVkX18cI1p8mWBOSK/FYFeGD50ATZTDbPwpuqg=) by smtp-auth.uni-erlangen.de (Postfix) with ESMTPSA id 401M1R6c1rzPjw5; Wed, 14 Mar 2018 07:16:27 +0100 (CET) From: Jonas Rabenstein To: Jonas Rabenstein , Scott Bauer , Jonathan Derrick , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8.3/8.4] block: sed-opal: get metadata about opal-sed tables Date: Wed, 14 Mar 2018 07:15:44 +0100 Message-Id: <2f3d01b1bf513a78a64e3b5dc6b7de59aaf2543d.1521006596.git.jonas.rabenstein@studium.uni-erlangen.de> X-Mailer: git-send-email 2.16.1 In-Reply-To: References: In-Reply-To: References: <20180313154416.sgptuw7jcn7l76vn@sbauer-Z170X-UD5> References: <20180313154416.sgptuw7jcn7l76vn@sbauer-Z170X-UD5> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Every opal-sed table is described in the OPAL_TABLE_TABLE. Provide a function to get desired information out of that table. Signed-off-by: Jonas Rabenstein --- block/opal_proto.h | 16 ++++++++++++++++ block/sed-opal.c | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/block/opal_proto.h b/block/opal_proto.h index b6e352cfe982..5e8df3245eb0 100644 --- a/block/opal_proto.h +++ b/block/opal_proto.h @@ -106,6 +106,7 @@ enum opal_uid { OPAL_ENTERPRISE_BANDMASTER0_UID, OPAL_ENTERPRISE_ERASEMASTER_UID, /* tables */ + OPAL_TABLE_TABLE, OPAL_LOCKINGRANGE_GLOBAL, OPAL_LOCKINGRANGE_ACE_RDLOCKED, OPAL_LOCKINGRANGE_ACE_WRLOCKED, @@ -160,6 +161,21 @@ enum opal_token { OPAL_STARTCOLUMN = 0x03, OPAL_ENDCOLUMN = 0x04, OPAL_VALUES = 0x01, + /* table table */ + OPAL_TABLE_UID = 0x00, + OPAL_TABLE_NAME = 0x01, + OPAL_TABLE_COMMON = 0x02, + OPAL_TABLE_TEMPLATE = 0x03, + OPAL_TABLE_KIND = 0x04, + OPAL_TABLE_COLUMN = 0x05, + OPAL_TABLE_COLUMNS = 0x06, + OPAL_TABLE_ROWS = 0x07, + OPAL_TABLE_ROWS_FREE = 0x08, + OPAL_TABLE_ROW_BYTES = 0x09, + OPAL_TABLE_LASTID = 0x0A, + OPAL_TABLE_MIN = 0x0B, + OPAL_TABLE_MAX = 0x0C, + /* authority table */ OPAL_PIN = 0x03, /* locking tokens */ diff --git a/block/sed-opal.c b/block/sed-opal.c index ebee06aaadd6..4d93a6097ec0 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -136,6 +136,8 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { /* tables */ + [OPAL_TABLE_TABLE] + { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 }, [OPAL_LOCKINGRANGE_GLOBAL] = { 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x01 }, [OPAL_LOCKINGRANGE_ACE_RDLOCKED] = @@ -1106,6 +1108,29 @@ static int generic_get_column(struct opal_dev *dev, const u8 *table, return finalize_and_send(dev, parse_and_check_status); } +/* + * see TCG SAS 5.3.2.3 for a description of the available columns + * + * the result is provided in dev->resp->tok[4] + */ +static int generic_get_table_info(struct opal_dev *dev, enum opal_uid table, + u64 column) +{ + u8 uid[OPAL_UID_LENGTH]; + const unsigned int half = OPAL_UID_LENGTH/2; + + /* sed-opal UIDs can be split in two halfs: + * first: actual table index + * second: relative index in the table + * so we have to get the first half of the OPAL_TABLE_TABLE and use the + * first part of the target table as relative index into that table + */ + memcpy(uid, opaluid[OPAL_TABLE_TABLE], half); + memcpy(uid+half, opaluid[table], half); + + return generic_get_column(dev, uid, column); +} + static int gen_key(struct opal_dev *dev, void *data) { u8 uid[OPAL_UID_LENGTH]; -- 2.16.1