2 * QLogic iSCSI Offload Driver
3 * Copyright (c) 2016 Cavium Inc.
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
12 #include "qedi_iscsi.h"
15 static inline struct qedi_ctx
*qedi_dev_to_hba(struct device
*dev
)
17 struct Scsi_Host
*shost
= class_to_shost(dev
);
19 return iscsi_host_priv(shost
);
22 static ssize_t
qedi_show_port_state(struct device
*dev
,
23 struct device_attribute
*attr
,
26 struct qedi_ctx
*qedi
= qedi_dev_to_hba(dev
);
28 if (atomic_read(&qedi
->link_state
) == QEDI_LINK_UP
)
29 return sprintf(buf
, "Online\n");
31 return sprintf(buf
, "Linkdown\n");
34 static ssize_t
qedi_show_speed(struct device
*dev
,
35 struct device_attribute
*attr
, char *buf
)
37 struct qedi_ctx
*qedi
= qedi_dev_to_hba(dev
);
38 struct qed_link_output if_link
;
40 qedi_ops
->common
->get_link(qedi
->cdev
, &if_link
);
42 return sprintf(buf
, "%d Gbit\n", if_link
.speed
/ 1000);
45 static DEVICE_ATTR(port_state
, 0444, qedi_show_port_state
, NULL
);
46 static DEVICE_ATTR(speed
, 0444, qedi_show_speed
, NULL
);
48 struct device_attribute
*qedi_shost_attrs
[] = {