Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/ipp/meters/tokenmt.c
          +++ new/usr/src/uts/common/ipp/meters/tokenmt.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <sys/types.h>
  30   28  #include <sys/kmem.h>
  31   29  #include <sys/conf.h>
  32   30  #include <sys/sysmacros.h>
  33   31  #include <netinet/in.h>
  34   32  #include <netinet/in_systm.h>
  35   33  #include <netinet/ip6.h>
  36   34  #include <inet/common.h>
  37   35  #include <inet/ip.h>
  38   36  #include <inet/ip6.h>
↓ open down ↓ 38 lines elided ↑ open up ↑
  77   75          ipha_t *ipha;
  78   76          ip6_t *ip6_hdr;
  79   77          uint32_t pkt_len;
  80   78          mblk_t *mp = *mpp;
  81   79          hrtime_t now;
  82   80          enum meter_colour colour;
  83   81          tokenmt_cfg_t *cfg_parms = tokenmt_data->cfg_parms;
  84   82  
  85   83          if (mp == NULL) {
  86   84                  tokenmt0dbg(("tokenmt_process: null mp!\n"));
  87      -                atomic_add_64(&tokenmt_data->epackets, 1);
       85 +                atomic_inc_64(&tokenmt_data->epackets);
  88   86                  return (EINVAL);
  89   87          }
  90   88  
  91   89          if (mp->b_datap->db_type != M_DATA) {
  92   90                  if ((mp->b_cont != NULL) &&
  93   91                      (mp->b_cont->b_datap->db_type == M_DATA)) {
  94   92                          mp = mp->b_cont;
  95   93                  } else {
  96   94                          tokenmt0dbg(("tokenmt_process: no data\n"));
  97      -                        atomic_add_64(&tokenmt_data->epackets, 1);
       95 +                        atomic_inc_64(&tokenmt_data->epackets);
  98   96                          return (EINVAL);
  99   97                  }
 100   98          }
 101   99  
 102  100          /* Figure out the ToS/Traffic Class and length from the message */
 103  101          if ((mp->b_wptr - mp->b_rptr) < IP_SIMPLE_HDR_LENGTH) {
 104  102                  if (!pullupmsg(mp, IP_SIMPLE_HDR_LENGTH)) {
 105  103                          tokenmt0dbg(("tokenmt_process: pullup error\n"));
 106      -                        atomic_add_64(&tokenmt_data->epackets, 1);
      104 +                        atomic_inc_64(&tokenmt_data->epackets);
 107  105                          return (EINVAL);
 108  106                  }
 109  107          }
 110  108          ipha = (ipha_t *)mp->b_rptr;
 111  109          if (IPH_HDR_VERSION(ipha) == IPV4_VERSION) {
 112  110                  /* discard last 2 unused bits */
 113  111                  dscp = ipha->ipha_type_of_service;
 114  112                  pkt_len = ntohs(ipha->ipha_length);
 115  113          } else {
 116  114                  ip6_hdr = (ip6_t *)mp->b_rptr;
↓ open down ↓ 94 lines elided ↑ open up ↑
 211  209                                  tokenmt_data->committed_tokens -= pkt_len;
 212  210                                  tokenmt_data->peak_tokens -= pkt_len;
 213  211                                  *next_action = cfg_parms->green_action;
 214  212                          }
 215  213                  }
 216  214          }
 217  215          mutex_exit(&tokenmt_data->tokenmt_lock);
 218  216  
 219  217          /* Update Stats */
 220  218          if (*next_action == cfg_parms->green_action) {
 221      -                atomic_add_64(&tokenmt_data->green_packets, 1);
      219 +                atomic_inc_64(&tokenmt_data->green_packets);
 222  220                  atomic_add_64(&tokenmt_data->green_bits, pkt_len);
 223  221          } else if (*next_action == cfg_parms->yellow_action) {
 224      -                atomic_add_64(&tokenmt_data->yellow_packets, 1);
      222 +                atomic_inc_64(&tokenmt_data->yellow_packets);
 225  223                  atomic_add_64(&tokenmt_data->yellow_bits, pkt_len);
 226  224          } else {
 227  225                  ASSERT(*next_action == cfg_parms->red_action);
 228      -                atomic_add_64(&tokenmt_data->red_packets, 1);
      226 +                atomic_inc_64(&tokenmt_data->red_packets);
 229  227                  atomic_add_64(&tokenmt_data->red_bits, pkt_len);
 230  228          }
 231  229  
 232  230          return (0);
 233  231  }
 234  232  
 235  233  void
 236  234  tokenmt_update_tokens(tokenmt_data_t *tokenmt_data, hrtime_t now)
 237  235  {
 238  236          tokenmt_cfg_t *cfg_parms = (tokenmt_cfg_t *)tokenmt_data->cfg_parms;
↓ open down ↓ 48 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX