]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
scsi: qedf: Implement callback for bw_update
authorSaurav Kashyap <skashyap@marvell.com>
Thu, 16 Apr 2020 08:43:11 +0000 (01:43 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 17 Apr 2020 21:55:27 +0000 (17:55 -0400)
Add support for the common qed bw_update callback to qedf.  This function
is called whenever there is a reported change in the bandwidth and updates
corresponding values in sysfs.

Link: https://lore.kernel.org/r/20200416084314.18851-7-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qedf/qedf_main.c

index 89d5c12bf49cf77ddc68dcb761dab8f0032db815..50557c4dbf217d35887d2dd74c5c86c307795c5e 100644 (file)
@@ -509,6 +509,32 @@ static void qedf_update_link_speed(struct qedf_ctx *qedf,
        fc_host_supported_speeds(lport->host) = lport->link_supported_speeds;
 }
 
+static void qedf_bw_update(void *dev)
+{
+       struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
+       struct qed_link_output link;
+
+       /* Get the latest status of the link */
+       qed_ops->common->get_link(qedf->cdev, &link);
+
+       if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
+               QEDF_ERR(&qedf->dbg_ctx,
+                        "Ignore link update, driver getting unload.\n");
+               return;
+       }
+
+       if (link.link_up) {
+               if (atomic_read(&qedf->link_state) == QEDF_LINK_UP)
+                       qedf_update_link_speed(qedf, &link);
+               else
+                       QEDF_ERR(&qedf->dbg_ctx,
+                                "Ignore bw update, link is down.\n");
+
+       } else {
+               QEDF_ERR(&qedf->dbg_ctx, "link_up is not set.\n");
+       }
+}
+
 static void qedf_link_update(void *dev, struct qed_link_output *link)
 {
        struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
@@ -635,6 +661,7 @@ static u32 qedf_get_login_failures(void *cookie)
 static struct qed_fcoe_cb_ops qedf_cb_ops = {
        {
                .link_update = qedf_link_update,
+               .bw_update = qedf_bw_update,
                .dcbx_aen = qedf_dcbx_handler,
                .get_generic_tlv_data = qedf_get_generic_tlv_data,
                .get_protocol_tlv_data = qedf_get_protocol_tlv_data,