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

@@ -494,13 +494,13 @@
                  * For all practical purposes, we limit the no. of entries in
                  * the flow table - i.e. the max_limt that a user specifies is
                  * the maximum no. of flow items in the table.
                  */
         try_again:
-                atomic_add_32(&flowacct_data->nflows, 1);
+                atomic_inc_32(&flowacct_data->nflows);
                 if (flowacct_data->nflows > flowacct_data->max_limit) {
-                        atomic_add_32(&flowacct_data->nflows, -1);
+                        atomic_dec_32(&flowacct_data->nflows);
 
                         /* Try timing out once */
                         if (just_once) {
                                 /*
                                  * Need to release the lock, as this entry

@@ -534,11 +534,11 @@
                         if (added_flow) {
                                 flowacct_del_obj(fhead, flow->hdr,
                                     FLOWACCT_DEL_OBJ);
                         }
                         mutex_exit(&fhead->lock);
-                        atomic_add_32(&flowacct_data->nflows, -1);
+                        atomic_dec_32(&flowacct_data->nflows);
                         flowacct0dbg(("flowacct_update_flows_tbl: mem alloc "\
                             "error"));
                         return (-1);
                 }
                 item->hdr = flowacct_add_obj(ihead, ihead->tail, (void *)item);

@@ -548,11 +548,11 @@
                         if (added_flow) {
                                 flowacct_del_obj(fhead, flow->hdr,
                                     FLOWACCT_DEL_OBJ);
                         }
                         mutex_exit(&fhead->lock);
-                        atomic_add_32(&flowacct_data->nflows, -1);
+                        atomic_dec_32(&flowacct_data->nflows);
                         kmem_free(item, FLOWACCT_ITEM_SZ);
                         flowacct0dbg(("flowacct_update_flows_tbl: mem alloc "\
                             "error\n"));
                         return (-1);
                 }

@@ -885,38 +885,38 @@
                 if ((mp->b_cont != NULL) &&
                     (mp->b_cont->b_datap->db_type == M_DATA)) {
                         mp = mp->b_cont;
                 } else {
                         flowacct0dbg(("flowacct_process: no data\n"));
-                        atomic_add_64(&flowacct_data->epackets, 1);
+                        atomic_inc_64(&flowacct_data->epackets);
                         return (EINVAL);
                 }
         }
 
         header = kmem_zalloc(FLOWACCT_HEADER_SZ, KM_NOSLEEP);
         if (header == NULL) {
                 flowacct0dbg(("flowacct_process: error allocing mem"));
-                atomic_add_64(&flowacct_data->epackets, 1);
+                atomic_inc_64(&flowacct_data->epackets);
                 return (ENOMEM);
         }
 
         /* Get all the required information into header. */
         if (flowacct_extract_header(mp, header) != 0) {
                 kmem_free(header, FLOWACCT_HEADER_SZ);
-                atomic_add_64(&flowacct_data->epackets, 1);
+                atomic_inc_64(&flowacct_data->epackets);
                 return (EINVAL);
         }
 
         /* Updated the flow table with this entry */
         if (flowacct_update_flows_tbl(header, flowacct_data) != 0) {
                 kmem_free(header, FLOWACCT_HEADER_SZ);
-                atomic_add_64(&flowacct_data->epackets, 1);
+                atomic_inc_64(&flowacct_data->epackets);
                 return (ENOMEM);
         }
 
         /* Update global stats */
-        atomic_add_64(&flowacct_data->npackets, 1);
+        atomic_inc_64(&flowacct_data->npackets);
         atomic_add_64(&flowacct_data->nbytes, header->pktlen);
 
         kmem_free(header, FLOWACCT_HEADER_SZ);
         if (flowacct_data->flow_tid == 0) {
                 flowacct_data->flow_tid = timeout(flowacct_timeout_flows,