From patchwork Wed Dec 16 23:12:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 7866711 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8AA66BEEED for ; Wed, 16 Dec 2015 23:12:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8000203EB for ; Wed, 16 Dec 2015 23:12:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D541420396 for ; Wed, 16 Dec 2015 23:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934270AbbLPXMj (ORCPT ); Wed, 16 Dec 2015 18:12:39 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33365 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754952AbbLPXMX (ORCPT ); Wed, 16 Dec 2015 18:12:23 -0500 Received: by mail-pa0-f45.google.com with SMTP id ur14so30974264pab.0 for ; Wed, 16 Dec 2015 15:12:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=avagotech.com; s=google; h=date:from:to:subject:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=wa6OQQ62mxEJoSdkqp2yVCAtbFN/2xd2K4h6L5VE0TU=; b=q+flHHLWg2LYf06BakibSOO7K37TC7iHjoKlGNtERs8WU3bbvZC55ychZd6pJET7RI 7FBZETdm9QkeORXhPSCxpBK/Ty15nd8Z4x8Hdv9jvXeCANxJHrDjIV/mYWslrr11glKn ePrwl3O/PtglWh7q5+nbm5HJ6eSAEvhOqy3I0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=wa6OQQ62mxEJoSdkqp2yVCAtbFN/2xd2K4h6L5VE0TU=; b=Tb/pztGVlK0TWNW7amf5gzOyKFxXr8O0GSaKBGiPiweTTOcSHtguVFLoKmKuf+oFEG USiY2aFMOLgl/FU/6zqzb/iySLhoXPsClfMJXPeUcQfK0uXJyea4JygEzPZ5Z87E3Clj vKh+qinHjmNQ8TPi3zptjWn2D612QAAwvmx8/18So6DOtdeNIYEAYGVLjJ7UsZ8mplwy c30fN4KZXL+rUfMP2jAzNBu0sgIDZ6dvihnbV4WsCOQLpydHixKgFuUgxjkWjfagkZO1 la6K3IngV2aP3oxMJwmQ4I5tTB4Drz2/xw6w4MRP3BqNQvbAF9Z3VdRHQdjCIUAqJFVU UApg== X-Gm-Message-State: ALoCoQl/cp5T/KAgzxqpDaYZVAzHoHeChAW2MEG86RWUleGgY/wRUIPOlBqzkgAt1QM9eKLTIFdDSbhM+aLqZeZToJmREImKaQ== X-Received: by 10.66.161.133 with SMTP id xs5mr7013187pab.70.1450307543208; Wed, 16 Dec 2015 15:12:23 -0800 (PST) Received: from myfc17 (cm-wififw.emulex.com. [138.239.220.50]) by smtp.gmail.com with ESMTPSA id w65sm3056975pfa.18.2015.12.16.15.12.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 16 Dec 2015 15:12:22 -0800 (PST) Date: Wed, 16 Dec 2015 18:12:04 -0500 From: james.smart@avagotech.com (James Smart) To: linux-scsi@vger.kernel.org Subject: [PATCH 13/17] lpfc: Fix external loopback failure. Message-ID: <5671efc4.p0ZuEBo3q81E+gY3%james.smart@avagotech.com> User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix external loopback failure. Rx sequence reassembly was incorrect. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- drivers/scsi/lpfc/lpfc_sli.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index e504d51..b4bff35 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -14849,10 +14849,12 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) struct lpfc_dmabuf *h_buf; struct hbq_dmabuf *seq_dmabuf = NULL; struct hbq_dmabuf *temp_dmabuf = NULL; + uint8_t found = 0; INIT_LIST_HEAD(&dmabuf->dbuf.list); dmabuf->time_stamp = jiffies; new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; + /* Use the hdr_buf to find the sequence that this frame belongs to */ list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { temp_hdr = (struct fc_frame_header *)h_buf->virt; @@ -14892,7 +14894,8 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) return seq_dmabuf; } /* find the correct place in the sequence to insert this frame */ - list_for_each_entry_reverse(d_buf, &seq_dmabuf->dbuf.list, list) { + d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); + while (!found) { temp_dmabuf = container_of(d_buf, struct hbq_dmabuf, dbuf); temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; /* @@ -14902,9 +14905,17 @@ lpfc_fc_frame_add(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) if (be16_to_cpu(new_hdr->fh_seq_cnt) > be16_to_cpu(temp_hdr->fh_seq_cnt)) { list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); - return seq_dmabuf; + found = 1; + break; } + + if (&d_buf->list == &seq_dmabuf->dbuf.list) + break; + d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); } + + if (found) + return seq_dmabuf; return NULL; }