From 56ffd3a0500e3b0c133da451036074fd0a8c3f1c Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:32 -0700 Subject: scsi: bnx2fc: Add filters to the non-offload FCoE receive path. Add the following filters to bnx2fc_recv_frame(): 1. Filter out invalid packets - eth->dest_mac[3] matches FC frame's D_ID 2. Filter out packets that are not from our connected target - In FIP_ST_ENABLED mode - eth->src_mac matches fcoe_ctlr->dest_addr 3. Filter out packets where if d_id of the packet doesn't belong to the device when one is already assigned a port_id, only then this packet is dropped Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 902722dc4ce3..342a316d9341 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -522,10 +522,12 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) struct fcoe_crc_eof crc_eof; struct fc_frame *fp; struct fc_lport *vn_port; - struct fcoe_port *port; + struct fcoe_port *port, *phys_port; u8 *mac = NULL; u8 *dest_mac = NULL; struct fcoe_hdr *hp; + struct bnx2fc_interface *interface; + struct fcoe_ctlr *ctlr; fr = fcoe_dev_from_skb(skb); lport = fr->fr_dev; @@ -561,8 +563,19 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } + phys_port = lport_priv(lport); + interface = phys_port->priv; + ctlr = bnx2fc_to_ctlr(interface); + fh = fc_frame_header_get(fp); + if (ntoh24(&dest_mac[3]) != ntoh24(fh->fh_d_id)) { + BNX2FC_HBA_DBG(lport, "FC frame d_id mismatch with MAC %pM.\n", + dest_mac); + kfree_skb(skb); + return; + } + vn_port = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id)); if (vn_port) { port = lport_priv(vn_port); @@ -572,6 +585,14 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } } + if (ctlr->state) { + if (!ether_addr_equal(mac, ctlr->dest_addr)) { + BNX2FC_HBA_DBG(lport, "Wrong source address: mac:%pM dest_addr:%pM.\n", + mac, ctlr->dest_addr); + kfree_skb(skb); + return; + } + } if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && fh->fh_type == FC_TYPE_FCP) { /* Drop FCP data. We dont this in L2 path */ @@ -597,6 +618,18 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } + /* + * If the destination ID from the frame header does not match what we + * have on record for lport and the search for a NPIV port came up + * empty then this is not addressed to our port so simply drop it. + */ + if (lport->port_id != ntoh24(fh->fh_d_id) && !vn_port) { + BNX2FC_HBA_DBG(lport, "Dropping frame due to destination mismatch: lport->port_id=%x fh->d_id=%x.\n", + lport->port_id, ntoh24(fh->fh_d_id)); + kfree_skb(skb); + return; + } + stats = per_cpu_ptr(lport->stats, smp_processor_id()); stats->RxFrames++; stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; -- cgit v1.2.3-58-ga151 From de08f46b90d3b353f53d273604e6544186564e59 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:33 -0700 Subject: scsi: bnx2fc: Check for connection offload before sending RRQ. If the connection is not offloaded then the backpointers from the tgt pointer are undefined. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_els.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c index 68ca518d34b0..fee12c3d67cd 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_els.c +++ b/drivers/scsi/bnx2fc/bnx2fc_els.c @@ -61,13 +61,20 @@ int bnx2fc_send_rrq(struct bnx2fc_cmd *aborted_io_req) struct fc_els_rrq rrq; struct bnx2fc_rport *tgt = aborted_io_req->tgt; - struct fc_lport *lport = tgt->rdata->local_port; + struct fc_lport *lport = NULL; struct bnx2fc_els_cb_arg *cb_arg = NULL; - u32 sid = tgt->sid; - u32 r_a_tov = lport->r_a_tov; + u32 sid = 0; + u32 r_a_tov = 0; unsigned long start = jiffies; int rc; + if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) + return -EINVAL; + + lport = tgt->rdata->local_port; + sid = tgt->sid; + r_a_tov = lport->r_a_tov; + BNX2FC_ELS_DBG("Sending RRQ orig_xid = 0x%x\n", aborted_io_req->xid); memset(&rrq, 0, sizeof(rrq)); -- cgit v1.2.3-58-ga151 From 21144b80619fc953bcf3615252960f2cdf846883 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:34 -0700 Subject: scsi: bnx2fc: Update copyright for 2017. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h | 3 ++- drivers/scsi/bnx2fc/bnx2fc.h | 3 ++- drivers/scsi/bnx2fc/bnx2fc_constants.h | 3 ++- drivers/scsi/bnx2fc/bnx2fc_debug.c | 3 ++- drivers/scsi/bnx2fc/bnx2fc_debug.h | 3 ++- drivers/scsi/bnx2fc/bnx2fc_els.c | 3 ++- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 3 ++- drivers/scsi/bnx2fc/bnx2fc_hwi.c | 3 ++- drivers/scsi/bnx2fc/bnx2fc_io.c | 3 ++- drivers/scsi/bnx2fc/bnx2fc_tgt.c | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h b/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h index ac1c0b631aca..e4469df9c469 100644 --- a/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h +++ b/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h @@ -3,7 +3,8 @@ * session resources such as connection id and qp resources. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 1f424e40afdf..c19284040952 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -1,7 +1,8 @@ /* bnx2fc.h: QLogic Linux FCoE offload driver. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_constants.h b/drivers/scsi/bnx2fc/bnx2fc_constants.h index 5b20efb661a5..9ed150307a39 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_constants.h +++ b/drivers/scsi/bnx2fc/bnx2fc_constants.h @@ -3,7 +3,8 @@ * session resources such as connection id and qp resources. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.c b/drivers/scsi/bnx2fc/bnx2fc_debug.c index c9e0bc7fad3b..47ba3ba1e03b 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_debug.c +++ b/drivers/scsi/bnx2fc/bnx2fc_debug.c @@ -3,7 +3,8 @@ * session resources such as connection id and qp resources. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.h b/drivers/scsi/bnx2fc/bnx2fc_debug.h index 34fda3e04d27..76717acee3ab 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_debug.h +++ b/drivers/scsi/bnx2fc/bnx2fc_debug.h @@ -3,7 +3,8 @@ * session resources such as connection id and qp resources. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c index fee12c3d67cd..76e65a32f38c 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_els.c +++ b/drivers/scsi/bnx2fc/bnx2fc_els.c @@ -4,7 +4,8 @@ * and responses. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 342a316d9341..0d313a15e677 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -4,7 +4,8 @@ * FIP/FCoE packets, listen to link events etc. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c index 5ff9f89c17c7..913c750205ce 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c @@ -3,7 +3,8 @@ * with 57712 FCoE firmware. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 898461b146cc..6e8b9bea89fc 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -2,7 +2,8 @@ * IO manager and SCSI IO processing. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c index 739bfb62aff6..59a2dfbcbc69 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c @@ -3,7 +3,8 @@ * session resources such as connection id and qp resources. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit v1.2.3-58-ga151 From 59fb870f0ed4da64cbbc44f6a4dc1038be9f8904 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:35 -0700 Subject: scsi: bnx2fc: Adjust bnx2fc_npiv_create_vports for WWNNs from NVRAM that are zero. Some vports addresses stored in NVRAM may have zero for the WWNN. Adjust the WWNN that we'll use to be the same as the WWPN. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 0d313a15e677..71dd36756ca4 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2139,6 +2139,9 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport *lport, { struct fc_vport_identifiers vpid; uint i, created = 0; + u64 wwnn = 0; + char wwpn_str[32]; + char wwnn_str[32]; if (npiv_tbl->count > MAX_NPIV_ENTRIES) { BNX2FC_HBA_DBG(lport, "Exceeded count max of npiv table\n"); @@ -2157,11 +2160,23 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport *lport, vpid.disable = false; for (i = 0; i < npiv_tbl->count; i++) { - vpid.node_name = wwn_to_u64(npiv_tbl->wwnn[i]); + wwnn = wwn_to_u64(npiv_tbl->wwnn[i]); + if (wwnn == 0) { + /* + * If we get a 0 element from for the WWNN then assume + * the WWNN should be the same as the physical port. + */ + wwnn = lport->wwnn; + } + vpid.node_name = wwnn; vpid.port_name = wwn_to_u64(npiv_tbl->wwpn[i]); scnprintf(vpid.symbolic_name, sizeof(vpid.symbolic_name), "NPIV[%u]:%016llx-%016llx", created, vpid.port_name, vpid.node_name); + fcoe_wwn_to_str(vpid.node_name, wwnn_str, sizeof(wwnn_str)); + fcoe_wwn_to_str(vpid.port_name, wwpn_str, sizeof(wwpn_str)); + BNX2FC_HBA_DBG(lport, "Creating vport %s:%s.\n", wwnn_str, + wwpn_str); if (fc_vport_create(lport->host, 0, &vpid)) created++; else -- cgit v1.2.3-58-ga151 From 5c63daf67d4753f80883672d429ff7b6595ec2f4 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:36 -0700 Subject: scsi: bnx2fc: If IO is still in cleanup then do not return to SCSI layer. In eh_abort, driver is calling scsi->done() for a IO for which cleanup is pending. As the IO is outstanding with the firmware, it may do DMA associated with the IO. This may lead to heap corruption. Do not complete the IO for which cleanup is still pending. Return failure from eh_abort and let the SCSI-ml retry the IO. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_io.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 6e8b9bea89fc..5b6153f23f01 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1167,16 +1167,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd) printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) " "not on active_q\n", io_req->xid); /* - * This condition can happen only due to the FW bug, - * where we do not receive cleanup response from - * the FW. Handle this case gracefully by erroring - * back the IO request to SCSI-ml + * The IO is still with the FW. + * Return failure and let SCSI-ml retry eh_abort. */ - bnx2fc_scsi_done(io_req, DID_ABORT); - - kref_put(&io_req->refcount, bnx2fc_cmd_release); spin_unlock_bh(&tgt->tgt_lock); - return SUCCESS; + return FAILED; } /* -- cgit v1.2.3-58-ga151 From 5eddc3358f6e2e2e7c56a24a75566c90ca207303 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:37 -0700 Subject: scsi: bnx2fc: Make rport_terminate_io callback a NOOP. Do not call the stock libfc terminate rport i/o handler so we won't reset the libfc exchange manager and kill any outstanding discovery requests. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 71dd36756ca4..b1c105f4130d 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2573,6 +2573,11 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev) bnx2fc_hba_destroy(hba); } +static void bnx2fc_rport_terminate_io(struct fc_rport *rport) +{ + /* This is a no-op */ +} + /** * bnx2fc_fcoe_reset - Resets the fcoe * @@ -2909,7 +2914,7 @@ static struct fc_function_template bnx2fc_transport_function = { .issue_fc_host_lip = bnx2fc_fcoe_reset, - .terminate_rport_io = fc_rport_terminate_io, + .terminate_rport_io = bnx2fc_rport_terminate_io, .vport_create = bnx2fc_vport_create, .vport_delete = bnx2fc_vport_destroy, -- cgit v1.2.3-58-ga151 From 3655a286ca5c244612f586cbb034cab433a20a1a Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:38 -0700 Subject: scsi: bnx2fc: Update version number to 2.11.8. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc') diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index c19284040952..7e007e142aab 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -66,7 +66,7 @@ #include "bnx2fc_constants.h" #define BNX2FC_NAME "bnx2fc" -#define BNX2FC_VERSION "2.10.3" +#define BNX2FC_VERSION "2.11.8" #define PFX "bnx2fc: " -- cgit v1.2.3-58-ga151