From 5185b32887d25699e5398d70f5ada945ea838d99 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:48 -0700 Subject: scsi: qedf: Enable basic FDMI information. For libfc to register FDMI attributes we need to do two things: - Set the appropriate fc_host attributes that libfc will use to form the FDMI registration commands - Set lport->fdmi_enabled to 1 Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index a5c97342fd5d..7313bda304e0 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -22,6 +22,7 @@ #include #include #include "qedf.h" +#include const struct qed_fcoe_ops *qed_ops; @@ -1334,6 +1335,59 @@ static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf) ether_addr_copy(qedf->ctlr.ctl_src_addr, qedf->mac); } +static void qedf_setup_fdmi(struct qedf_ctx *qedf) +{ + struct fc_lport *lport = qedf->lport; + struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); + u8 buf[8]; + int i, pos; + + /* + * fdmi_enabled needs to be set for libfc to execute FDMI registration. + */ + lport->fdmi_enabled = 1; + + /* + * Setup the necessary fc_host attributes to that will be used to fill + * in the FDMI information. + */ + + /* Get the PCI-e Device Serial Number Capability */ + pos = pci_find_ext_capability(qedf->pdev, PCI_EXT_CAP_ID_DSN); + if (pos) { + pos += 4; + for (i = 0; i < 8; i++) + pci_read_config_byte(qedf->pdev, pos + i, &buf[i]); + + snprintf(fc_host->serial_number, + sizeof(fc_host->serial_number), + "%02X%02X%02X%02X%02X%02X%02X%02X", + buf[7], buf[6], buf[5], buf[4], + buf[3], buf[2], buf[1], buf[0]); + } else + snprintf(fc_host->serial_number, + sizeof(fc_host->serial_number), "Unknown"); + + snprintf(fc_host->manufacturer, + sizeof(fc_host->manufacturer), "%s", "Cavium Inc."); + + snprintf(fc_host->model, sizeof(fc_host->model), "%s", "QL41000"); + + snprintf(fc_host->model_description, sizeof(fc_host->model_description), + "%s", "QLogic FastLinQ QL41000 Series 10/25/40/50GGbE Controller" + "(FCoE)"); + + snprintf(fc_host->hardware_version, sizeof(fc_host->hardware_version), + "Rev %d", qedf->pdev->revision); + + snprintf(fc_host->driver_version, sizeof(fc_host->driver_version), + "%s", QEDF_VERSION); + + snprintf(fc_host->firmware_version, sizeof(fc_host->firmware_version), + "%d.%d.%d.%d", FW_MAJOR_VERSION, FW_MINOR_VERSION, + FW_REVISION_VERSION, FW_ENGINEERING_VERSION); +} + static int qedf_lport_setup(struct qedf_ctx *qedf) { struct fc_lport *lport = qedf->lport; @@ -1377,6 +1431,8 @@ static int qedf_lport_setup(struct qedf_ctx *qedf) snprintf(fc_host_symbolic_name(lport->host), 256, "QLogic %s v%s", QEDF_MODULE_NAME, QEDF_VERSION); + qedf_setup_fdmi(qedf); + return 0; } -- cgit v1.2.3 From 12d0b12c57cb7bf0aebf48da79f277330c2552c3 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:49 -0700 Subject: scsi: qedf: Update copyright to 2017. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 2 +- drivers/scsi/qedf/drv_fcoe_fw_funcs.h | 2 +- drivers/scsi/qedf/drv_scsi_fw_funcs.c | 2 +- drivers/scsi/qedf/drv_scsi_fw_funcs.h | 2 +- drivers/scsi/qedf/qedf.h | 2 +- drivers/scsi/qedf/qedf_attr.c | 2 +- drivers/scsi/qedf/qedf_dbg.h | 2 +- drivers/scsi/qedf/qedf_debugfs.c | 2 +- drivers/scsi/qedf/qedf_els.c | 2 +- drivers/scsi/qedf/qedf_fip.c | 2 +- drivers/scsi/qedf/qedf_hsi.h | 2 +- drivers/scsi/qedf/qedf_io.c | 2 +- drivers/scsi/qedf/qedf_main.c | 2 +- drivers/scsi/qedf/qedf_version.h | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c index 8c65e3b034dc..7d91e53562f8 100644 --- a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c +++ b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c @@ -1,5 +1,5 @@ /* QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/drv_fcoe_fw_funcs.h b/drivers/scsi/qedf/drv_fcoe_fw_funcs.h index 617529b058f4..f9c50faa748e 100644 --- a/drivers/scsi/qedf/drv_fcoe_fw_funcs.h +++ b/drivers/scsi/qedf/drv_fcoe_fw_funcs.h @@ -1,5 +1,5 @@ /* QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/drv_scsi_fw_funcs.c b/drivers/scsi/qedf/drv_scsi_fw_funcs.c index 11e0cc082ec0..5d5095e3d96d 100644 --- a/drivers/scsi/qedf/drv_scsi_fw_funcs.c +++ b/drivers/scsi/qedf/drv_scsi_fw_funcs.c @@ -1,5 +1,5 @@ /* QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/drv_scsi_fw_funcs.h b/drivers/scsi/qedf/drv_scsi_fw_funcs.h index 9cb45410bc45..8fbe6e4d0b4f 100644 --- a/drivers/scsi/qedf/drv_scsi_fw_funcs.h +++ b/drivers/scsi/qedf/drv_scsi_fw_funcs.h @@ -1,5 +1,5 @@ /* QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h index 07ee88200e91..4d038926a455 100644 --- a/drivers/scsi/qedf/qedf.h +++ b/drivers/scsi/qedf/qedf.h @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c index 47720611ad2c..1349f8a66e29 100644 --- a/drivers/scsi/qedf/qedf_attr.c +++ b/drivers/scsi/qedf/qedf_attr.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_dbg.h b/drivers/scsi/qedf/qedf_dbg.h index 7d173f48a81e..50083cae84c3 100644 --- a/drivers/scsi/qedf/qedf_dbg.h +++ b/drivers/scsi/qedf/qedf_dbg.h @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_debugfs.c b/drivers/scsi/qedf/qedf_debugfs.c index 00a1d6405ebe..2b1ef3075e93 100644 --- a/drivers/scsi/qedf/qedf_debugfs.c +++ b/drivers/scsi/qedf/qedf_debugfs.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 QLogic Corporation + * Copyright (c) 2016-2017 QLogic Corporation * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index 90627033bde6..69a365da3891 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c index e10b91cc3c62..2dfb8179ed0e 100644 --- a/drivers/scsi/qedf/qedf_fip.c +++ b/drivers/scsi/qedf/qedf_fip.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_hsi.h b/drivers/scsi/qedf/qedf_hsi.h index dfd65dec2874..7faef80c5f7a 100644 --- a/drivers/scsi/qedf/qedf_hsi.h +++ b/drivers/scsi/qedf/qedf_hsi.h @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index 1d7f90d0adc1..ca9097bb7308 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 7313bda304e0..a3b040a18535 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of diff --git a/drivers/scsi/qedf/qedf_version.h b/drivers/scsi/qedf/qedf_version.h index 4ae5f537a440..d46c487a6e73 100644 --- a/drivers/scsi/qedf/qedf_version.h +++ b/drivers/scsi/qedf/qedf_version.h @@ -1,6 +1,6 @@ /* * QLogic FCoE Offload Driver - * Copyright (c) 2016 Cavium Inc. + * Copyright (c) 2016-2017 Cavium Inc. * * This software is available under the terms of the GNU General Public License * (GPL) Version 2, available from the file COPYING in the main directory of -- cgit v1.2.3 From 914fff102e00455bb867871e612b65524839d271 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:50 -0700 Subject: scsi: qedf: Honor qed_ops->common->set_fp_int() return code. We need to check the return code the set_fp_int() callback in case we were not allocated any fastpath interrupts or there was an error setting up the fastpath interrupts from the qed perspective. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index a3b040a18535..549598f75c63 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -2035,6 +2035,8 @@ static int qedf_setup_int(struct qedf_ctx *qedf) * Learn interrupt configuration */ rc = qed_ops->common->set_fp_int(qedf->cdev, num_online_cpus()); + if (rc <= 0) + return 0; rc = qed_ops->common->get_fp_int(qedf->cdev, &qedf->int_info); if (rc) -- cgit v1.2.3 From 53c51adbe6f83eba94fd39000f98cf4235a89e4c Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:51 -0700 Subject: scsi: qedf: Look at all descriptors when processing a clear virtual link. If there are multiple descriptors for a particular type in a clear virtual link we receive, we will not process it correctly but rather take the last value. This can cause us not to not flap the virtual link as the value from the descriptors that we compare against the our stored FCF or fc_lport values may not match. Change this to do a comparison when processing the each descriptor instead of at the end and then set a bool if we need to do the reset. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_fip.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c index 2dfb8179ed0e..64b04f245e15 100644 --- a/drivers/scsi/qedf/qedf_fip.c +++ b/drivers/scsi/qedf/qedf_fip.c @@ -156,10 +156,9 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) struct fip_wwn_desc *wp; struct fip_vn_desc *vp; size_t rlen, dlen; - uint32_t cvl_port_id; - __u8 cvl_mac[ETH_ALEN]; u16 op; u8 sub; + bool do_reset = false; eth_hdr = (struct ethhdr *)skb_mac_header(skb); fiph = (struct fip_header *) ((void *)skb->data + 2 * ETH_ALEN + 2); @@ -190,8 +189,6 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) return; } - cvl_port_id = 0; - memset(cvl_mac, 0, ETH_ALEN); /* * We need to loop through the CVL descriptors to determine * if we want to reset the fcoe link @@ -205,7 +202,9 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) mp = (struct fip_mac_desc *)desc; QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, "fd_mac=%pM\n", mp->fd_mac); - ether_addr_copy(cvl_mac, mp->fd_mac); + if (ether_addr_equal(mp->fd_mac, + qedf->ctlr.sel_fcf->fcf_mac)) + do_reset = true; break; case FIP_DT_NAME: wp = (struct fip_wwn_desc *)desc; @@ -217,7 +216,9 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) vp = (struct fip_vn_desc *)desc; QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, "fd_fc_id=%x.\n", ntoh24(vp->fd_fc_id)); - cvl_port_id = ntoh24(vp->fd_fc_id); + if (ntoh24(vp->fd_fc_id) == + qedf->lport->port_id) + do_reset = true; break; default: /* Ignore anything else */ @@ -228,11 +229,8 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) } QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, - "cvl_port_id=%06x cvl_mac=%pM.\n", cvl_port_id, - cvl_mac); - if (cvl_port_id == qedf->lport->port_id && - ether_addr_equal(cvl_mac, - qedf->ctlr.sel_fcf->fcf_mac)) { + "do_reset=%d.\n", do_reset); + if (do_reset) { fcoe_ctlr_link_down(&qedf->ctlr); qedf_wait_for_upload(qedf); fcoe_ctlr_link_up(&qedf->ctlr); -- cgit v1.2.3 From ff34e8e84fbbd3e3f31a4d54cc0501aeaa155d43 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:52 -0700 Subject: scsi: qedf: Check that fcport is offloaded before dereferencing pointers in initiate_abts|cleanup. If an fcport is not offloaded then the members of the qedf_rport struct are undefined which may cause a system crash. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_io.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index ca9097bb7308..db160046f3e0 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -1476,8 +1476,8 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) { struct fc_lport *lport; struct qedf_rport *fcport = io_req->fcport; - struct fc_rport_priv *rdata = fcport->rdata; - struct qedf_ctx *qedf = fcport->qedf; + struct fc_rport_priv *rdata; + struct qedf_ctx *qedf; u16 xid; u32 r_a_tov = 0; int rc = 0; @@ -1485,15 +1485,18 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) struct fcoe_wqe *sqe; u16 sqe_idx; - r_a_tov = rdata->r_a_tov; - lport = qedf->lport; - + /* Sanity check qedf_rport before dereferencing any pointers */ if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { - QEDF_ERR(&(qedf->dbg_ctx), "tgt not offloaded\n"); + QEDF_ERR(NULL, "tgt not offloaded\n"); rc = 1; goto abts_err; } + rdata = fcport->rdata; + r_a_tov = rdata->r_a_tov; + qedf = fcport->qedf; + lport = qedf->lport; + if (lport->state != LPORT_ST_READY || !(lport->link_up)) { QEDF_ERR(&(qedf->dbg_ctx), "link is not ready\n"); rc = 1; @@ -1729,6 +1732,13 @@ int qedf_initiate_cleanup(struct qedf_ioreq *io_req, return SUCCESS; } + /* Sanity check qedf_rport before dereferencing any pointers */ + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { + QEDF_ERR(NULL, "tgt not offloaded\n"); + rc = 1; + return SUCCESS; + } + qedf = fcport->qedf; if (!qedf) { QEDF_ERR(NULL, "qedf is NULL.\n"); -- cgit v1.2.3 From c07c54b0cbb740dbc2f7fba247049bd9e25ac08e Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:53 -0700 Subject: scsi: qedf: Add fka_period SCSI host attribute to show fip keep alive period. Expose this information for interested applications. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_attr.c | 57 ++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c index 1349f8a66e29..fa6727685627 100644 --- a/drivers/scsi/qedf/qedf_attr.c +++ b/drivers/scsi/qedf/qedf_attr.c @@ -8,6 +8,25 @@ */ #include "qedf.h" +inline bool qedf_is_vport(struct qedf_ctx *qedf) +{ + return qedf->lport->vport != NULL; +} + +/* Get base qedf for physical port from vport */ +static struct qedf_ctx *qedf_get_base_qedf(struct qedf_ctx *qedf) +{ + struct fc_lport *lport; + struct fc_lport *base_lport; + + if (!(qedf_is_vport(qedf))) + return NULL; + + lport = qedf->lport; + base_lport = shost_priv(vport_to_shost(lport->vport)); + return lport_priv(base_lport); +} + static ssize_t qedf_fcoe_mac_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -26,34 +45,34 @@ qedf_fcoe_mac_show(struct device *dev, return scnprintf(buf, PAGE_SIZE, "%pM\n", fcoe_mac); } +static ssize_t +qedf_fka_period_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fc_lport *lport = shost_priv(class_to_shost(dev)); + struct qedf_ctx *qedf = lport_priv(lport); + int fka_period = -1; + + if (qedf_is_vport(qedf)) + qedf = qedf_get_base_qedf(qedf); + + if (qedf->ctlr.sel_fcf) + fka_period = qedf->ctlr.sel_fcf->fka_period; + + return scnprintf(buf, PAGE_SIZE, "%d\n", fka_period); +} + static DEVICE_ATTR(fcoe_mac, S_IRUGO, qedf_fcoe_mac_show, NULL); +static DEVICE_ATTR(fka_period, S_IRUGO, qedf_fka_period_show, NULL); struct device_attribute *qedf_host_attrs[] = { &dev_attr_fcoe_mac, + &dev_attr_fka_period, NULL, }; extern const struct qed_fcoe_ops *qed_ops; -inline bool qedf_is_vport(struct qedf_ctx *qedf) -{ - return (!(qedf->lport->vport == NULL)); -} - -/* Get base qedf for physical port from vport */ -static struct qedf_ctx *qedf_get_base_qedf(struct qedf_ctx *qedf) -{ - struct fc_lport *lport; - struct fc_lport *base_lport; - - if (!(qedf_is_vport(qedf))) - return NULL; - - lport = qedf->lport; - base_lport = shost_priv(vport_to_shost(lport->vport)); - return (struct qedf_ctx *)(lport_priv(base_lport)); -} - void qedf_capture_grc_dump(struct qedf_ctx *qedf) { struct qedf_ctx *base_qedf; -- cgit v1.2.3 From 2b82a62f52e647944446a3b85a4131b279c078fb Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:54 -0700 Subject: scsi: qedf: Set qed logging level to QED_LEVEL_NOTICE. Reduce the logging level we set for qed messages pertaining to this PCI function so that unnecessary messages are not printed in the kernel message log. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 549598f75c63..7753fc5ab65b 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -95,7 +95,7 @@ module_param_named(dp_module, qedf_dp_module, uint, S_IRUGO); MODULE_PARM_DESC(dp_module, " bit flags control for verbose printk passed " "qed module during probe."); -static uint qedf_dp_level; +static uint qedf_dp_level = QED_LEVEL_NOTICE; module_param_named(dp_level, qedf_dp_level, uint, S_IRUGO); MODULE_PARM_DESC(dp_level, " printk verbosity control passed to qed module " "during probe (0-3: 0 more verbose)."); -- cgit v1.2.3 From 5cf446d2aa4b92a1c1f079416e17fa9edee76ef8 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:55 -0700 Subject: scsi: qedf: Use same logic for SCSI host reset and FC lip_reset. We should be using the same logic to do a soft reset of the FCoE function whether it is initiated via sg_reset or the fc_host issue_lip attribute. Refactor the host reset and fcoe reset handlers to use the preferred logic which is currently contained in qedf_eh_host_reset(). Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 7753fc5ab65b..6813b9be994e 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -640,27 +640,17 @@ void qedf_wait_for_upload(struct qedf_ctx *qedf) } } -/* Reset the host by gracefully logging out and then logging back in */ -static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd) +/* Performs soft reset of qedf_ctx by simulating a link down/up */ +static void qedf_ctx_soft_reset(struct fc_lport *lport) { - struct fc_lport *lport; struct qedf_ctx *qedf; - lport = shost_priv(sc_cmd->device->host); - if (lport->vport) { QEDF_ERR(NULL, "Cannot issue host reset on NPIV port.\n"); - return SUCCESS; + return; } - qedf = (struct qedf_ctx *)lport_priv(lport); - - if (atomic_read(&qedf->link_state) == QEDF_LINK_DOWN || - test_bit(QEDF_UNLOADING, &qedf->flags) || - test_bit(QEDF_DBG_STOP_IO, &qedf->flags)) - return FAILED; - - QEDF_ERR(&(qedf->dbg_ctx), "HOST RESET Issued..."); + qedf = lport_priv(lport); /* For host reset, essentially do a soft link up/down */ atomic_set(&qedf->link_state, QEDF_LINK_DOWN); @@ -672,6 +662,24 @@ static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd) qedf->vlan_id = 0; queue_delayed_work(qedf->link_update_wq, &qedf->link_update, 0); +} + +/* Reset the host by gracefully logging out and then logging back in */ +static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd) +{ + struct fc_lport *lport; + struct qedf_ctx *qedf; + + lport = shost_priv(sc_cmd->device->host); + qedf = lport_priv(lport); + + if (atomic_read(&qedf->link_state) == QEDF_LINK_DOWN || + test_bit(QEDF_UNLOADING, &qedf->flags)) + return FAILED; + + QEDF_ERR(&(qedf->dbg_ctx), "HOST RESET Issued..."); + + qedf_ctx_soft_reset(lport); return SUCCESS; } @@ -1669,8 +1677,7 @@ static int qedf_fcoe_reset(struct Scsi_Host *shost) { struct fc_lport *lport = shost_priv(shost); - fc_fabric_logoff(lport); - fc_fabric_login(lport); + qedf_ctx_soft_reset(lport); return 0; } -- cgit v1.2.3 From b09fdc3aac6acc20587713e306692b12d31a2008 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:56 -0700 Subject: scsi: qedf: Add bus_reset No-op. We need to add a bus reset no-op as without it some of the LUNs attached to a vport may go offline when the error handler escalates to host reset due to not having a bus reset handler in the driver. What happens is we escalate to host reset which does a soft link down/link up to reset the adapter. However with multiple vports attached it's been observed that if the vports do log back into the target within 5 seconds, the SCSI layer offlines the devices most likely due to a TUR timing out to verify that the device is online. Adding a bus reset handler will cause the TUR to be sent after the bus reset handler where the devices will still be online if the bus reset is initiated by sg_reset (which is the case in the test that was failing). The bus reset will succeed and not needlessly bring the device offline/online. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 6813b9be994e..ef0dc566d70f 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -628,6 +628,16 @@ static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) return qedf_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET); } +static int qedf_eh_bus_reset(struct scsi_cmnd *sc_cmd) +{ + QEDF_ERR(NULL, "BUS RESET Issued...\n"); + /* + * Essentially a no-op but return SUCCESS to prevent + * unnecessary escalation to the host reset handler. + */ + return SUCCESS; +} + void qedf_wait_for_upload(struct qedf_ctx *qedf) { while (1) { @@ -705,6 +715,7 @@ static struct scsi_host_template qedf_host_template = { .eh_abort_handler = qedf_eh_abort, .eh_device_reset_handler = qedf_eh_device_reset, /* lun reset */ .eh_target_reset_handler = qedf_eh_target_reset, /* target reset */ + .eh_bus_reset_handler = qedf_eh_bus_reset, .eh_host_reset_handler = qedf_eh_host_reset, .slave_configure = qedf_slave_configure, .dma_boundary = QED_HW_DMA_BOUNDARY, -- cgit v1.2.3 From 384d5a9b412ea0fb60f999c13d39a1f007d87730 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:57 -0700 Subject: scsi: qedf: Add non-offload receive filters. Drop invalid or unexpected FCoE frames that come into the non-offload path since the FCoE firmware would not do the filtering for us. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index ef0dc566d70f..b7d17e177cf0 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -2087,6 +2087,8 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, u8 *dest_mac = NULL; struct fcoe_hdr *hp; struct qedf_rport *fcport; + struct fc_lport *vn_port; + u32 f_ctl; lport = qedf->lport; if (lport == NULL || lport->state == LPORT_ST_DISABLED) { @@ -2123,6 +2125,10 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, fh = fc_frame_header_get(fp); + /* + * Invalid frame filters. + */ + 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 */ @@ -2148,6 +2154,43 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, return; } + if (ntoh24(&dest_mac[3]) != ntoh24(fh->fh_d_id)) { + QEDF_ERR(&(qedf->dbg_ctx), "FC frame d_id mismatch with MAC %pM.\n", + dest_mac); + return; + } + + if (qedf->ctlr.state) { + if (!ether_addr_equal(mac, qedf->ctlr.dest_addr)) { + QEDF_ERR(&(qedf->dbg_ctx), "Wrong source address mac:%pM dest_addr:%pM.\n", + mac, qedf->ctlr.dest_addr); + kfree_skb(skb); + return; + } + } + + vn_port = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id)); + + /* + * 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) { + QEDF_ERR(&(qedf->dbg_ctx), "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; + } + + f_ctl = ntoh24(fh->fh_f_ctl); + if ((fh->fh_type == FC_TYPE_BLS) && (f_ctl & FC_FC_SEQ_CTX) && + (f_ctl & FC_FC_EX_CTX)) { + /* Drop incoming ABTS response that has both SEQ/EX CTX set */ + kfree_skb(skb); + return; + } + /* * If a connection is uploading, drop incoming FCoE frames as there * is a small window where we could try to return a frame while libfc -- cgit v1.2.3 From 57a3548a0164299d548b534806e436e5544997ea Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:58 -0700 Subject: scsi: qedf: Fixup unnecessary parantheses around test_bit operations. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_els.c | 6 +++--- drivers/scsi/qedf/qedf_io.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index 69a365da3891..eb07f1de8afa 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -44,7 +44,7 @@ static int qedf_initiate_els(struct qedf_rport *fcport, unsigned int op, goto els_err; } - if (!(test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags))) { + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(&(qedf->dbg_ctx), "els 0x%x: fcport not ready\n", op); rc = -EINVAL; goto els_err; @@ -225,7 +225,7 @@ int qedf_send_rrq(struct qedf_ioreq *aborted_io_req) fcport = aborted_io_req->fcport; /* Check that fcport is still offloaded */ - if (!(test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags))) { + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(NULL, "fcport is no longer offloaded.\n"); return -EINVAL; } @@ -550,7 +550,7 @@ static int qedf_send_srr(struct qedf_ioreq *orig_io_req, u32 offset, u8 r_ctl) fcport = orig_io_req->fcport; /* Check that fcport is still offloaded */ - if (!(test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags))) { + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(NULL, "fcport is no longer offloaded.\n"); return -EINVAL; } diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index db160046f3e0..ea37c78418d7 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -1847,7 +1847,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, return FAILED; } - if (!(test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags))) { + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n"); rc = FAILED; return FAILED; -- cgit v1.2.3 From f7e8d57be143523189543dfaf183af92b4c85204 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:33:59 -0700 Subject: scsi: qedf: Move some prints to a debug level so they do not print when no debugging is enabled. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b7d17e177cf0..4135354acea8 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -442,7 +442,8 @@ static void qedf_link_update(void *dev, struct qed_link_output *link) qedf_update_link_speed(qedf, link); if (atomic_read(&qedf->dcbx) == QEDF_DCBX_DONE) { - QEDF_ERR(&(qedf->dbg_ctx), "DCBx done.\n"); + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, + "DCBx done.\n"); if (atomic_read(&qedf->link_down_tmo_valid) > 0) queue_delayed_work(qedf->link_update_wq, &qedf->link_recovery, 0); @@ -2155,14 +2156,15 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, } if (ntoh24(&dest_mac[3]) != ntoh24(fh->fh_d_id)) { - QEDF_ERR(&(qedf->dbg_ctx), "FC frame d_id mismatch with MAC %pM.\n", - dest_mac); + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, + "FC frame d_id mismatch with MAC %pM.\n", dest_mac); return; } if (qedf->ctlr.state) { if (!ether_addr_equal(mac, qedf->ctlr.dest_addr)) { - QEDF_ERR(&(qedf->dbg_ctx), "Wrong source address mac:%pM dest_addr:%pM.\n", + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, + "Wrong source address: mac:%pM dest_addr:%pM.\n", mac, qedf->ctlr.dest_addr); kfree_skb(skb); return; @@ -2177,7 +2179,8 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, * empty then this is not addressed to our port so simply drop it. */ if (lport->port_id != ntoh24(fh->fh_d_id) && !vn_port) { - QEDF_ERR(&(qedf->dbg_ctx), "Dropping frame due to destination mismatch: lport->port_id=%x fh->d_id=%x.\n", + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, + "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; -- cgit v1.2.3 From a7746f1e01d05066135a3c3ac7e8a857cab68ba7 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:34:00 -0700 Subject: scsi: qedf: Change cmd_per_lun in scsi_host_template to 32 to increase performance. Increase the default number of commands that the driver tells the SCSI mid-layer it can do to increase the default performance of the driver. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 4135354acea8..ed4bca1231a2 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -708,7 +708,7 @@ static struct scsi_host_template qedf_host_template = { .module = THIS_MODULE, .name = QEDF_MODULE_NAME, .this_id = -1, - .cmd_per_lun = 3, + .cmd_per_lun = 32, .use_clustering = ENABLE_CLUSTERING, .max_sectors = 0xffff, .queuecommand = qedf_queuecommand, -- cgit v1.2.3 From 6088cfaafba205139f57aaffd8480c2f8b141dca Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:34:01 -0700 Subject: scsi: qedf: Add change_queue_depth member to scsi_host_template(). Add the change_queue_depth member to our SCSI host template so the queue depth of devices attached to qedf can be changed dynamically. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index ed4bca1231a2..5842676e3b71 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -722,6 +722,7 @@ static struct scsi_host_template qedf_host_template = { .dma_boundary = QED_HW_DMA_BOUNDARY, .sg_tablesize = QEDF_MAX_BDS_PER_CMD, .can_queue = FCOE_PARAMS_NUM_TASKS, + .change_queue_depth = scsi_change_queue_depth, }; static int qedf_get_paged_crc_eof(struct sk_buff *skb, int tlen) -- cgit v1.2.3 From e2e2c7da4b7b1c45479483e17bd8fbad628ffad1 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 31 May 2017 06:34:02 -0700 Subject: scsi: qedf: Update version number to 8.18.22.0. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_version.h b/drivers/scsi/qedf/qedf_version.h index d46c487a6e73..6fa442061c32 100644 --- a/drivers/scsi/qedf/qedf_version.h +++ b/drivers/scsi/qedf/qedf_version.h @@ -7,9 +7,9 @@ * this source tree. */ -#define QEDF_VERSION "8.10.7.0" +#define QEDF_VERSION "8.18.22.0" #define QEDF_DRIVER_MAJOR_VER 8 -#define QEDF_DRIVER_MINOR_VER 10 -#define QEDF_DRIVER_REV_VER 7 +#define QEDF_DRIVER_MINOR_VER 18 +#define QEDF_DRIVER_REV_VER 22 #define QEDF_DRIVER_ENG_VER 0 -- cgit v1.2.3 From 16a611154dc11d73dfa99ae2089a1f1ef45db7f8 Mon Sep 17 00:00:00 2001 From: "Dupuis, Chad" Date: Fri, 2 Jun 2017 12:02:05 -0700 Subject: scsi: qedf: Check if sense buffer has been allocated during completion sc_cmd->sense_buffer is not guaranteed to be allocated so we need to sc_cmd->check if the pointer is NULL before trying to copy anything into it. Fixes the crash: [ 143.793176] [0000:00:00.0]:[qedf_eh_device_reset:626]: LUN RESET Issued... [ 143.802996] BUG: unable to handle kernel NULL pointer dereference at (null) [ 143.803063] IP: qedf_parse_fcp_rsp+0xe2/0x290 [qedf] [ 143.803077] PGD 0 [ 143.803078] P4D 0 [ 143.803103] Oops: 0002 [#1] SMP [ 143.803115] Modules linked in: msr(E) ebtable_filter(E) ebtables(E) ip6table_filter(E) ip6_tables(E) iptable_filter(E) ip_tables(E) x_tables(E) raw(E) scsi_transport_iscsi(E) br_netfilter(E) bridge(E) iscsi_ibft(E) iscsi_boot_sysfs(E) intel_rapl(E) sb_edac(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) coretemp(E) kvm_intel(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) xfs(E) ghash_clmulni_intel(E) pcbc(E) aesni_intel(E) aes_x86_64(E) crypto_simd(E) ipmi_ssif(E) glue_helper(E) iTCO_wdt(E) iTCO_vendor_support(E) lpc_ich(E) ipmi_si(E) pcspkr(E) hpilo(E) ioatdma(E) cryptd(E) ipmi_devintf(E) hpwdt(E) mfd_core(E) shpchp(E) dca(E) thermal(E) pcc_cpufreq(E) ipmi_msghandler(E) acpi_cpufreq(E) af_packet(E) btrfs(E) xor(E) raid6_pq(E) sr_mod(E) cdrom(E) ata_generic(E) sd_mod(E) 8021q(E) garp(E) [ 143.803302] stp(E) llc(E) mrp(E) bnx2fc(E) cnic(E) uio(E) mgag200(E) ata_piix(E) i2c_algo_bit(E) drm_kms_helper(E) syscopyarea(E) sysfillrect(E) sysimgblt(E) ahci(E) fb_sys_fops(E) bnx2x(E) qedf(E) serio_raw(E) libahci(E) ttm(E) uhci_hcd(E) ehci_pci(E) qed(E) mdio(E) libcrc32c(E) ehci_hcd(E) crc32c_intel(E) drm(E) libata(E) usbcore(E) tg3(E) ptp(E) hpsa(E) pps_core(E) scsi_transport_sas(E) libphy(E) wmi(E) button(E) fcoe(E) libfcoe(E) libfc(E) scsi_transport_fc(E) sg(E) dm_multipath(E) dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) scsi_dh_alua(E) scsi_mod(E) autofs4(E) [ 143.803438] CPU: 31 PID: 494 Comm: kworker/31:2 Tainted: G E 4.12.0-rc1-69-default+ #1 [ 143.803461] Hardware name: HP ProLiant DL380p Gen8, BIOS P70 08/20/2012 [ 143.803480] Workqueue: qedf_io_wq qedf_fp_io_handler [qedf] [ 143.803496] task: ffff8804181a0000 task.stack: ffffc90003b64000 [ 143.803514] RIP: 0010:qedf_parse_fcp_rsp+0xe2/0x290 [qedf] [ 143.803529] RSP: 0018:ffffc90003b67dc8 EFLAGS: 00010246 [ 143.803544] RAX: 0000000000000000 RBX: ffff880401abdd48 RCX: 000000000000000c [ 143.803563] RDX: 0000000000000060 RSI: ffffffffa039c740 RDI: 0000000000000000 [ 143.803581] RBP: ffffc90003b67df0 R08: ffffffffa039dba8 R09: 0000000000000000 [ 143.803600] R10: 0000000000000000 R11: 0000000000000018 R12: 0000000000000000 [ 143.803619] R13: ffff88040ac80bc8 R14: 0000000000000008 R15: ffff880407c14008 [ 143.803638] FS: 0000000000000000(0000) GS:ffff88043f7c0000(0000) knlGS:0000000000000000 [ 143.804360] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 143.805065] CR2: 0000000000000000 CR3: 0000000001c09000 CR4: 00000000000406e0 [ 143.805753] Call Trace: [ 143.806436] qedf_process_tmf_compl+0x19/0x30 [qedf] [ 143.807124] qedf_process_cqe+0x265/0x280 [qedf] [ 143.807800] qedf_fp_io_handler+0x26/0x60 [qedf] [ 143.808469] process_one_work+0x138/0x370 [ 143.809133] worker_thread+0x4d/0x3b0 [ 143.809797] kthread+0x109/0x140 [ 143.810451] ? rescuer_thread+0x320/0x320 [ 143.811100] ? kthread_park+0x60/0x60 [ 143.811743] ret_from_fork+0x2c/0x40 Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_io.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index ea37c78418d7..ded386036c27 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -1041,10 +1041,13 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, fcp_sns_len = SCSI_SENSE_BUFFERSIZE; } - memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - if (fcp_sns_len) - memcpy(sc_cmd->sense_buffer, sense_data, - fcp_sns_len); + /* The sense buffer can be NULL for TMF commands */ + if (sc_cmd->sense_buffer) { + memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); + if (fcp_sns_len) + memcpy(sc_cmd->sense_buffer, sense_data, + fcp_sns_len); + } } static void qedf_unmap_sg_list(struct qedf_ctx *qedf, struct qedf_ioreq *io_req) -- cgit v1.2.3 From 3a240b21b5ccb77fcbece7a617f333cd31097776 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 11 Jun 2017 08:16:02 +0200 Subject: scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' We should return -ENOMEM in case of memory allocation error, as done elsewhere in this function. [mkp: fixed typo] Fixes: 61d8658b4a435 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.") Signed-off-by: Christophe JAILLET Acked-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 5842676e3b71..f97dd0f98543 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -2671,8 +2671,9 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) qedf->global_queues[i] = kzalloc(sizeof(struct global_queue), GFP_KERNEL); if (!qedf->global_queues[i]) { - QEDF_WARN(&(qedf->dbg_ctx), "Unable to allocation " + QEDF_WARN(&(qedf->dbg_ctx), "Unable to allocate " "global queue %d.\n", i); + status = -ENOMEM; goto mem_alloc_failure; } -- cgit v1.2.3 From c4d6ffc8465f4225e79ee58275fa1a61def991cc Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 11 Jun 2017 08:16:03 +0200 Subject: scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity. Replace some 'dma_alloc_coherent+memset' by some quivalent 'dma_zalloc_coherent' in order to reduce code verbosity Signed-off-by: Christophe JAILLET Acked-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index f97dd0f98543..c2f1a71a724e 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -972,17 +972,16 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport) sizeof(void *); fcport->sq_pbl_size = fcport->sq_pbl_size + QEDF_PAGE_SIZE; - fcport->sq = dma_alloc_coherent(&qedf->pdev->dev, fcport->sq_mem_size, - &fcport->sq_dma, GFP_KERNEL); + fcport->sq = dma_zalloc_coherent(&qedf->pdev->dev, + fcport->sq_mem_size, &fcport->sq_dma, GFP_KERNEL); if (!fcport->sq) { QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send " "queue.\n"); rval = 1; goto out; } - memset(fcport->sq, 0, fcport->sq_mem_size); - fcport->sq_pbl = dma_alloc_coherent(&qedf->pdev->dev, + fcport->sq_pbl = dma_zalloc_coherent(&qedf->pdev->dev, fcport->sq_pbl_size, &fcport->sq_pbl_dma, GFP_KERNEL); if (!fcport->sq_pbl) { QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send " @@ -990,7 +989,6 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport) rval = 1; goto out_free_sq; } - memset(fcport->sq_pbl, 0, fcport->sq_pbl_size); /* Create PBL */ num_pages = fcport->sq_mem_size / QEDF_PAGE_SIZE; @@ -2597,14 +2595,13 @@ static int qedf_alloc_bdq(struct qedf_ctx *qedf) } /* Allocate list of PBL pages */ - qedf->bdq_pbl_list = dma_alloc_coherent(&qedf->pdev->dev, + qedf->bdq_pbl_list = dma_zalloc_coherent(&qedf->pdev->dev, QEDF_PAGE_SIZE, &qedf->bdq_pbl_list_dma, GFP_KERNEL); if (!qedf->bdq_pbl_list) { QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL " "pages.\n"); return -ENOMEM; } - memset(qedf->bdq_pbl_list, 0, QEDF_PAGE_SIZE); /* * Now populate PBL list with pages that contain pointers to the @@ -2689,7 +2686,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) ALIGN(qedf->global_queues[i]->cq_pbl_size, QEDF_PAGE_SIZE); qedf->global_queues[i]->cq = - dma_alloc_coherent(&qedf->pdev->dev, + dma_zalloc_coherent(&qedf->pdev->dev, qedf->global_queues[i]->cq_mem_size, &qedf->global_queues[i]->cq_dma, GFP_KERNEL); @@ -2699,11 +2696,9 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) status = -ENOMEM; goto mem_alloc_failure; } - memset(qedf->global_queues[i]->cq, 0, - qedf->global_queues[i]->cq_mem_size); qedf->global_queues[i]->cq_pbl = - dma_alloc_coherent(&qedf->pdev->dev, + dma_zalloc_coherent(&qedf->pdev->dev, qedf->global_queues[i]->cq_pbl_size, &qedf->global_queues[i]->cq_pbl_dma, GFP_KERNEL); @@ -2713,8 +2708,6 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) status = -ENOMEM; goto mem_alloc_failure; } - memset(qedf->global_queues[i]->cq_pbl, 0, - qedf->global_queues[i]->cq_pbl_size); /* Create PBL */ num_pages = qedf->global_queues[i]->cq_mem_size / -- cgit v1.2.3 From 32eebb317fba6f29dfd3be677b0fc2b63fa08131 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 11 Jun 2017 08:16:04 +0200 Subject: scsi: qedf: Merge a few quoted strings split across lines Merge some quoted strings to improve readability and to save some lines of code. Signed-off-by: Christophe JAILLET Acked-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'drivers/scsi/qedf') diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index c2f1a71a724e..6149ea004fa1 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -975,8 +975,7 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport) fcport->sq = dma_zalloc_coherent(&qedf->pdev->dev, fcport->sq_mem_size, &fcport->sq_dma, GFP_KERNEL); if (!fcport->sq) { - QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send " - "queue.\n"); + QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send queue.\n"); rval = 1; goto out; } @@ -984,8 +983,7 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport) fcport->sq_pbl = dma_zalloc_coherent(&qedf->pdev->dev, fcport->sq_pbl_size, &fcport->sq_pbl_dma, GFP_KERNEL); if (!fcport->sq_pbl) { - QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send " - "queue PBL.\n"); + QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send queue PBL.\n"); rval = 1; goto out_free_sq; } @@ -2598,8 +2596,7 @@ static int qedf_alloc_bdq(struct qedf_ctx *qedf) qedf->bdq_pbl_list = dma_zalloc_coherent(&qedf->pdev->dev, QEDF_PAGE_SIZE, &qedf->bdq_pbl_list_dma, GFP_KERNEL); if (!qedf->bdq_pbl_list) { - QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL " - "pages.\n"); + QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL pages.\n"); return -ENOMEM; } @@ -2691,8 +2688,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) &qedf->global_queues[i]->cq_dma, GFP_KERNEL); if (!qedf->global_queues[i]->cq) { - QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate " - "cq.\n"); + QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate cq.\n"); status = -ENOMEM; goto mem_alloc_failure; } @@ -2703,8 +2699,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) &qedf->global_queues[i]->cq_pbl_dma, GFP_KERNEL); if (!qedf->global_queues[i]->cq_pbl) { - QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate " - "cq PBL.\n"); + QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate cq PBL.\n"); status = -ENOMEM; goto mem_alloc_failure; } @@ -2800,8 +2795,7 @@ static int qedf_set_fcoe_pf_param(struct qedf_ctx *qedf) cq_mem_size = ALIGN(cq_mem_size, QEDF_PAGE_SIZE); cq_num_entries = cq_mem_size / sizeof(struct fcoe_cqe); - memset(&(qedf->pf_params), 0, - sizeof(qedf->pf_params)); + memset(&(qedf->pf_params), 0, sizeof(qedf->pf_params)); /* Setup the value for fcoe PF */ qedf->pf_params.fcoe_pf_params.num_cons = QEDF_MAX_SESSIONS; -- cgit v1.2.3