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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/ipp/ipgpc/filters.c
          +++ new/usr/src/uts/common/ipp/ipgpc/filters.c
↓ open down ↓ 267 lines elided ↑ open up ↑
 268  268  initialize_ba_tables(void)
 269  269  {
 270  270          /* DS (ToS/Traffic Class) field structure */
 271  271          ipgpc_ds_table_id.info.mask = DS_MASK;
 272  272          ipgpc_ds_table_id.info.dontcareonly = B_TRUE;
 273  273  }
 274  274  
 275  275  static void
 276  276  element_node_ref(element_node_t *element)
 277  277  {
 278      -        atomic_add_32(&element->element_refcnt, 1);
      278 +        atomic_inc_32(&element->element_refcnt);
 279  279          ASSERT(element->element_refcnt > 1);
 280  280  }
 281  281  
 282  282  static void
 283  283  element_node_unref(element_node_t *element)
 284  284  {
 285  285          ASSERT(element->element_refcnt > 0);
 286      -        if (atomic_add_32_nv(&element->element_refcnt, -1) == 0) {
      286 +        if (atomic_dec_32_nv(&element->element_refcnt) == 0) {
 287  287                  kmem_cache_free(element_node_cache, element);
 288  288          }
 289  289  }
 290  290  
 291  291  /* ARGSUSED1 */
 292  292  static int
 293  293  element_node_cache_constructor(void *buf, void *cdrarg, int kmflags)
 294  294  {
 295  295          element_node_t *node = buf;
 296  296  
↓ open down ↓ 832 lines elided ↑ open up ↑
1129 1129                  reset_dontcare_stats(); /* need to fixup stats */
1130 1130                  mutex_exit(&ipgpc_fid_list_lock);
1131 1131                  return (EINVAL);
1132 1132          } else {                /* associate filter with class */
1133 1133                  mutex_enter(&ipgpc_cid_list_lock);
1134 1134                  (void) ipgpc_list_insert(&ipgpc_cid_list[class_id].filter_list,
1135 1135                      filter_id);
1136 1136                  mutex_exit(&ipgpc_cid_list_lock);
1137 1137          }
1138 1138          mutex_exit(&ipgpc_fid_list_lock);
1139      -        atomic_add_long(&ipgpc_num_fltrs, 1);
     1139 +        atomic_inc_ulong(&ipgpc_num_fltrs);
1140 1140          ipgpc3dbg(("ipgpc_addfilter: adding filter %s", filter->filter_name));
1141 1141          return (0);
1142 1142  }
1143 1143  
1144 1144  /*
1145 1145   * reset_dontcare_stats()
1146 1146   *
1147 1147   * when an insertion fails because zero selectors are specified in a filter
1148 1148   * the number of dontcare's recorded for each selector structure needs to be
1149 1149   * decremented
1150 1150   */
1151 1151  static void
1152 1152  reset_dontcare_stats(void)
1153 1153  {
1154 1154          int i;
1155 1155  
1156 1156          for (i = 0; i < NUM_TRIES; ++i) {
1157      -                atomic_add_32(&ipgpc_trie_list[i].stats.num_dontcare, -1);
     1157 +                atomic_dec_32(&ipgpc_trie_list[i].stats.num_dontcare);
1158 1158          }
1159 1159          for (i = 0; i < NUM_TABLES; ++i) {
1160      -                atomic_add_32(&ipgpc_table_list[i].stats.num_dontcare, -1);
     1160 +                atomic_dec_32(&ipgpc_table_list[i].stats.num_dontcare);
1161 1161          }
1162      -        atomic_add_32(&ipgpc_ds_table_id.stats.num_dontcare, -1);
     1162 +        atomic_dec_32(&ipgpc_ds_table_id.stats.num_dontcare);
1163 1163  }
1164 1164  
1165 1165  /*
1166 1166   * ipgpc_parse_class(out_class, nvlp)
1167 1167   *
1168 1168   * Given a name value pair list, a class structure will be parsed.
1169 1169   * To be a valid class, the class name, originator id and next action name
1170 1170   * must be present. gather_stats is optional, if absent default value is used
1171 1171   */
1172 1172  int
↓ open down ↓ 177 lines elided ↑ open up ↑
1350 1350                                  return (rc);
1351 1351                          }
1352 1352                  } else {
1353 1353                          ipgpc_cid_list[class_id].cl_stats = NULL;
1354 1354                  }
1355 1355                  ipgpc3dbg(("insertcid: adding class %s",
1356 1356                      in_class->class_name));
1357 1357                  bcopy(in_class->class_name,
1358 1358                      ipgpc_cid_list[class_id].aclass.class_name, MAXNAMELEN);
1359 1359                  ipgpc_cid_list[class_id].filter_list = NULL;
1360      -                atomic_add_long(&ipgpc_num_cls, 1);
     1360 +                atomic_inc_ulong(&ipgpc_num_cls);
