Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp851304imu; Thu, 13 Dec 2018 05:37:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wr+ANwGkOj/YuzdlB7ko1gVXLOmi0qUhbXszB6Qr8/PCltuuvAmosNlXql/FiDqd/vWMgM X-Received: by 2002:a17:902:7614:: with SMTP id k20mr23957958pll.285.1544708262812; Thu, 13 Dec 2018 05:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544708262; cv=none; d=google.com; s=arc-20160816; b=PJgROHFQhLZM5tbReo7zVHDT/RDW5OTBf1TbLBT7JS8MHlEFukuq3w4jNQq5k07gDT 6MniUlrkV1LErYmBWfO/hKzrBpT0H7n15CctHz4QT5cL5cGTwXvhnS5dzACYp78vgPk7 GKhAV3oMvRXddZaOrB//rNzXmkp+W2PKdOhoAISCsrL8FJzIbVZmgih8fOuMXUIqUTZk 176QckX9/gf4o7btDmooQMEgwziZFo2nCeftVsmUqIy5j1w0IOyeRAlddMCzQ36IOeDz f6s6NL5EaNdQRGz1W9KoX6QDjX/tn1qO7lVGosyBorWvbK15tPO2ieppLCltx+usu0Na 81qg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=D/WQaxePgOtUAT5rTUxHxgOkGBiPzSwWfT5nFKN7N3k=; b=VYFtXaZ7ExqKRhRjAcW+XlrZOlw/XQpe+c280FAD9KEuvd+sMV4SvUFKpCrBDEjDoJ h/MUSTFUfPT6B/hoJbnnzmv76DqZHd7zydI7sRxNleVlgtJr4IHIEOPfhx/IRfSUwR5u olbMBnk9c+7pfsovwoNPiEfxMMW4TN1iB6mmAfNWggO/r/M8owYeFTPh0CGXbsaWb4iH jcLESgALYH9z6zIA9G4MEkL7yHW+rTugPyg0zghNN4zUeJ6A4mNnc+nuXhivnCcSJH33 kjYKqSkCD4rzjyQoMSDH0PVJh8sKRLKBSzcNRv3W+ActfFL0L0v99StQPsIiAzBSRh3g 561Q== 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 102si1582573plc.277.2018.12.13.05.37.18; Thu, 13 Dec 2018 05:37:42 -0800 (PST) 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 S1729496AbeLMNgR (ORCPT + 99 others); Thu, 13 Dec 2018 08:36:17 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:16564 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729281AbeLMNgR (ORCPT ); Thu, 13 Dec 2018 08:36:17 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 374E3E39FCCA8; Thu, 13 Dec 2018 21:36:09 +0800 (CST) Received: from [127.0.0.1] (10.202.226.41) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.408.0; Thu, 13 Dec 2018 21:36:00 +0800 Subject: Re: [PATCH v4 4/5] scsi: hisi_sas: Add support for DIF feature for v3 hw To: "Martin K. Petersen" References: <1544103284-100497-1-git-send-email-john.garry@huawei.com> <1544103284-100497-5-git-send-email-john.garry@huawei.com> CC: , , , , Xiang Chen From: John Garry Message-ID: <4752be71-f39c-ac55-0e51-36c146108a38@huawei.com> Date: Thu, 13 Dec 2018 13:35:56 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.41] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/12/2018 02:20, Martin K. Petersen wrote: > > John, Hi Martin, > >> +static void fill_prot_v3_hw(struct scsi_cmnd *scsi_cmnd, >> + struct hisi_sas_protect_iu_v3_hw *prot) >> +{ >> + u8 prot_type = scsi_get_prot_type(scsi_cmnd); >> + u8 prot_op = scsi_get_prot_op(scsi_cmnd); >> + unsigned int interval = scsi_prot_interval(scsi_cmnd); >> + u32 lbrt_chk_val; >> + >> + if (interval == 4096) >> + lbrt_chk_val = (u32)(scsi_get_lba(scsi_cmnd) >> 3); >> + else >> + lbrt_chk_val = (u32)scsi_get_lba(scsi_cmnd); > > lbrt_chk_val = t10_pi_ref_tag(scmd->request); > ok > + >> + switch (prot_op) { >> + case SCSI_PROT_READ_STRIP: >> + prot->dw0 |= (T10_RMV_EN_MSK | T10_CHK_EN_MSK); >> + prot->lbrtcv = lbrt_chk_val; >> + if (prot_type == SCSI_PROT_DIF_TYPE1) >> + prot->dw4 |= (0xc << 16); >> + else if (prot_type == SCSI_PROT_DIF_TYPE3) >> + prot->dw4 |= (0xfc << 16); > > We're moving away from prot_type. You should use: > > enum scsi_prot_flags { > SCSI_PROT_TRANSFER_PI = 1 << 0, > SCSI_PROT_GUARD_CHECK = 1 << 1, > SCSI_PROT_REF_CHECK = 1 << 2, > SCSI_PROT_REF_INCREMENT = 1 << 3, > SCSI_PROT_IP_CHECKSUM = 1 << 4, > }; ok > > to set your controller flags. > > + if (prot_op == SCSI_PROT_WRITE_INSERT) { > + unsigned int interval = scsi_prot_interval(scsi_cmnd); > + unsigned int ilog2_interval = ilog2(interval); > + > + len = (task->total_xfer_len >> ilog2_interval) * 8; > > scsi_transfer_length(struct scsi_cmnd *scmd) ok > >> + if (hisi_hba->enable_dif) { >> + dev_info(dev, "Registering for DIF type 1/2/3 protection.\n"); >> + prot |= SHOST_DIF_TYPE1_PROTECTION | >> + SHOST_DIF_TYPE2_PROTECTION | >> + SHOST_DIF_TYPE3_PROTECTION; >> + } >> + >> + scsi_host_set_prot(hisi_hba->shost, prot); > > I'm not so keen on this enable_dif/enable_dix business in module > parameters. I suggest you just allow the user to specify the host > protection mask instead of having a layer of indirection. > Fine, we can let the user select the mask. However, for now, I would like to keep default at off. When soaks a bit, we can make default on @ 0x7. Cheers, John