1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
14 * Copyright 2019 Joyent, Inc.
15 */
16
17 #include "i40e_sw.h"
18
19 /*
20 * -------------------
21 * Statistics Overview
22 * -------------------
23 *
24 * As part of managing the driver and understanding what's going on, we keep
25 * track of statistics from two different sources:
26 *
27 * - Statistics from the device
28 * - Statistics maintained by the driver
29 *
30 * Generally, the hardware provides us traditional IETF and MIB Ethernet
31 * statistics, for example, the total packets in and out, various errors in
32 * packets, the negotiated status etc. The driver, on the other hand, primarily
33 * contains statistics around driver-specific issues, such as information about
34 * checksumming on receive and transmit and the data in and out of a specific
918 break;
919 case I40E_PHY_TYPE_1000BASE_T:
920 *val = XCVR_1000T;
921 break;
922 default:
923 *val = XCVR_UNDEFINED;
924 break;
925 }
926 break;
927
928 /*
929 * This group answers the question of do we support a given speed in
930 * theory.
931 */
932 case ETHER_STAT_CAP_100FDX:
933 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
934 break;
935 case ETHER_STAT_CAP_1000FDX:
936 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
937 break;
938 case ETHER_STAT_CAP_10GFDX:
939 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
940 break;
941 case ETHER_STAT_CAP_25GFDX:
942 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
943 break;
944 case ETHER_STAT_CAP_40GFDX:
945 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_40GB) != 0;
946 break;
947
948 /*
949 * These ask are we currently advertising these speeds and abilities.
950 * Until we support setting these because we're working with a copper
951 * PHY, then the only things we advertise are based on the link PHY
952 * speeds. In other words, we advertise everything we support.
953 */
954 case ETHER_STAT_ADV_CAP_100FDX:
955 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
956 break;
957 case ETHER_STAT_ADV_CAP_1000FDX:
958 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
959 break;
960 case ETHER_STAT_ADV_CAP_10GFDX:
961 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
962 break;
963 case ETHER_STAT_ADV_CAP_25GFDX:
964 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
965 break;
966 case ETHER_STAT_ADV_CAP_40GFDX:
967 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_40GB) != 0;
968 break;
969
970 /*
971 * These ask if the peer supports these speeds, e.g. what did they tell
972 * us in auto-negotiation. Unfortunately, hardware doesn't appear to
973 * give us a way to determine whether or not they actually support
974 * something, only what they have enabled. This means that all we can
975 * tell the user is the speed that we're currently at, unfortunately.
976 */
977 case ETHER_STAT_LP_CAP_100FDX:
978 *val = i40e->i40e_link_speed == 100;
979 break;
980 case ETHER_STAT_LP_CAP_1000FDX:
981 *val = i40e->i40e_link_speed == 1000;
982 break;
983 case ETHER_STAT_LP_CAP_10GFDX:
984 *val = i40e->i40e_link_speed == 10000;
985 break;
986 case ETHER_STAT_LP_CAP_25GFDX:
987 *val = i40e->i40e_link_speed == 25000;
988 break;
989 case ETHER_STAT_LP_CAP_40GFDX:
990 *val = i40e->i40e_link_speed == 40000;
991 break;
992
993 /*
994 * Statistics for unsupported speeds. Note that these often have the
995 * same constraints as the other ones. For example, we can't answer the
996 * question of the ETHER_STAT_LP_CAP family because hardware doesn't
997 * give us any way of knowing whether or not it does.
998 */
999 case ETHER_STAT_CAP_100HDX:
1000 case ETHER_STAT_CAP_1000HDX:
1001 case ETHER_STAT_CAP_10FDX:
1002 case ETHER_STAT_CAP_10HDX:
1003 case ETHER_STAT_CAP_100T4:
1004 case ETHER_STAT_CAP_100GFDX:
1005 case ETHER_STAT_CAP_50GFDX:
1006 case ETHER_STAT_CAP_2500FDX:
1007 case ETHER_STAT_CAP_5000FDX:
1008 case ETHER_STAT_ADV_CAP_1000HDX:
1009 case ETHER_STAT_ADV_CAP_100HDX:
1010 case ETHER_STAT_ADV_CAP_10FDX:
1011 case ETHER_STAT_ADV_CAP_10HDX:
1012 case ETHER_STAT_ADV_CAP_100T4:
1013 case ETHER_STAT_ADV_CAP_100GFDX:
1014 case ETHER_STAT_ADV_CAP_50GFDX:
1015 case ETHER_STAT_ADV_CAP_2500FDX:
1016 case ETHER_STAT_ADV_CAP_5000FDX:
1017 case ETHER_STAT_LP_CAP_1000HDX:
1018 case ETHER_STAT_LP_CAP_100HDX:
1019 case ETHER_STAT_LP_CAP_10FDX:
1020 case ETHER_STAT_LP_CAP_10HDX:
1021 case ETHER_STAT_LP_CAP_100T4:
1022 case ETHER_STAT_LP_CAP_100GFDX:
1023 case ETHER_STAT_LP_CAP_50GFDX:
1024 case ETHER_STAT_LP_CAP_2500FDX:
1025 case ETHER_STAT_LP_CAP_5000FDX:
1026 *val = 0;
1027 break;
1028
1029 case ETHER_STAT_LINK_DUPLEX:
1030 *val = i40e->i40e_link_duplex;
1031 break;
1032 case ETHER_STAT_TOOSHORT_ERRORS:
1033 i40e_stat_get_uint32(i40e, I40E_GLPRT_RUC(port),
1034 &ipk->ipk_rx_undersize, &ips->ips_rx_undersize, B_FALSE);
1035
1036 i40e_stat_get_uint32(i40e, I40E_GLPRT_MSPDC(port),
1037 &ipk->ipk_rx_short_discards, &ips->ips_rx_short_discards,
1038 B_FALSE);
1039 *val = ipk->ipk_rx_undersize.value.ui64 +
1040 ipk->ipk_rx_short_discards.value.ui64;
1041 break;
1042 case ETHER_STAT_JABBER_ERRORS:
1043 i40e_stat_get_uint32(i40e, I40E_GLPRT_RJC(port),
1044 &ipk->ipk_rx_jabber, &ips->ips_rx_jabber, B_FALSE);
1045 *val = ipk->ipk_rx_jabber.value.ui64;
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
14 * Copyright 2019 Joyent, Inc.
15 * Copyright 2021 Oxide Computer Company
16 */
17
18 #include "i40e_sw.h"
19
20 /*
21 * -------------------
22 * Statistics Overview
23 * -------------------
24 *
25 * As part of managing the driver and understanding what's going on, we keep
26 * track of statistics from two different sources:
27 *
28 * - Statistics from the device
29 * - Statistics maintained by the driver
30 *
31 * Generally, the hardware provides us traditional IETF and MIB Ethernet
32 * statistics, for example, the total packets in and out, various errors in
33 * packets, the negotiated status etc. The driver, on the other hand, primarily
34 * contains statistics around driver-specific issues, such as information about
35 * checksumming on receive and transmit and the data in and out of a specific
919 break;
920 case I40E_PHY_TYPE_1000BASE_T:
921 *val = XCVR_1000T;
922 break;
923 default:
924 *val = XCVR_UNDEFINED;
925 break;
926 }
927 break;
928
929 /*
930 * This group answers the question of do we support a given speed in
931 * theory.
932 */
933 case ETHER_STAT_CAP_100FDX:
934 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
935 break;
936 case ETHER_STAT_CAP_1000FDX:
937 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
938 break;
939 case ETHER_STAT_CAP_2500FDX:
940 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_2_5GB) != 0;
941 break;
942 case ETHER_STAT_CAP_5000FDX:
943 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_5GB) != 0;
944 break;
945 case ETHER_STAT_CAP_10GFDX:
946 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
947 break;
948 case ETHER_STAT_CAP_25GFDX:
949 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
950 break;
951 case ETHER_STAT_CAP_40GFDX:
952 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_40GB) != 0;
953 break;
954
955 /*
956 * These ask are we currently advertising these speeds and abilities.
957 * Until we support setting these because we're working with a copper
958 * PHY, then the only things we advertise are based on the link PHY
959 * speeds. In other words, we advertise everything we support.
960 */
961 case ETHER_STAT_ADV_CAP_100FDX:
962 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
963 break;
964 case ETHER_STAT_ADV_CAP_1000FDX:
965 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
966 break;
967 case ETHER_STAT_ADV_CAP_2500FDX:
968 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_2_5GB) != 0;
969 break;
970 case ETHER_STAT_ADV_CAP_5000FDX:
971 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_5GB) != 0;
972 break;
973 case ETHER_STAT_ADV_CAP_10GFDX:
974 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
975 break;
976 case ETHER_STAT_ADV_CAP_25GFDX:
977 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
978 break;
979 case ETHER_STAT_ADV_CAP_40GFDX:
980 *val = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_40GB) != 0;
981 break;
982
983 /*
984 * These ask if the peer supports these speeds, e.g. what did they tell
985 * us in auto-negotiation. Unfortunately, hardware doesn't appear to
986 * give us a way to determine whether or not they actually support
987 * something, only what they have enabled. This means that all we can
988 * tell the user is the speed that we're currently at, unfortunately.
989 */
990 case ETHER_STAT_LP_CAP_100FDX:
991 *val = i40e->i40e_link_speed == 100;
992 break;
993 case ETHER_STAT_LP_CAP_1000FDX:
994 *val = i40e->i40e_link_speed == 1000;
995 break;
996 case ETHER_STAT_LP_CAP_2500FDX:
997 *val = i40e->i40e_link_speed == 2500;
998 break;
999 case ETHER_STAT_LP_CAP_5000FDX:
1000 *val = i40e->i40e_link_speed == 5000;
1001 break;
1002 case ETHER_STAT_LP_CAP_10GFDX:
1003 *val = i40e->i40e_link_speed == 10000;
1004 break;
1005 case ETHER_STAT_LP_CAP_25GFDX:
1006 *val = i40e->i40e_link_speed == 25000;
1007 break;
1008 case ETHER_STAT_LP_CAP_40GFDX:
1009 *val = i40e->i40e_link_speed == 40000;
1010 break;
1011
1012 /*
1013 * Statistics for unsupported speeds. Note that these often have the
1014 * same constraints as the other ones. For example, we can't answer the
1015 * question of the ETHER_STAT_LP_CAP family because hardware doesn't
1016 * give us any way of knowing whether or not it does.
1017 */
1018 case ETHER_STAT_CAP_100HDX:
1019 case ETHER_STAT_CAP_1000HDX:
1020 case ETHER_STAT_CAP_10FDX:
1021 case ETHER_STAT_CAP_10HDX:
1022 case ETHER_STAT_CAP_100T4:
1023 case ETHER_STAT_CAP_100GFDX:
1024 case ETHER_STAT_CAP_50GFDX:
1025 case ETHER_STAT_ADV_CAP_1000HDX:
1026 case ETHER_STAT_ADV_CAP_100HDX:
1027 case ETHER_STAT_ADV_CAP_10FDX:
1028 case ETHER_STAT_ADV_CAP_10HDX:
1029 case ETHER_STAT_ADV_CAP_100T4:
1030 case ETHER_STAT_ADV_CAP_100GFDX:
1031 case ETHER_STAT_ADV_CAP_50GFDX:
1032 case ETHER_STAT_LP_CAP_1000HDX:
1033 case ETHER_STAT_LP_CAP_100HDX:
1034 case ETHER_STAT_LP_CAP_10FDX:
1035 case ETHER_STAT_LP_CAP_10HDX:
1036 case ETHER_STAT_LP_CAP_100T4:
1037 case ETHER_STAT_LP_CAP_100GFDX:
1038 case ETHER_STAT_LP_CAP_50GFDX:
1039 *val = 0;
1040 break;
1041
1042 case ETHER_STAT_LINK_DUPLEX:
1043 *val = i40e->i40e_link_duplex;
1044 break;
1045 case ETHER_STAT_TOOSHORT_ERRORS:
1046 i40e_stat_get_uint32(i40e, I40E_GLPRT_RUC(port),
1047 &ipk->ipk_rx_undersize, &ips->ips_rx_undersize, B_FALSE);
1048
1049 i40e_stat_get_uint32(i40e, I40E_GLPRT_MSPDC(port),
1050 &ipk->ipk_rx_short_discards, &ips->ips_rx_short_discards,
1051 B_FALSE);
1052 *val = ipk->ipk_rx_undersize.value.ui64 +
1053 ipk->ipk_rx_short_discards.value.ui64;
1054 break;
1055 case ETHER_STAT_JABBER_ERRORS:
1056 i40e_stat_get_uint32(i40e, I40E_GLPRT_RJC(port),
1057 &ipk->ipk_rx_jabber, &ips->ips_rx_jabber, B_FALSE);
1058 *val = ipk->ipk_rx_jabber.value.ui64;
|