Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*
*** 22,33 ****
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
- #pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/random.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
--- 22,31 ----
*** 72,101 ****
uint32_t min = 0, additive, rnd;
tswtcl_cfg_t *cfg_parms = tswtcl_data->cfg_parms;
if (mp == NULL) {
tswtcl0dbg(("tswtcl_process: null mp!\n"));
! atomic_add_64(&tswtcl_data->epackets, 1);
return (EINVAL);
}
if (mp->b_datap->db_type != M_DATA) {
if ((mp->b_cont != NULL) &&
(mp->b_cont->b_datap->db_type == M_DATA)) {
mp = mp->b_cont;
} else {
tswtcl0dbg(("tswtcl_process: no data\n"));
! atomic_add_64(&tswtcl_data->epackets, 1);
return (EINVAL);
}
}
/* Figure out the ToS/Traffic Class and length from the message */
if ((mp->b_wptr - mp->b_rptr) < IP_SIMPLE_HDR_LENGTH) {
if (!pullupmsg(mp, IP_SIMPLE_HDR_LENGTH)) {
tswtcl0dbg(("tswtcl_process: pullup error\n"));
! atomic_add_64(&tswtcl_data->epackets, 1);
return (EINVAL);
}
}
ipha = (ipha_t *)mp->b_rptr;
if (IPH_HDR_VERSION(ipha) == IPV4_VERSION) {
--- 70,99 ----
uint32_t min = 0, additive, rnd;
tswtcl_cfg_t *cfg_parms = tswtcl_data->cfg_parms;
if (mp == NULL) {
tswtcl0dbg(("tswtcl_process: null mp!\n"));
! atomic_inc_64(&tswtcl_data->epackets);
return (EINVAL);
}
if (mp->b_datap->db_type != M_DATA) {
if ((mp->b_cont != NULL) &&
(mp->b_cont->b_datap->db_type == M_DATA)) {
mp = mp->b_cont;
} else {
tswtcl0dbg(("tswtcl_process: no data\n"));
! atomic_inc_64(&tswtcl_data->epackets);
return (EINVAL);
}
}
/* Figure out the ToS/Traffic Class and length from the message */
if ((mp->b_wptr - mp->b_rptr) < IP_SIMPLE_HDR_LENGTH) {
if (!pullupmsg(mp, IP_SIMPLE_HDR_LENGTH)) {
tswtcl0dbg(("tswtcl_process: pullup error\n"));
! atomic_inc_64(&tswtcl_data->epackets);
return (EINVAL);
}
}
ipha = (ipha_t *)mp->b_rptr;
if (IPH_HDR_VERSION(ipha) == IPV4_VERSION) {
*** 182,198 ****
}
mutex_exit(&tswtcl_data->tswtcl_lock);
/* Update Stats */
if (*next_action == cfg_parms->green_action) {
! atomic_add_64(&tswtcl_data->green_packets, 1);
atomic_add_64(&tswtcl_data->green_bits, pkt_len);
} else if (*next_action == cfg_parms->yellow_action) {
! atomic_add_64(&tswtcl_data->yellow_packets, 1);
atomic_add_64(&tswtcl_data->yellow_bits, pkt_len);
} else {
ASSERT(*next_action == cfg_parms->red_action);
! atomic_add_64(&tswtcl_data->red_packets, 1);
atomic_add_64(&tswtcl_data->red_bits, pkt_len);
}
return (0);
}
--- 180,196 ----
}
mutex_exit(&tswtcl_data->tswtcl_lock);
/* Update Stats */
if (*next_action == cfg_parms->green_action) {
! atomic_inc_64(&tswtcl_data->green_packets);
atomic_add_64(&tswtcl_data->green_bits, pkt_len);
} else if (*next_action == cfg_parms->yellow_action) {
! atomic_inc_64(&tswtcl_data->yellow_packets);
atomic_add_64(&tswtcl_data->yellow_bits, pkt_len);
} else {
ASSERT(*next_action == cfg_parms->red_action);
! atomic_inc_64(&tswtcl_data->red_packets);
atomic_add_64(&tswtcl_data->red_bits, pkt_len);
}
return (0);
}