|
|
786c6d |
From fe6623803d1135fd382146faa847bcdf5dc6abc3 Mon Sep 17 00:00:00 2001
|
|
|
786c6d |
From: Lalit Chandivade <lalit.chandivade@qlogic.com>
|
|
|
786c6d |
Date: Fri, 22 Nov 2013 05:46:13 -0500
|
|
|
786c6d |
Subject: [PATCH] iscsi_tool: Add offload host statistics support.
|
|
|
786c6d |
|
|
|
786c6d |
Signed-off-by: Lalit Chandivade <lalit.chandivade@qlogic.com>
|
|
|
786c6d |
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
|
|
|
786c6d |
---
|
|
|
786c6d |
include/iscsi_if.h | 116 ++++++++++++++++++++++++-
|
|
|
786c6d |
usr/iscsi_ipc.h | 2 +
|
|
|
786c6d |
usr/iscsiadm.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
786c6d |
usr/netlink.c | 47 +++++++++++
|
|
|
786c6d |
4 files changed, 406 insertions(+), 3 deletions(-)
|
|
|
786c6d |
|
|
|
786c6d |
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
|
|
|
786c6d |
index e59bcd0..9d15811 100644
|
|
|
786c6d |
--- a/include/iscsi_if.h
|
|
|
786c6d |
+++ b/include/iscsi_if.h
|
|
|
786c6d |
@@ -75,8 +75,8 @@ enum iscsi_uevent_e {
|
|
|
786c6d |
ISCSI_UEVENT_LOGOUT_FLASHNODE = UEVENT_BASE + 29,
|
|
|
786c6d |
ISCSI_UEVENT_LOGOUT_FLASHNODE_SID = UEVENT_BASE + 30,
|
|
|
786c6d |
ISCSI_UEVENT_SET_CHAP = UEVENT_BASE + 31,
|
|
|
786c6d |
-
|
|
|
786c6d |
- ISCSI_UEVENT_MAX = ISCSI_UEVENT_SET_CHAP,
|
|
|
786c6d |
+ ISCSI_UEVENT_GET_HOST_STATS = UEVENT_BASE + 32,
|
|
|
786c6d |
+ ISCSI_UEVENT_MAX = ISCSI_UEVENT_GET_HOST_STATS,
|
|
|
786c6d |
|
|
|
786c6d |
/* up events */
|
|
|
786c6d |
ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
|
|
|
786c6d |
@@ -251,6 +251,10 @@ struct iscsi_uevent {
|
|
|
786c6d |
uint32_t host_no;
|
|
|
786c6d |
uint32_t sid;
|
|
|
786c6d |
} logout_flashnode_sid;
|
|
|
786c6d |
+ struct msg_get_host_stats {
|
|
|
786c6d |
+ uint32_t host_no;
|
|
|
786c6d |
+ } get_host_stats;
|
|
|
786c6d |
+
|
|
|
786c6d |
} u;
|
|
|
786c6d |
union {
|
|
|
786c6d |
/* messages k -> u */
|
|
|
786c6d |
@@ -854,4 +858,112 @@ struct iscsi_chap_rec {
|
|
|
786c6d |
uint8_t password_length;
|
|
|
786c6d |
};
|
|
|
786c6d |
|
|
|
786c6d |
+#define ISCSI_HOST_STATS_CUSTOM_MAX 32
|
|
|
786c6d |
+#define ISCSI_HOST_STATS_CUSTOM_DESC_MAX 64
|
|
|
786c6d |
+struct iscsi_host_stats_custom {
|
|
|
786c6d |
+ char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX];
|
|
|
786c6d |
+ uint64_t value;
|
|
|
786c6d |
+};
|
|
|
786c6d |
+
|
|
|
786c6d |
+/* struct iscsi_offload_host_stats: Host statistics,
|
|
|
786c6d |
+ * Include statistics for MAC, IP, TCP & iSCSI.
|
|
|
786c6d |
+ */
|
|
|
786c6d |
+struct iscsi_offload_host_stats {
|
|
|
786c6d |
+ /* MAC */
|
|
|
786c6d |
+ uint64_t mactx_frames;
|
|
|
786c6d |
+ uint64_t mactx_bytes;
|
|
|
786c6d |
+ uint64_t mactx_multicast_frames;
|
|
|
786c6d |
+ uint64_t mactx_broadcast_frames;
|
|
|
786c6d |
+ uint64_t mactx_pause_frames;
|
|
|
786c6d |
+ uint64_t mactx_control_frames;
|
|
|
786c6d |
+ uint64_t mactx_deferral;
|
|
|
786c6d |
+ uint64_t mactx_excess_deferral;
|
|
|
786c6d |
+ uint64_t mactx_late_collision;
|
|
|
786c6d |
+ uint64_t mactx_abort;
|
|
|
786c6d |
+ uint64_t mactx_single_collision;
|
|
|
786c6d |
+ uint64_t mactx_multiple_collision;
|
|
|
786c6d |
+ uint64_t mactx_collision;
|
|
|
786c6d |
+ uint64_t mactx_frames_dropped;
|
|
|
786c6d |
+ uint64_t mactx_jumbo_frames;
|
|
|
786c6d |
+ uint64_t macrx_frames;
|
|
|
786c6d |
+ uint64_t macrx_bytes;
|
|
|
786c6d |
+ uint64_t macrx_unknown_control_frames;
|
|
|
786c6d |
+ uint64_t macrx_pause_frames;
|
|
|
786c6d |
+ uint64_t macrx_control_frames;
|
|
|
786c6d |
+ uint64_t macrx_dribble;
|
|
|
786c6d |
+ uint64_t macrx_frame_length_error;
|
|
|
786c6d |
+ uint64_t macrx_jabber;
|
|
|
786c6d |
+ uint64_t macrx_carrier_sense_error;
|
|
|
786c6d |
+ uint64_t macrx_frame_discarded;
|
|
|
786c6d |
+ uint64_t macrx_frames_dropped;
|
|
|
786c6d |
+ uint64_t mac_crc_error;
|
|
|
786c6d |
+ uint64_t mac_encoding_error;
|
|
|
786c6d |
+ uint64_t macrx_length_error_large;
|
|
|
786c6d |
+ uint64_t macrx_length_error_small;
|
|
|
786c6d |
+ uint64_t macrx_multicast_frames;
|
|
|
786c6d |
+ uint64_t macrx_broadcast_frames;
|
|
|
786c6d |
+ /* IP */
|
|
|
786c6d |
+ uint64_t iptx_packets;
|
|
|
786c6d |
+ uint64_t iptx_bytes;
|
|
|
786c6d |
+ uint64_t iptx_fragments;
|
|
|
786c6d |
+ uint64_t iprx_packets;
|
|
|
786c6d |
+ uint64_t iprx_bytes;
|
|
|
786c6d |
+ uint64_t iprx_fragments;
|
|
|
786c6d |
+ uint64_t ip_datagram_reassembly;
|
|
|
786c6d |
+ uint64_t ip_invalid_address_error;
|
|
|
786c6d |
+ uint64_t ip_error_packets;
|
|
|
786c6d |
+ uint64_t ip_fragrx_overlap;
|
|
|
786c6d |
+ uint64_t ip_fragrx_outoforder;
|
|
|
786c6d |
+ uint64_t ip_datagram_reassembly_timeout;
|
|
|
786c6d |
+ uint64_t ipv6tx_packets;
|
|
|
786c6d |
+ uint64_t ipv6tx_bytes;
|
|
|
786c6d |
+ uint64_t ipv6tx_fragments;
|
|
|
786c6d |
+ uint64_t ipv6rx_packets;
|
|
|
786c6d |
+ uint64_t ipv6rx_bytes;
|
|
|
786c6d |
+ uint64_t ipv6rx_fragments;
|
|
|
786c6d |
+ uint64_t ipv6_datagram_reassembly;
|
|
|
786c6d |
+ uint64_t ipv6_invalid_address_error;
|
|
|
786c6d |
+ uint64_t ipv6_error_packets;
|
|
|
786c6d |
+ uint64_t ipv6_fragrx_overlap;
|
|
|
786c6d |
+ uint64_t ipv6_fragrx_outoforder;
|
|
|
786c6d |
+ uint64_t ipv6_datagram_reassembly_timeout;
|
|
|
786c6d |
+ /* TCP */
|
|
|
786c6d |
+ uint64_t tcptx_segments;
|
|
|
786c6d |
+ uint64_t tcptx_bytes;
|
|
|
786c6d |
+ uint64_t tcprx_segments;
|
|
|
786c6d |
+ uint64_t tcprx_byte;
|
|
|
786c6d |
+ uint64_t tcp_duplicate_ack_retx;
|
|
|
786c6d |
+ uint64_t tcp_retx_timer_expired;
|
|
|
786c6d |
+ uint64_t tcprx_duplicate_ack;
|
|
|
786c6d |
+ uint64_t tcprx_pure_ackr;
|
|
|
786c6d |
+ uint64_t tcptx_delayed_ack;
|
|
|
786c6d |
+ uint64_t tcptx_pure_ack;
|
|
|
786c6d |
+ uint64_t tcprx_segment_error;
|
|
|
786c6d |
+ uint64_t tcprx_segment_outoforder;
|
|
|
786c6d |
+ uint64_t tcprx_window_probe;
|
|
|
786c6d |
+ uint64_t tcprx_window_update;
|
|
|
786c6d |
+ uint64_t tcptx_window_probe_persist;
|
|
|
786c6d |
+ /* ECC */
|
|
|
786c6d |
+ uint64_t ecc_error_correction;
|
|
|
786c6d |
+ /* iSCSI */
|
|
|
786c6d |
+ uint64_t iscsi_pdu_tx;
|
|
|
786c6d |
+ uint64_t iscsi_data_bytes_tx;
|
|
|
786c6d |
+ uint64_t iscsi_pdu_rx;
|
|
|
786c6d |
+ uint64_t iscsi_data_bytes_rx;
|
|
|
786c6d |
+ uint64_t iscsi_io_completed;
|
|
|
786c6d |
+ uint64_t iscsi_unexpected_io_rx;
|
|
|
786c6d |
+ uint64_t iscsi_format_error;
|
|
|
786c6d |
+ uint64_t iscsi_hdr_digest_error;
|
|
|
786c6d |
+ uint64_t iscsi_data_digest_error;
|
|
|
786c6d |
+ uint64_t iscsi_sequence_error;
|
|
|
786c6d |
+ /*
|
|
|
786c6d |
+ * iSCSI Custom Host Statistics support, i.e. Transport could
|
|
|
786c6d |
+ * extend existing host statistics with its own specific statistics
|
|
|
786c6d |
+ * up to ISCSI_HOST_STATS_CUSTOM_MAX
|
|
|
786c6d |
+ */
|
|
|
786c6d |
+ uint32_t custom_length;
|
|
|
786c6d |
+ struct iscsi_host_stats_custom custom[0]
|
|
|
786c6d |
+ __attribute__ ((aligned (sizeof(uint64_t))));
|
|
|
786c6d |
+};
|
|
|
786c6d |
+
|
|
|
786c6d |
#endif
|
|
|
786c6d |
diff --git a/usr/iscsi_ipc.h b/usr/iscsi_ipc.h
|
|
|
786c6d |
index a32da1c..9d26d54 100644
|
|
|
786c6d |
--- a/usr/iscsi_ipc.h
|
|
|
786c6d |
+++ b/usr/iscsi_ipc.h
|
|
|
786c6d |
@@ -161,6 +161,8 @@ struct iscsi_ipc {
|
|
|
786c6d |
uint32_t flashnode_idx);
|
|
|
786c6d |
int (*logout_flash_node_sid) (uint64_t transport_handle,
|
|
|
786c6d |
uint32_t host_no, uint32_t sid);
|
|
|
786c6d |
+ int (*get_host_stats) (uint64_t transport_handle, uint32_t host_no,
|
|
|
786c6d |
+ char *host_stats);
|
|
|
786c6d |
};
|
|
|
786c6d |
|
|
|
786c6d |
#endif /* ISCSI_IPC_H */
|
|
|
786c6d |
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
|
|
786c6d |
index 045259b..ed2c0c3 100644
|
|
|
786c6d |
--- a/usr/iscsiadm.c
|
|
|
786c6d |
+++ b/usr/iscsiadm.c
|
|
|
786c6d |
@@ -69,7 +69,8 @@ enum iscsiadm_mode {
|
|
|
786c6d |
MODE_FW,
|
|
|
786c6d |
MODE_PING,
|
|
|
786c6d |
MODE_CHAP,
|
|
|
786c6d |
- MODE_FLASHNODE
|
|
|
786c6d |
+ MODE_FLASHNODE,
|
|
|
786c6d |
+ MODE_HOST_STATS
|
|
|
786c6d |
};
|
|
|
786c6d |
|
|
|
786c6d |
enum iscsiadm_op {
|
|
|
786c6d |
@@ -137,6 +138,7 @@ iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid
|
|
|
786c6d |
iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\
|
|
|
786c6d |
iscsiadm -m fw [ -d debug_level ] [ -l ]\n\
|
|
|
786c6d |
iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] ] [ [ -o operation ] [ -n name ] [ -v value ] ] \n\
|
|
|
786c6d |
+iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -o operation ] [ -v chap_tbl_idx ] ] | [ -C flashnode [ -o operation ] [ -A portal_type ] [ -x flashnode_idx ] [ -n name ] [ -v value ] ] | [ -C stats ] ]\n\
|
|
|
786c6d |
iscsiadm -k priority\n");
|
|
|
786c6d |
}
|
|
|
786c6d |
exit(status);
|
|
|
786c6d |
@@ -207,6 +209,9 @@ str_to_submode(char *str)
|
|
|
786c6d |
sub_mode = MODE_CHAP;
|
|
|
786c6d |
else if (!strcmp("flashnode", str))
|
|
|
786c6d |
sub_mode = MODE_FLASHNODE;
|
|
|
786c6d |
+ else if (!strcmp("stats", str))
|
|
|
786c6d |
+ sub_mode = MODE_HOST_STATS;
|
|
|
786c6d |
+
|
|
|
786c6d |
else
|
|
|
786c6d |
sub_mode = -1;
|
|
|
786c6d |
|
|
|
786c6d |
@@ -2025,6 +2030,232 @@ exit_flashnode_op:
|
|
|
786c6d |
return rc;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
+static void print_host_stats(struct iscsi_offload_host_stats *host_stats)
|
|
|
786c6d |
+{
|
|
|
786c6d |
+ /* MAC */
|
|
|
786c6d |
+ printf("Host Statistics:\n"
|
|
|
786c6d |
+ "\tmactx_frames: %lld\n"
|
|
|
786c6d |
+ "\tmactx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tmactx_multicast_frames: %lld\n"
|
|
|
786c6d |
+ "\tmactx_broadcast_frames: %lld\n"
|
|
|
786c6d |
+ "\tmactx_pause_frames: %lld\n"
|
|
|
786c6d |
+ "\tmactx_control_frames: %lld\n"
|
|
|
786c6d |
+ "\tmactx_deferral: %lld\n"
|
|
|
786c6d |
+ "\tmactx_excess_deferral: %lld\n"
|
|
|
786c6d |
+ "\tmactx_late_collision: %lld\n"
|
|
|
786c6d |
+ "\tmactx_abort: %lld\n"
|
|
|
786c6d |
+ "\tmactx_single_collision: %lld\n"
|
|
|
786c6d |
+ "\tmactx_multiple_collision: %lld\n"
|
|
|
786c6d |
+ "\tmactx_collision: %lld\n"
|
|
|
786c6d |
+ "\tmactx_frames_dropped: %lld\n"
|
|
|
786c6d |
+ "\tmactx_jumbo_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_unknown_control_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_pause_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_control_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_dribble: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_frame_length_error: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_jabber: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_carrier_sense_error: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_frame_discarded: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_frames_dropped: %lld\n"
|
|
|
786c6d |
+ "\tmac_crc_error: %lld\n"
|
|
|
786c6d |
+ "\tmac_encoding_error: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_length_error_large: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_length_error_small: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_multicast_frames: %lld\n"
|
|
|
786c6d |
+ "\tmacrx_broadcast_frames: %lld\n"
|
|
|
786c6d |
+ /* IP */
|
|
|
786c6d |
+ "\tiptx_packets: %lld\n"
|
|
|
786c6d |
+ "\tiptx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tiptx_fragments: %lld\n"
|
|
|
786c6d |
+ "\tiprx_packets: %lld\n"
|
|
|
786c6d |
+ "\tiprx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tiprx_fragments: %lld\n"
|
|
|
786c6d |
+ "\tip_datagram_reassembly: %lld\n"
|
|
|
786c6d |
+ "\tip_invalid_address_error: %lld\n"
|
|
|
786c6d |
+ "\tip_error_packets: %lld\n"
|
|
|
786c6d |
+ "\tip_fragrx_overlap: %lld\n"
|
|
|
786c6d |
+ "\tip_fragrx_outoforder: %lld\n"
|
|
|
786c6d |
+ "\tip_datagram_reassembly_timeout: %lld\n"
|
|
|
786c6d |
+ "\tipv6tx_packets: %lld\n"
|
|
|
786c6d |
+ "\tipv6tx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tipv6tx_fragments: %lld\n"
|
|
|
786c6d |
+ "\tipv6rx_packets: %lld\n"
|
|
|
786c6d |
+ "\tipv6rx_bytes: %lld\n"
|
|
|
786c6d |
+ "\tipv6rx_fragments: %lld\n"
|
|
|
786c6d |
+ "\tipv6_datagram_reassembly: %lld\n"
|
|
|
786c6d |
+ "\tipv6_invalid_address_error: %lld\n"
|
|
|
786c6d |
+ "\tipv6_error_packets: %lld\n"
|
|
|
786c6d |
+ "\tipv6_fragrx_overlap: %lld\n"
|
|
|
786c6d |
+ "\tipv6_fragrx_outoforder: %lld\n"
|
|
|
786c6d |
+ "\tipv6_datagram_reassembly_timeout: %lld\n"
|
|
|
786c6d |
+ /* TCP */
|
|
|
786c6d |
+ "\ttcptx_segments: %lld\n"
|
|
|
786c6d |
+ "\ttcptx_bytes: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_segments: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_byte: %lld\n"
|
|
|
786c6d |
+ "\ttcp_duplicate_ack_retx: %lld\n"
|
|
|
786c6d |
+ "\ttcp_retx_timer_expired: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_duplicate_ack: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_pure_ackr: %lld\n"
|
|
|
786c6d |
+ "\ttcptx_delayed_ack: %lld\n"
|
|
|
786c6d |
+ "\ttcptx_pure_ack: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_segment_error: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_segment_outoforder: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_window_probe: %lld\n"
|
|
|
786c6d |
+ "\ttcprx_window_update: %lld\n"
|
|
|
786c6d |
+ "\ttcptx_window_probe_persist: %lld\n"
|
|
|
786c6d |
+ /* ECC */
|
|
|
786c6d |
+ "\tecc_error_correction: %lld\n"
|
|
|
786c6d |
+ /* iSCSI */
|
|
|
786c6d |
+ "\tiscsi_pdu_tx: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_data_bytes_tx: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_pdu_rx: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_data_bytes_rx: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_io_completed: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_unexpected_io_rx: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_format_error: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_hdr_digest_error: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_data_digest_error: %lld\n"
|
|
|
786c6d |
+ "\tiscsi_sequence_error: %lld\n",
|
|
|
786c6d |
+ /* MAC */
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_multicast_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_broadcast_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_pause_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_control_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_deferral,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_excess_deferral,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_late_collision,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_abort,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_single_collision,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_multiple_collision,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_collision,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_frames_dropped,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mactx_jumbo_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_unknown_control_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_pause_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_control_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_dribble,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_frame_length_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_jabber,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_carrier_sense_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_frame_discarded,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_frames_dropped,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mac_crc_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->mac_encoding_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_length_error_large,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_length_error_small,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_multicast_frames,
|
|
|
786c6d |
+ (unsigned long long)host_stats->macrx_broadcast_frames,
|
|
|
786c6d |
+ /* IP */
|
|
|
786c6d |
+ (unsigned long long)host_stats->iptx_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iptx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iptx_fragments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iprx_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iprx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iprx_fragments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_datagram_reassembly,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_invalid_address_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_error_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_fragrx_overlap,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_fragrx_outoforder,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ip_datagram_reassembly_timeout,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6tx_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6tx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6tx_fragments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6rx_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6rx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6rx_fragments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_datagram_reassembly,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_invalid_address_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_error_packets,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_fragrx_overlap,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_fragrx_outoforder,
|
|
|
786c6d |
+ (unsigned long long)host_stats->ipv6_datagram_reassembly_timeout,
|
|
|
786c6d |
+ /* TCP */
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcptx_segments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcptx_bytes,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_segments,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_byte,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcp_duplicate_ack_retx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcp_retx_timer_expired,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_duplicate_ack,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_pure_ackr,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcptx_delayed_ack,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcptx_pure_ack,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_segment_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_segment_outoforder,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_window_probe,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcprx_window_update,
|
|
|
786c6d |
+ (unsigned long long)host_stats->tcptx_window_probe_persist,
|
|
|
786c6d |
+ /* ECC */
|
|
|
786c6d |
+ (unsigned long long)host_stats->ecc_error_correction,
|
|
|
786c6d |
+ /* iSCSI */
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_pdu_tx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_data_bytes_tx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_pdu_rx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_data_bytes_rx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_io_completed,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_unexpected_io_rx,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_format_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_hdr_digest_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_data_digest_error,
|
|
|
786c6d |
+ (unsigned long long)host_stats->iscsi_sequence_error);
|
|
|
786c6d |
+}
|
|
|
786c6d |
+
|
|
|
786c6d |
+static int exec_host_stats_op(int op, int info_level, uint32_t host_no)
|
|
|
786c6d |
+{
|
|
|
786c6d |
+ struct iscsi_transport *t = NULL;
|
|
|
786c6d |
+ char *req_buf;
|
|
|
786c6d |
+ int rc = ISCSI_SUCCESS;
|
|
|
786c6d |
+ int fd = 0, buf_size = 0;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ t = iscsi_sysfs_get_transport_by_hba(host_no);
|
|
|
786c6d |
+ if (!t) {
|
|
|
786c6d |
+ log_error("Could not match hostno %u to transport.", host_no);
|
|
|
786c6d |
+ rc = ISCSI_ERR_TRANS_NOT_FOUND;
|
|
|
786c6d |
+ goto exit_host_stats;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ buf_size = sizeof(struct iscsi_offload_host_stats) +
|
|
|
786c6d |
+ sizeof(struct iscsi_uevent);
|
|
|
786c6d |
+ req_buf = calloc(1, buf_size);
|
|
|
786c6d |
+ if (!req_buf) {
|
|
|
786c6d |
+ log_error("Could not allocate memory for host stats request.");
|
|
|
786c6d |
+ rc = ISCSI_ERR_NOMEM;
|
|
|
786c6d |
+ goto exit_host_stats;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ fd = ipc->ctldev_open();
|
|
|
786c6d |
+ if (fd < 0) {
|
|
|
786c6d |
+ rc = ISCSI_ERR_INTERNAL;
|
|
|
786c6d |
+ log_error("Netlink open failed.");
|
|
|
786c6d |
+ goto exit_host_stats;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ rc = ipc->get_host_stats(t->handle, host_no, req_buf);
|
|
|
786c6d |
+ if (rc < 0) {
|
|
|
786c6d |
+ log_error("get_host_stats failed. errno=%d", errno);
|
|
|
786c6d |
+ rc = ISCSI_ERR;
|
|
|
786c6d |
+ goto exit_host_stats;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ print_host_stats(req_buf + sizeof(struct iscsi_uevent));
|
|
|
786c6d |
+
|
|
|
786c6d |
+ ipc->ctldev_close();
|
|
|
786c6d |
+
|
|
|
786c6d |
+exit_host_stats:
|
|
|
786c6d |
+ if (req_buf)
|
|
|
786c6d |
+ free(req_buf);
|
|
|
786c6d |
+ return rc;
|
|
|
786c6d |
+}
|
|
|
786c6d |
+
|
|
|
786c6d |
static int verify_iface_params(struct list_head *params, struct node_rec *rec)
|
|
|
786c6d |
{
|
|
|
786c6d |
struct user_param *param;
|
|
|
786c6d |
@@ -3239,6 +3470,17 @@ main(int argc, char **argv)
|
|
|
786c6d |
index, portal_type,
|
|
|
786c6d |
¶ms);
|
|
|
786c6d |
break;
|
|
|
786c6d |
+ case MODE_HOST_STATS:
|
|
|
786c6d |
+ if (!host_no) {
|
|
|
786c6d |
+ log_error("STATS mode requires host no");
|
|
|
786c6d |
+ rc = ISCSI_ERR_INVAL;
|
|
|
786c6d |
+ break;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ rc = exec_host_stats_op(op, info_level,
|
|
|
786c6d |
+ host_no);
|
|
|
786c6d |
+ break;
|
|
|
786c6d |
+
|
|
|
786c6d |
default:
|
|
|
786c6d |
log_error("Invalid Sub Mode");
|
|
|
786c6d |
break;
|
|
|
786c6d |
diff --git a/usr/netlink.c b/usr/netlink.c
|
|
|
786c6d |
index 151b56d..1c4b5cc 100644
|
|
|
786c6d |
--- a/usr/netlink.c
|
|
|
786c6d |
+++ b/usr/netlink.c
|
|
|
786c6d |
@@ -339,6 +339,10 @@ __kipc_call(struct iovec *iovp, int count)
|
|
|
786c6d |
} else if (ev->type == ISCSI_UEVENT_GET_CHAP) {
|
|
|
786c6d |
/* kget_chap() will read */
|
|
|
786c6d |
return 0;
|
|
|
786c6d |
+ } else if (ev->type == ISCSI_UEVENT_GET_HOST_STATS) {
|
|
|
786c6d |
+ /* kget_host_stats() will read */
|
|
|
786c6d |
+ return 0;
|
|
|
786c6d |
+
|
|
|
786c6d |
} else {
|
|
|
786c6d |
if ((rc = nlpayload_read(ctrl_fd, (void*)ev,
|
|
|
786c6d |
sizeof(*ev), 0)) < 0) {
|
|
|
786c6d |
@@ -1439,6 +1443,48 @@ klogout_flashnode_sid(uint64_t transport_handle, uint32_t host_no,
|
|
|
786c6d |
return 0;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
+static int kget_host_stats(uint64_t transport_handle, uint32_t host_no,
|
|
|
786c6d |
+ char *host_stats)
|
|
|
786c6d |
+{
|
|
|
786c6d |
+ int rc = 0;
|
|
|
786c6d |
+ int ev_size;
|
|
|
786c6d |
+ struct iscsi_uevent ev;
|
|
|
786c6d |
+ struct iovec iov[2];
|
|
|
786c6d |
+ char nlm_ev[NLMSG_SPACE(sizeof(struct iscsi_uevent))];
|
|
|
786c6d |
+ struct nlmsghdr *nlh;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ memset(&ev, 0, sizeof(struct iscsi_uevent));
|
|
|
786c6d |
+
|
|
|
786c6d |
+ ev.type = ISCSI_UEVENT_GET_HOST_STATS;
|
|
|
786c6d |
+ ev.transport_handle = transport_handle;
|
|
|
786c6d |
+ ev.u.get_host_stats.host_no = host_no;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ iov[1].iov_base = &ev;
|
|
|
786c6d |
+ iov[1].iov_len = sizeof(ev);
|
|
|
786c6d |
+ rc = __kipc_call(iov, 2);
|
|
|
786c6d |
+ if (rc < 0)
|
|
|
786c6d |
+ return rc;
|
|
|
786c6d |
+
|
|
|
786c6d |
+ if ((rc = nl_read(ctrl_fd, nlm_ev,
|
|
|
786c6d |
+ NLMSG_SPACE(sizeof(struct iscsi_uevent)),
|
|
|
786c6d |
+ MSG_PEEK)) < 0) {
|
|
|
786c6d |
+ log_error("can not read nlm_ev, error %d", rc);
|
|
|
786c6d |
+ return rc;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ nlh = (struct nlmsghdr *)nlm_ev;
|
|
|
786c6d |
+ ev_size = nlh->nlmsg_len - NLMSG_ALIGN(sizeof(struct nlmsghdr));
|
|
|
786c6d |
+
|
|
|
786c6d |
+ if ((rc = nlpayload_read(ctrl_fd, (void *)host_stats,
|
|
|
786c6d |
+ ev_size, 0)) < 0) {
|
|
|
786c6d |
+ log_error("can not read from NL socket, error %d", rc);
|
|
|
786c6d |
+ return rc;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
+ return rc;
|
|
|
786c6d |
+}
|
|
|
786c6d |
+
|
|
|
786c6d |
+
|
|
|
786c6d |
static void drop_data(struct nlmsghdr *nlh)
|
|
|
786c6d |
{
|
|
|
786c6d |
int ev_size;
|
|
|
786c6d |
@@ -1737,6 +1783,7 @@ struct iscsi_ipc nl_ipc = {
|
|
|
786c6d |
.login_flash_node = klogin_flashnode,
|
|
|
786c6d |
.logout_flash_node = klogout_flashnode,
|
|
|
786c6d |
.logout_flash_node_sid = klogout_flashnode_sid,
|
|
|
786c6d |
+ .get_host_stats = kget_host_stats,
|
|
|
786c6d |
};
|
|
|
786c6d |
struct iscsi_ipc *ipc = &nl_ipc;
|
|
|
786c6d |
|
|
|
786c6d |
--
|
|
|
786c6d |
1.8.3.1
|
|
|
786c6d |
|