Skip to contentSkip to conversation

zfcp: introduce SysFS interface for diagnostics of local SFP transceiver

PATCH New Benjamin Block 1 participant 1 message Apr 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/10 zfcp: introduce SysFS interface for diagnostics of local SFP transceiver

This adds an interface to read the diagnostics of the local SFP transceiver of an FCP-Channel from userspace. This comes in the form of new SysFS entries that are attached to the CCW device representing the FCP device. Each type of data gets its own SysFS entry; the whole collection of entries is pooled into a new child-directory of the CCW device node: "diagnostics".

Adds SysFS entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid

 * temperature:    transceiver temp.; unit 1/256��C;
                   range [-128��C, +128��C]
 * vcc:            supply voltage; unit 100��V; range [0, 6.55V]
 * tx_bias:        transmitter laser bias current; unit 2��A;
                   range [0, 131mA]

* tx_power: coupled TX output power; unit 0.1��W; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1��W; range [0, 6.5mW]

* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;

                   {0, 1}; 1 - active

* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+

This is only supported if the FCP-Channel in turn supports reporting the SFP Diagnostic Data, otherwise read() on these new entries will return EOPNOTSUPP (this affects only adapters older than FICON Express8S, on Mainframe generations older than z14). Other possible errors for read() include ENOLINK, ENODEV and ENOMEM.

With this patch the userspace-interface will only read data stored in the corresponding "diagnostic buffer" (that was stored during completion of an previous Exchange Port Data command). Implicit updating will follow later in this series.

---
 drivers/s390/scsi/zfcp_aux.c   |  4 +++
 drivers/s390/scsi/zfcp_diag.c  | 42 +++++++++++++++++++++++++
 drivers/s390/scsi/zfcp_diag.h  | 18 +++++++++++
 drivers/s390/scsi/zfcp_ext.h   |  1 +
 drivers/s390/scsi/zfcp_sysfs.c | 71 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 136 insertions(+)
drivers/s390/scsi/zfcp_aux.c +4 -0
index 3ddc7147ac4f..5ea162999c4a 100644
@@ -407,6 +407,9 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
 			       &zfcp_sysfs_adapter_attrs))
 		goto failed;
 
+	if (zfcp_diag_sysfs_setup(adapter))
+		goto failed;
+
 	/* report size limit per scatter-gather segment */
 	adapter->ccw_device->dev.dma_parms = &adapter->dma_parms;
 
@@ -431,6 +434,7 @@ void zfcp_adapter_unregister(struct zfcp_adapter *adapter)
 
 	zfcp_fc_wka_ports_force_offline(adapter->gs);
 	zfcp_scsi_adapter_unregister(adapter);
+	zfcp_diag_sysfs_destroy(adapter);
 	sysfs_remove_group(&cdev->dev.kobj, &zfcp_sysfs_adapter_attrs);
 
 	zfcp_erp_thread_kill(adapter);
drivers/s390/scsi/zfcp_diag.c +42 -0

54 lines not on this page · raw message

drivers/s390/scsi/zfcp_diag.h +18 -0
index 031050c82b6e..7c7e0a726c7e 100644
@@ -40,6 +40,8 @@ struct zfcp_diag_header {
 /**
  * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
  *                            adapter.
+ * @sysfs_established: flag showing that the associated sysfs-group was created
+ *                     during run of zfcp_adapter_enqueue().
  * @port_data: data retrieved using exchange port data.
  * @port_data.header: header with metadata for the cache in @port_data.data.
  * @port_data.data: cached QTCB Bottom of command exchange port data.
@@ -48,6 +50,8 @@ struct zfcp_diag_header {
  * @config_data.data: cached QTCB Bottom of command exchange config data.
  */
 struct zfcp_diag_adapter {
+	u64	sysfs_established	:1;
+
 	struct {
 		struct zfcp_diag_header		header;
 		struct fsf_qtcb_bottom_port	data;
@@ -61,7 +65,21 @@ struct zfcp_diag_adapter {
 int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
 void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
 
+int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
+void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
+
 void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
 			    const void *const data, const bool incomplete);
 
+/**
+ * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
+ *                           SFP Data.
+ * @adapter: adapter to test the availability of SFP Data reporting for.
+ */
+static inline bool
+zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
+{
+	return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
+}
+
 #endif /* ZFCP_DIAG_H */
drivers/s390/scsi/zfcp_ext.h +1 -0
index 3fce47b0b21b..b4f9d5fa5ab1 100644
@@ -165,6 +165,7 @@ extern const struct attribute_group *zfcp_port_attr_groups[];
 extern struct mutex zfcp_sysfs_port_units_mutex;
 extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
 extern struct device_attribute *zfcp_sysfs_shost_attrs[];
+extern const struct attribute_group zfcp_sysfs_diag_attr_group;
 
 /* zfcp_unit.c */
 extern int zfcp_unit_add(struct zfcp_port *, u64);
drivers/s390/scsi/zfcp_sysfs.c +71 -0

80 lines not on this page · raw message

Signature · 1 line
2.16.4