Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp472597pxu; Wed, 25 Nov 2020 07:45:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEepWHcZtE2P3DIJEJUcjYMv4By2Yjd5/6LM+HbQffQZ4KTwxvjxv7S5MYahMgFKQE5HW4 X-Received: by 2002:a17:906:6dd6:: with SMTP id j22mr3537921ejt.255.1606319147310; Wed, 25 Nov 2020 07:45:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606319147; cv=none; d=google.com; s=arc-20160816; b=bwgDGqY3EjKjk+BeaRGevyfELaPD3Hk9UyWIK5mWAHHOn7D8aXWbVKmS8Jjzmfr/wO 0KAulrnfNPEhgZqUhXhFMdiAky2yAmq9b9jN3//Q2f51WPanQ9//yRaoJKFjHhbCZITR 5xPEbIsn0jCX9dS7jqEr4HwZHpzfH+tSQNssX7dZhj+XXOdDE9XqZ3OOJGfzUkdFukXz 5E7pn8yazjE5enlc6aJ/p4FT/BX/QoFt/S43GtJ5/euxTupKHcqDs82HECtDcaQOZlIE km3/vxeCgrYRIAIZv1KLVbgnKXrm6C1XCijG3MvwsVVQ72SkXf6uqAUK9Yjob+IeQ+VH qoBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DQ5mvdYsZKpuKwSnVY9FO2m/COFaWljnLIbiifDXalg=; b=GsxoVXcH5dxgl3kxOrYjwAB6/wonDYQyvN7gpR9JnEH1PBl+7QmQeIcbecLrEckVAy kL3AoZ7grEc5os+DWmkOdKnNtoWPbdzCQg0XJOBZhG/yv6N0VX2SkY8nMfGrf2aYqhVk YQgzy45XhpfRJO7+5zg9iq5cjFsn29mrBdM7vtnH9H7DuzeGWYKLvBysi14GPSrd+6al UdO+/QrNzqUQnIC29Z+Kaq9JXF0f5IIh8UtTE4jMUemUyZXxOqb+oNVwJSFwLrk9KKvi 4Lw/4ShYV5SxJWN3ItZzat4DXC9bdK39snlKKJ1PhTeKj/1obA9V8WOjLoieozp64VcO QkpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYEJTLQS; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq23si1450954ejb.529.2020.11.25.07.45.24; Wed, 25 Nov 2020 07:45:47 -0800 (PST) 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=rYEJTLQS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731769AbgKYPma (ORCPT + 99 others); Wed, 25 Nov 2020 10:42:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:53684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730542AbgKYPgW (ORCPT ); Wed, 25 Nov 2020 10:36:22 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A51C21527; Wed, 25 Nov 2020 15:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606318581; bh=4gu0UGDR9VqIfsJu+7+Ew5aXzDMrtErgwkWyRjtxuuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYEJTLQSSmGFxYvD4DSM6orTT/mMWOS6FYVe1Iv/y+cfl2/6cXOnWNLbPP+V5iZgv T60wA+VnHaMI21evIHPEuJXnoSPRRqzsylczSti5xotaqRDviZpScIYTrR9jWAB/mn VwbEPKMM7yHo9EueCRK2LvqzQ4/D6idk0VikQqi4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Christie , Paolo Bonzini , Jason Wang , "Michael S . Tsirkin" , Stefan Hajnoczi , Sasha Levin , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 22/33] vhost scsi: add lun parser helper Date: Wed, 25 Nov 2020 10:35:39 -0500 Message-Id: <20201125153550.810101-22-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201125153550.810101-1-sashal@kernel.org> References: <20201125153550.810101-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Christie [ Upstream commit 18f1becb6948cd411fd01968a0a54af63732e73c ] Move code to parse lun from req's lun_buf to helper, so tmf code can use it in the next patch. Signed-off-by: Mike Christie Reviewed-by: Paolo Bonzini Acked-by: Jason Wang Link: https://lore.kernel.org/r/1604986403-4931-5-git-send-email-michael.christie@oracle.com Signed-off-by: Michael S. Tsirkin Acked-by: Stefan Hajnoczi Signed-off-by: Sasha Levin --- drivers/vhost/scsi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 5d8850f5aef16..ed7dc6b998f65 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -898,6 +898,11 @@ vhost_scsi_get_req(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc, return ret; } +static u16 vhost_buf_to_lun(u8 *lun_buf) +{ + return ((lun_buf[2] << 8) | lun_buf[3]) & 0x3FFF; +} + static void vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) { @@ -1036,12 +1041,12 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) tag = vhost64_to_cpu(vq, v_req_pi.tag); task_attr = v_req_pi.task_attr; cdb = &v_req_pi.cdb[0]; - lun = ((v_req_pi.lun[2] << 8) | v_req_pi.lun[3]) & 0x3FFF; + lun = vhost_buf_to_lun(v_req_pi.lun); } else { tag = vhost64_to_cpu(vq, v_req.tag); task_attr = v_req.task_attr; cdb = &v_req.cdb[0]; - lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF; + lun = vhost_buf_to_lun(v_req.lun); } /* * Check that the received CDB size does not exceeded our -- 2.27.0