4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * MAC Services Module
28 */
29
30 #include <sys/types.h>
31 #include <sys/sysmacros.h>
32 #include <sys/stream.h>
33 #include <sys/kstat.h>
34 #include <sys/mac.h>
35 #include <sys/mac_impl.h>
36 #include <sys/mac_client_impl.h>
37 #include <sys/mac_stat.h>
38 #include <sys/mac_soft_ring.h>
39 #include <sys/vlan.h>
40
41 #define MAC_KSTAT_NAME "mac"
42 #define MAC_KSTAT_CLASS "net"
43
986 uint64_t
987 mac_driver_stat_default(mac_impl_t *mip, uint_t stat)
988 {
989 uint_t stat_index;
990
991 if (IS_MAC_STAT(stat)) {
992 stat_index = stat - MAC_STAT_MIN;
993 ASSERT(stat_index < MAC_NKSTAT);
994 return (i_mac_si[stat_index].msi_default);
995 }
996 ASSERT(IS_MACTYPE_STAT(stat));
997 stat_index = stat - MACTYPE_STAT_MIN;
998 ASSERT(stat_index < mip->mi_type->mt_statcount);
999 return (mip->mi_type->mt_stats[stat_index].msi_default);
1000 }
1001
1002 void
1003 mac_ring_stat_create(mac_ring_t *ring)
1004 {
1005 mac_impl_t *mip = ring->mr_mip;
1006 char statname[MAXNAMELEN];
1007 char modname[MAXNAMELEN];
1008
1009 if (mip->mi_state_flags & MIS_IS_AGGR) {
1010 (void) strlcpy(modname, mip->mi_clients_list->mci_name,
1011 MAXNAMELEN);
1012 } else
1013 (void) strlcpy(modname, mip->mi_name, MAXNAMELEN);
1014
1015 switch (ring->mr_type) {
1016 case MAC_RING_TYPE_RX:
1017 (void) snprintf(statname, sizeof (statname), "mac_rx_ring%d",
1018 ring->mr_index);
1019 i_mac_rx_ring_stat_create(ring, modname, statname);
1020 break;
1021
1022 case MAC_RING_TYPE_TX:
1023 (void) snprintf(statname, sizeof (statname), "mac_tx_ring%d",
1024 ring->mr_index);
1025 i_mac_tx_ring_stat_create(ring, modname, statname);
1026 break;
1027
1028 default:
1029 ASSERT(B_FALSE);
1030 break;
1031 }
1032 }
1033
1034 void
1035 mac_srs_stat_create(mac_soft_ring_set_t *mac_srs)
1036 {
1037 flow_entry_t *flent = mac_srs->srs_flent;
1038 char statname[MAXNAMELEN];
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2018 Joyent, Inc.
25 */
26
27 /*
28 * MAC Services Module
29 */
30
31 #include <sys/types.h>
32 #include <sys/sysmacros.h>
33 #include <sys/stream.h>
34 #include <sys/kstat.h>
35 #include <sys/mac.h>
36 #include <sys/mac_impl.h>
37 #include <sys/mac_client_impl.h>
38 #include <sys/mac_stat.h>
39 #include <sys/mac_soft_ring.h>
40 #include <sys/vlan.h>
41
42 #define MAC_KSTAT_NAME "mac"
43 #define MAC_KSTAT_CLASS "net"
44
987 uint64_t
988 mac_driver_stat_default(mac_impl_t *mip, uint_t stat)
989 {
990 uint_t stat_index;
991
992 if (IS_MAC_STAT(stat)) {
993 stat_index = stat - MAC_STAT_MIN;
994 ASSERT(stat_index < MAC_NKSTAT);
995 return (i_mac_si[stat_index].msi_default);
996 }
997 ASSERT(IS_MACTYPE_STAT(stat));
998 stat_index = stat - MACTYPE_STAT_MIN;
999 ASSERT(stat_index < mip->mi_type->mt_statcount);
1000 return (mip->mi_type->mt_stats[stat_index].msi_default);
1001 }
1002
1003 void
1004 mac_ring_stat_create(mac_ring_t *ring)
1005 {
1006 mac_impl_t *mip = ring->mr_mip;
1007 mac_group_t *grp = (mac_group_t *)ring->mr_gh;
1008 char statname[MAXNAMELEN];
1009 char modname[MAXNAMELEN];
1010
1011 if (mip->mi_state_flags & MIS_IS_AGGR) {
1012 (void) strlcpy(modname, mip->mi_clients_list->mci_name,
1013 MAXNAMELEN);
1014 } else
1015 (void) strlcpy(modname, mip->mi_name, MAXNAMELEN);
1016
1017 switch (ring->mr_type) {
1018 case MAC_RING_TYPE_RX:
1019 (void) snprintf(statname, sizeof (statname),
1020 "mac_rx_ring_%d_%d", grp->mrg_index, ring->mr_index);
1021 i_mac_rx_ring_stat_create(ring, modname, statname);
1022 break;
1023
1024 case MAC_RING_TYPE_TX:
1025 (void) snprintf(statname, sizeof (statname), "mac_tx_ring%d",
1026 ring->mr_index);
1027 i_mac_tx_ring_stat_create(ring, modname, statname);
1028 break;
1029
1030 default:
1031 ASSERT(B_FALSE);
1032 break;
1033 }
1034 }
1035
1036 void
1037 mac_srs_stat_create(mac_soft_ring_set_t *mac_srs)
1038 {
1039 flow_entry_t *flent = mac_srs->srs_flent;
1040 char statname[MAXNAMELEN];
|