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


  49  * This module does not free any mblks or packets in case or errors.
  50  */
  51 
  52 int
  53 dlcosmk_process(mblk_t **mpp, dlcosmk_data_t *dlcosmk_data, uint32_t ill_index,
  54     ip_proc_t proc)
  55 {
  56         ill_t *ill = NULL;
  57         mblk_t *mp;
  58 
  59         ASSERT((mpp != NULL) && (*mpp != NULL));
  60         mp = *mpp;
  61 
  62         /*
  63          * The action module will receive an M_DATA or an M_CTL followed
  64          * by an M_DATA. In the latter case skip the M_CTL.
  65          */
  66         if (mp->b_datap->db_type != M_DATA) {
  67                 if ((mp->b_cont == NULL) ||
  68                     (mp->b_cont->b_datap->db_type != M_DATA)) {
  69                         atomic_add_64(&dlcosmk_data->epackets, 1);
  70                         dlcosmk0dbg(("dlcosmk_process: no data\n"));
  71                         return (EINVAL);
  72                 }
  73         }
  74 
  75         /* Update global stats */
  76         atomic_add_64(&dlcosmk_data->npackets, 1);
  77 
  78         /*
  79          * This should only be called for outgoing packets. For inbound, just
  80          * send it along.
  81          */
  82         if ((proc == IPP_LOCAL_IN) || (proc == IPP_FWD_IN)) {
  83                 dlcosmk2dbg(("dlcosmk_process:cannot mark incoming packets\n"));
  84                 atomic_add_64(&dlcosmk_data->ipackets, 1);
  85                 return (0);
  86         }
  87 
  88         if ((ill_index == 0) ||
  89             ((ill = ill_lookup_on_ifindex_global_instance(ill_index,
  90             B_FALSE)) == NULL)) {
  91                 dlcosmk2dbg(("dlcosmk_process:invalid ill index %u\n",
  92                     ill_index));
  93                 atomic_add_64(&dlcosmk_data->ipackets, 1);
  94                 return (0);
  95         }
  96 
  97         /*
  98          * Check if the interface supports CoS marking. If not send it to the
  99          * next action in the chain
 100          */
 101         if (!(ill->ill_flags & ILLF_COS_ENABLED)) {
 102                 dlcosmk2dbg(("dlcosmk_process:ill %u does not support CoS\n",
 103                     ill_index));
 104                 atomic_add_64(&dlcosmk_data->ipackets, 1);
 105                 ill_refrele(ill);
 106                 return (0);
 107         }
 108         ill_refrele(ill);
 109 
 110 
 111         /*
 112          * Mark the b_band for fastpath messages or dl_priority.dl_max for
 113          * DL_UNITDATA_REQ messages. For, others just pass it along.
 114          */
 115         switch (DB_TYPE(mp)) {
 116                 case M_PROTO:
 117                 case M_PCPROTO:
 118                         {       /* DL_UNITDATA */
 119                                 dl_unitdata_req_t *dlur;
 120                                 dlur = (dl_unitdata_req_t *)mp->b_rptr;
 121 
 122                                 /* DL_UNITDATA message?? */
 123                                 if (dlur->dl_primitive == DL_UNITDATA_REQ) {
 124                                         dlur->dl_priority.dl_max =
 125                                             dlcosmk_data->dl_max;
 126                                 } else {
 127                                         atomic_add_64(&dlcosmk_data->ipackets,
 128                                             1);
 129                                 }
 130                                 break;
 131                         }
 132                 case M_DATA:
 133                         /* fastpath message */
 134                         mp->b_band = dlcosmk_data->b_band;
 135                         break;
 136                 default:
 137                         atomic_add_64(&dlcosmk_data->ipackets, 1);
 138                         break;
 139         }
 140 
 141         return (0);
 142 }


  49  * This module does not free any mblks or packets in case or errors.
  50  */
  51 
  52 int
  53 dlcosmk_process(mblk_t **mpp, dlcosmk_data_t *dlcosmk_data, uint32_t ill_index,
  54     ip_proc_t proc)
  55 {
  56         ill_t *ill = NULL;
  57         mblk_t *mp;
  58 
  59         ASSERT((mpp != NULL) && (*mpp != NULL));
  60         mp = *mpp;
  61 
  62         /*
  63          * The action module will receive an M_DATA or an M_CTL followed
  64          * by an M_DATA. In the latter case skip the M_CTL.
  65          */
  66         if (mp->b_datap->db_type != M_DATA) {
  67                 if ((mp->b_cont == NULL) ||
  68                     (mp->b_cont->b_datap->db_type != M_DATA)) {
  69                         atomic_inc_64(&dlcosmk_data->epackets);
  70                         dlcosmk0dbg(("dlcosmk_process: no data\n"));
  71                         return (EINVAL);
  72                 }
  73         }
  74 
  75         /* Update global stats */
  76         atomic_inc_64(&dlcosmk_data->npackets);
  77 
  78         /*
  79          * This should only be called for outgoing packets. For inbound, just
  80          * send it along.
  81          */
  82         if ((proc == IPP_LOCAL_IN) || (proc == IPP_FWD_IN)) {
  83                 dlcosmk2dbg(("dlcosmk_process:cannot mark incoming packets\n"));
  84                 atomic_inc_64(&dlcosmk_data->ipackets);
  85                 return (0);
  86         }
  87 
  88         if ((ill_index == 0) ||
  89             ((ill = ill_lookup_on_ifindex_global_instance(ill_index,
  90             B_FALSE)) == NULL)) {
  91                 dlcosmk2dbg(("dlcosmk_process:invalid ill index %u\n",
  92                     ill_index));
  93                 atomic_inc_64(&dlcosmk_data->ipackets);
  94                 return (0);
  95         }
  96 
  97         /*
  98          * Check if the interface supports CoS marking. If not send it to the
  99          * next action in the chain
 100          */
 101         if (!(ill->ill_flags & ILLF_COS_ENABLED)) {
 102                 dlcosmk2dbg(("dlcosmk_process:ill %u does not support CoS\n",
 103                     ill_index));
 104                 atomic_inc_64(&dlcosmk_data->ipackets);
 105                 ill_refrele(ill);
 106                 return (0);
 107         }
 108         ill_refrele(ill);
 109 
 110 
 111         /*
 112          * Mark the b_band for fastpath messages or dl_priority.dl_max for
 113          * DL_UNITDATA_REQ messages. For, others just pass it along.
 114          */
 115         switch (DB_TYPE(mp)) {
 116                 case M_PROTO:
 117                 case M_PCPROTO:
 118                         {       /* DL_UNITDATA */
 119                                 dl_unitdata_req_t *dlur;
 120                                 dlur = (dl_unitdata_req_t *)mp->b_rptr;
 121 
 122                                 /* DL_UNITDATA message?? */
 123                                 if (dlur->dl_primitive == DL_UNITDATA_REQ) {
 124                                         dlur->dl_priority.dl_max =
 125                                             dlcosmk_data->dl_max;
 126                                 } else {
 127                                         atomic_inc_64(&dlcosmk_data->ipackets);

 128                                 }
 129                                 break;
 130                         }
 131                 case M_DATA:
 132                         /* fastpath message */
 133                         mp->b_band = dlcosmk_data->b_band;
 134                         break;
 135                 default:
 136                         atomic_inc_64(&dlcosmk_data->ipackets);
 137                         break;
 138         }
 139 
 140         return (0);
 141 }