Print this page
11493 aggr needs support for multiple pseudo rx groups
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/mac/mac_stat.c
          +++ new/usr/src/uts/common/io/mac/mac_stat.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2018 Joyent, Inc.
  24   25   */
  25   26  
  26   27  /*
  27   28   * MAC Services Module
  28   29   */
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/sysmacros.h>
  32   33  #include <sys/stream.h>
  33   34  #include <sys/kstat.h>
↓ open down ↓ 220 lines elided ↑ open up ↑
 254  255          {RX_SRS_STAT_OFF(mrs_pollcnt)},
 255  256          {RX_SRS_STAT_OFF(mrs_pollbytes)},
 256  257          {RX_SRS_STAT_OFF(mrs_intrcnt)},
 257  258          {RX_SRS_STAT_OFF(mrs_intrbytes)},
 258  259          {RX_SRS_STAT_OFF(mrs_sdrops)},
 259  260          {RX_SRS_STAT_OFF(mrs_chaincntundr10)},
 260  261          {RX_SRS_STAT_OFF(mrs_chaincnt10to50)},
 261  262          {RX_SRS_STAT_OFF(mrs_chaincntover50)},
 262  263          {RX_SRS_STAT_OFF(mrs_ierrors)}
 263  264  };
 264      -#define RX_SRS_STAT_SIZE                \
      265 +#define RX_SRS_STAT_SIZE                \
 265  266          (sizeof (rx_srs_stats_list) / sizeof (stat_info_t))
 266  267  
 267  268  #define TX_SOFTRING_STAT_OFF(f) (offsetof(mac_tx_stats_t, f))
 268  269  static stat_info_t tx_softring_stats_list[] = {
 269  270          {TX_SOFTRING_STAT_OFF(mts_obytes)},
 270  271          {TX_SOFTRING_STAT_OFF(mts_opackets)},
 271  272          {TX_SOFTRING_STAT_OFF(mts_oerrors)},
 272  273          {TX_SOFTRING_STAT_OFF(mts_blockcnt)},
 273  274          {TX_SOFTRING_STAT_OFF(mts_unblockcnt)},
 274  275          {TX_SOFTRING_STAT_OFF(mts_sdrops)},
 275  276  };
 276      -#define TX_SOFTRING_STAT_SIZE           \
      277 +#define TX_SOFTRING_STAT_SIZE           \
 277  278          (sizeof (tx_softring_stats_list) / sizeof (stat_info_t))
 278  279  
 279  280  static void
 280  281  i_mac_add_stats(void *sum, void *op1, void *op2,
 281  282      stat_info_t stats_list[], uint_t size)
 282  283  {
 283      -        int     i;
      284 +        int     i;
 284  285  
 285  286          for (i = 0; i < size; i++) {
 286  287                  uint64_t *op1_val = (uint64_t *)
 287  288                      ((uchar_t *)op1 + stats_list[i].si_offset);
 288  289                  uint64_t *op2_val = (uint64_t *)
 289  290                      ((uchar_t *)op2 + stats_list[i].si_offset);
 290  291                  uint64_t *sum_val = (uint64_t *)
 291  292                      ((uchar_t *)sum + stats_list[i].si_offset);
 292  293  
 293  294                  *sum_val =  *op1_val + *op2_val;
↓ open down ↓ 377 lines elided ↑ open up ↑
 671  672  /*
 672  673   * Misc statistics
 673  674   *
 674  675   * Counts for
 675  676   *      - Multicast/broadcast Rx/Tx counts
 676  677   *      - Tx errors
 677  678   */
 678  679  static uint64_t
 679  680  i_mac_misc_stat_get(void *handle, uint_t stat)
 680  681  {
 681      -        flow_entry_t            *flent = handle;
 682      -        mac_client_impl_t       *mcip = flent->fe_mcip;
      682 +        flow_entry_t            *flent = handle;
      683 +        mac_client_impl_t       *mcip = flent->fe_mcip;
 683  684          mac_misc_stats_t        *mac_misc_stat = &mcip->mci_misc_stat;
 684  685          mac_rx_stats_t          *mac_rx_stat;
 685  686          mac_tx_stats_t          *mac_tx_stat;
 686  687  
 687  688          mac_rx_stat = &mac_misc_stat->mms_defunctrxlanestats;
 688  689          mac_tx_stat = &mac_misc_stat->mms_defuncttxlanestats;
 689  690  
 690  691          switch (stat) {
 691  692          case MAC_STAT_MULTIRCV:
 692  693                  return (mac_misc_stat->mms_multircv);
↓ open down ↓ 170 lines elided ↑ open up ↑
 863  864  
 864  865          ringp->s_ring_ksp = ksp;
 865  866  }
 866  867  
 867  868  /*
 868  869   * Per fanout rx statistics
 869  870   */
 870  871  static uint64_t
 871  872  i_mac_rx_fanout_stat_get(void *handle, uint_t stat)
 872  873  {
 873      -        mac_soft_ring_t         *tcp_ringp = (mac_soft_ring_t *)handle;
      874 +        mac_soft_ring_t         *tcp_ringp = (mac_soft_ring_t *)handle;
 874  875          mac_soft_ring_t         *udp_ringp = NULL, *oth_ringp = NULL;
 875      -        mac_soft_ring_set_t     *mac_srs = tcp_ringp->s_ring_set;
      876 +        mac_soft_ring_set_t     *mac_srs = tcp_ringp->s_ring_set;
 876  877          int                     index;
 877  878          uint64_t                val;
 878  879  
 879  880          mutex_enter(&mac_srs->srs_lock);
 880  881          /* Extract corresponding udp and oth ring pointers */
 881  882          for (index = 0; mac_srs->srs_tcp_soft_rings[index] != NULL; index++) {
 882  883                  if (mac_srs->srs_tcp_soft_rings[index] == tcp_ringp) {
 883  884                          udp_ringp = mac_srs->srs_udp_soft_rings[index];
 884  885                          oth_ringp = mac_srs->srs_oth_soft_rings[index];
 885  886                          break;
↓ open down ↓ 110 lines elided ↑ open up ↑
 996  997          ASSERT(IS_MACTYPE_STAT(stat));
 997  998          stat_index = stat - MACTYPE_STAT_MIN;
 998  999          ASSERT(stat_index < mip->mi_type->mt_statcount);
 999 1000          return (mip->mi_type->mt_stats[stat_index].msi_default);
1000 1001  }
1001 1002  
1002 1003  void
1003 1004  mac_ring_stat_create(mac_ring_t *ring)
1004 1005  {
1005 1006          mac_impl_t      *mip = ring->mr_mip;
     1007 +        mac_group_t     *grp = (mac_group_t *)ring->mr_gh;
1006 1008          char            statname[MAXNAMELEN];
1007 1009          char            modname[MAXNAMELEN];
1008 1010  
1009 1011          if (mip->mi_state_flags & MIS_IS_AGGR) {
1010 1012                  (void) strlcpy(modname, mip->mi_clients_list->mci_name,
1011 1013                      MAXNAMELEN);
1012 1014          } else
1013 1015                  (void) strlcpy(modname, mip->mi_name, MAXNAMELEN);
1014 1016  
1015 1017          switch (ring->mr_type) {
1016 1018          case MAC_RING_TYPE_RX:
1017      -                (void) snprintf(statname, sizeof (statname), "mac_rx_ring%d",
1018      -                    ring->mr_index);
     1019 +                (void) snprintf(statname, sizeof (statname),
     1020 +                    "mac_rx_ring_%d_%d", grp->mrg_index, ring->mr_index);
1019 1021                  i_mac_rx_ring_stat_create(ring, modname, statname);
1020 1022                  break;
1021 1023  
1022 1024          case MAC_RING_TYPE_TX:
1023 1025                  (void) snprintf(statname, sizeof (statname), "mac_tx_ring%d",
1024 1026                      ring->mr_index);
1025 1027                  i_mac_tx_ring_stat_create(ring, modname, statname);
1026 1028                  break;
1027 1029  
1028 1030          default:
1029 1031                  ASSERT(B_FALSE);
1030 1032                  break;
1031 1033          }
1032 1034  }
1033 1035  
1034 1036  void
1035 1037  mac_srs_stat_create(mac_soft_ring_set_t *mac_srs)
1036 1038  {
1037 1039          flow_entry_t    *flent = mac_srs->srs_flent;
1038      -        char            statname[MAXNAMELEN];
     1040 +        char            statname[MAXNAMELEN];
1039 1041          boolean_t       is_tx_srs;
1040 1042  
1041 1043          /* No hardware/software lanes for user defined flows */
1042 1044          if ((flent->fe_type & FLOW_USER) != 0)
1043 1045                  return;
1044 1046  
1045 1047          is_tx_srs = ((mac_srs->srs_type & SRST_TX) != 0);
1046 1048  
1047 1049          if (is_tx_srs) {
1048 1050                  mac_srs_tx_t    *srs_tx = &mac_srs->srs_tx;
↓ open down ↓ 246 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX