Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752138AbaASLnu (ORCPT ); Sun, 19 Jan 2014 06:43:50 -0500 Received: from mail-ea0-f179.google.com ([209.85.215.179]:62621 "EHLO mail-ea0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbaASLnp (ORCPT ); Sun, 19 Jan 2014 06:43:45 -0500 Message-ID: <52DBBA69.4040800@dev.mellanox.co.il> Date: Sun, 19 Jan 2014 13:43:37 +0200 From: Sagi Grimberg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "Nicholas A. Bellinger" , target-devel CC: linux-scsi , linux-kernel , "Martin K. Petersen" , Christoph Hellwig , Hannes Reinecke , Sagi Grimberg , Or Gerlitz , Roland Dreier , Nicholas Bellinger Subject: Re: [PATCH-v2 03/17] target/sbc: Add DIF setup in sbc_check_prot + sbc_parse_cdb References: <1390099480-29013-1-git-send-email-nab@daterainc.com> <1390099480-29013-4-git-send-email-nab@daterainc.com> In-Reply-To: <1390099480-29013-4-git-send-email-nab@daterainc.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/19/2014 4:44 AM, Nicholas A. Bellinger wrote: > From: Nicholas Bellinger > > This patch adds sbc_check_prot() for performing various DIF > related CDB sanity checks, along with setting cmd->prot_type > once sanity checks have passed. > > Also, add calls in sbc_parse_cdb() for READ_[10,12,16] + > WRITE_[10,12,16] to perform DIF sanity checking. > > v2 changes: > - Make sbc_check_prot defined as static (Fengguang + Wei) > - Remove unprotected READ/WRITE warning (mkp) > - Populate cmd->prot_type + friends (Sagi) > - Drop SCF_PROT usage > > Cc: Martin K. Petersen > Cc: Christoph Hellwig > Cc: Hannes Reinecke > Cc: Sagi Grimberg > Cc: Or Gerlitz > Signed-off-by: Nicholas Bellinger > --- > drivers/target/target_core_sbc.c | 62 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c > index 6863dbe..91a92f3 100644 > --- a/drivers/target/target_core_sbc.c > +++ b/drivers/target/target_core_sbc.c > @@ -563,6 +563,44 @@ sbc_compare_and_write(struct se_cmd *cmd) > return TCM_NO_SENSE; > } > > +static bool > +sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb, > + u32 sectors) > +{ > + if (!cmd->t_prot_sg || !cmd->t_prot_nents) > + return true; > + > + switch (dev->dev_attrib.pi_prot_type) { > + case TARGET_DIF_TYPE3_PROT: > + if (!(cdb[1] & 0xe0)) > + return true; > + > + cmd->reftag_seed = 0xffffffff; > + break; > + case TARGET_DIF_TYPE2_PROT: > + if (cdb[1] & 0xe0) > + return false; > + > + cmd->reftag_seed = cmd->t_task_lba; > + break; > + case TARGET_DIF_TYPE1_PROT: > + if (!(cdb[1] & 0xe0)) > + return true; > + > + cmd->reftag_seed = cmd->t_task_lba; > + break; > + case TARGET_DIF_TYPE0_PROT: > + default: > + return true; > + } > + > + cmd->prot_type = dev->dev_attrib.pi_prot_type; > + cmd->prot_length = dev->prot_length * sectors; > + cmd->prot_handover = PROT_SEPERATED; I know that we are not planning to support interleaved mode at the moment, But I think that the protection handover type is the backstore preference and should be taken from se_dev. But it is not that important for now... Sagi. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/