1 // SPDX-License-Identifier: GPL-2.0-only
3 * QLogic iSCSI Offload Driver
4 * Copyright (c) 2016 Cavium Inc.
9 #include "qedi_iscsi.h"
12 static inline struct qedi_ctx
*qedi_dev_to_hba(struct device
*dev
)
14 struct Scsi_Host
*shost
= class_to_shost(dev
);
16 return iscsi_host_priv(shost
);
19 static ssize_t
qedi_show_port_state(struct device
*dev
,
20 struct device_attribute
*attr
,
23 struct qedi_ctx
*qedi
= qedi_dev_to_hba(dev
);
25 if (atomic_read(&qedi
->link_state
) == QEDI_LINK_UP
)
26 return sprintf(buf
, "Online\n");
28 return sprintf(buf
, "Linkdown\n");
31 static ssize_t
qedi_show_speed(struct device
*dev
,
32 struct device_attribute
*attr
, char *buf
)
34 struct qedi_ctx
*qedi
= qedi_dev_to_hba(dev
);
35 struct qed_link_output if_link
;
37 qedi_ops
->common
->get_link(qedi
->cdev
, &if_link
);
39 return sprintf(buf
, "%d Gbit\n", if_link
.speed
/ 1000);
42 static DEVICE_ATTR(port_state
, 0444, qedi_show_port_state
, NULL
);
43 static DEVICE_ATTR(speed
, 0444, qedi_show_speed
, NULL
);
45 struct device_attribute
*qedi_shost_attrs
[] = {