mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 18:00:53 +07:00
3287e96af0
Based on 1 normalized pattern(s): 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 this source tree extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 35 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190531190115.411886531@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* QLogic iSCSI Offload Driver
|
|
* Copyright (c) 2016 Cavium Inc.
|
|
*/
|
|
|
|
#include "qedi.h"
|
|
#include "qedi_gbl.h"
|
|
#include "qedi_iscsi.h"
|
|
#include "qedi_dbg.h"
|
|
|
|
static inline struct qedi_ctx *qedi_dev_to_hba(struct device *dev)
|
|
{
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
return iscsi_host_priv(shost);
|
|
}
|
|
|
|
static ssize_t qedi_show_port_state(struct device *dev,
|
|
struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
|
|
|
|
if (atomic_read(&qedi->link_state) == QEDI_LINK_UP)
|
|
return sprintf(buf, "Online\n");
|
|
else
|
|
return sprintf(buf, "Linkdown\n");
|
|
}
|
|
|
|
static ssize_t qedi_show_speed(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
|
|
struct qed_link_output if_link;
|
|
|
|
qedi_ops->common->get_link(qedi->cdev, &if_link);
|
|
|
|
return sprintf(buf, "%d Gbit\n", if_link.speed / 1000);
|
|
}
|
|
|
|
static DEVICE_ATTR(port_state, 0444, qedi_show_port_state, NULL);
|
|
static DEVICE_ATTR(speed, 0444, qedi_show_speed, NULL);
|
|
|
|
struct device_attribute *qedi_shost_attrs[] = {
|
|
&dev_attr_port_state,
|
|
&dev_attr_speed,
|
|
NULL
|
|
};
|