1361 1361          } else {
1362 1362                  ipgpc0dbg(("insertcid: class name lookup error %d", err));
1363 1363                  mutex_exit(&ipgpc_cid_list_lock);
1364 1364                  return (err);
1365 1365          }
1366 1366          mutex_exit(&ipgpc_cid_list_lock);
1367 1367          *out_class_id = class_id;
1368 1368          return (err);
1369 1369  }
1370 1370  
↓ open down ↓ 126 lines elided ↑ open up ↑
1497 1497          }
1498 1498          /* remove filter from filter list */
1499 1499          ipgpc_fid_list[filter_id].info = -1;
1500 1500          ipgpc_fid_list[filter_id].insert_map = 0;
1501 1501          ipgpc_fid_list[filter_id].filter.filter_name[0] = '\0';
1502 1502          ipgpc_filter_destructor(&ipgpc_fid_list[filter_id].filter);
1503 1503          mutex_exit(&ipgpc_fid_list_lock);
1504 1504          /* remove filter id from class' list of filters */
1505 1505          remove_from_cid_filter_list(ipgpc_fid_list[filter_id].class_id,
1506 1506              filter_id);
1507      -        atomic_add_long(&ipgpc_num_fltrs, -1);
     1507 +        atomic_dec_ulong(&ipgpc_num_fltrs);
1508 1508          return (0);
1509 1509  }
1510 1510  
1511 1511  /*
1512 1512   * removecid(in_class_id)
1513 1513   *
1514 1514   * removes the cid entry from the cid list and frees allocated structures
1515 1515   */
1516 1516  static void
1517 1517  removecid(int in_class_id)
1518 1518  {
1519 1519          ipgpc_cid_list[in_class_id].info = -1;
1520 1520          ipgpc_cid_list[in_class_id].aclass.class_name[0] = '\0';
1521 1521          ipgpc_cid_list[in_class_id].aclass.next_action = -1;
1522 1522          /* delete kstat entry */
1523 1523          if (ipgpc_cid_list[in_class_id].cl_stats != NULL) {
1524 1524                  ipp_stat_destroy(ipgpc_cid_list[in_class_id].cl_stats);
1525 1525                  ipgpc_cid_list[in_class_id].cl_stats = NULL;
1526 1526          }
1527 1527          /* decrement total number of classes loaded */
1528      -        atomic_add_long(&ipgpc_num_cls, -1);
     1528 +        atomic_dec_ulong(&ipgpc_num_cls);
1529 1529  }
1530 1530  
1531 1531  /*
1532 1532   * remove_from_cid_filter_list(in_class_id, in_filter_id)
1533 1533   *
1534 1534   * removes the input filter_id from the filter_list of the class associated
1535 1535   * with the input class_id
1536 1536   */
1537 1537  static void
1538 1538  remove_from_cid_filter_list(int in_class_id, int in_filter_id)
↓ open down ↓ 1146 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX