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


 217         aggr_pseudo_tx_group_t  lg_tx_group;
 218 
 219         kmutex_t        lg_tx_flowctl_lock;
 220         kcondvar_t      lg_tx_flowctl_cv;
 221         uint_t          lg_tx_blocked_cnt;
 222         mac_ring_handle_t       *lg_tx_blocked_rings;
 223         kthread_t       *lg_tx_notify_thread;
 224         boolean_t       lg_tx_notify_done;
 225 
 226         /*
 227          * The following fields are used by aggr to wait for all the
 228          * aggr_port_notify_cb() and aggr_port_timer_thread() to finish
 229          * before it calls mac_unregister() when the aggr is deleted.
 230          */
 231         kmutex_t        lg_port_lock;
 232         kcondvar_t      lg_port_cv;
 233         int             lg_port_ref;
 234 } aggr_grp_t;
 235 
 236 #define AGGR_GRP_REFHOLD(grp) {                 \
 237         atomic_add_32(&(grp)->lg_refs, 1);       \
 238         ASSERT((grp)->lg_refs != 0);         \
 239 }
 240 
 241 #define AGGR_GRP_REFRELE(grp) {                                 \
 242         ASSERT((grp)->lg_refs != 0);                         \
 243         membar_exit();                                          \
 244         if (atomic_add_32_nv(&(grp)->lg_refs, -1) == 0)          \
 245                 aggr_grp_free(grp);                             \
 246 }
 247 
 248 #define AGGR_PORT_REFHOLD(port) {               \
 249         atomic_add_32(&(port)->lp_refs, 1);      \
 250         ASSERT((port)->lp_refs != 0);                \
 251 }
 252 
 253 #define AGGR_PORT_REFRELE(port) {                               \
 254         ASSERT((port)->lp_refs != 0);                                \
 255         membar_exit();                                          \
 256         if (atomic_add_32_nv(&(port)->lp_refs, -1) == 0) \
 257                 aggr_port_free(port);                           \
 258 }
 259 
 260 extern dev_info_t *aggr_dip;
 261 extern int aggr_ioc_init(void);
 262 extern void aggr_ioc_fini(void);
 263 
 264 typedef int (*aggr_grp_info_new_grp_fn_t)(void *, datalink_id_t, uint32_t,
 265     uchar_t *, boolean_t, boolean_t, uint32_t, uint32_t, aggr_lacp_mode_t,
 266     aggr_lacp_timer_t);
 267 typedef int (*aggr_grp_info_new_port_fn_t)(void *, datalink_id_t, uchar_t *,
 268     aggr_port_state_t, aggr_lacp_state_t *);
 269 
 270 extern void aggr_grp_init(void);
 271 extern void aggr_grp_fini(void);
 272 extern int aggr_grp_create(datalink_id_t, uint32_t, uint_t, laioc_port_t *,
 273     uint32_t, boolean_t, boolean_t, uchar_t *, aggr_lacp_mode_t,
 274     aggr_lacp_timer_t, cred_t *);
 275 extern int aggr_grp_delete(datalink_id_t, cred_t *);
 276 extern void aggr_grp_free(aggr_grp_t *);




 217         aggr_pseudo_tx_group_t  lg_tx_group;
 218 
 219         kmutex_t        lg_tx_flowctl_lock;
 220         kcondvar_t      lg_tx_flowctl_cv;
 221         uint_t          lg_tx_blocked_cnt;
 222         mac_ring_handle_t       *lg_tx_blocked_rings;
 223         kthread_t       *lg_tx_notify_thread;
 224         boolean_t       lg_tx_notify_done;
 225 
 226         /*
 227          * The following fields are used by aggr to wait for all the
 228          * aggr_port_notify_cb() and aggr_port_timer_thread() to finish
 229          * before it calls mac_unregister() when the aggr is deleted.
 230          */
 231         kmutex_t        lg_port_lock;
 232         kcondvar_t      lg_port_cv;
 233         int             lg_port_ref;
 234 } aggr_grp_t;
 235 
 236 #define AGGR_GRP_REFHOLD(grp) {                 \
 237         atomic_inc_32(&(grp)->lg_refs);  \
 238         ASSERT((grp)->lg_refs != 0);         \
 239 }
 240 
 241 #define AGGR_GRP_REFRELE(grp) {                                 \
 242         ASSERT((grp)->lg_refs != 0);                         \
 243         membar_exit();                                          \
 244         if (atomic_dec_32_nv(&(grp)->lg_refs) == 0)              \
 245                 aggr_grp_free(grp);                             \
 246 }
 247 
 248 #define AGGR_PORT_REFHOLD(port) {               \
 249         atomic_inc_32(&(port)->lp_refs); \
 250         ASSERT((port)->lp_refs != 0);                \
 251 }
 252 
 253 #define AGGR_PORT_REFRELE(port) {                               \
 254         ASSERT((port)->lp_refs != 0);                                \
 255         membar_exit();                                          \
 256         if (atomic_dec_32_nv(&(port)->lp_refs) == 0)     \
 257                 aggr_port_free(port);                           \
 258 }
 259 
 260 extern dev_info_t *aggr_dip;
 261 extern int aggr_ioc_init(void);
 262 extern void aggr_ioc_fini(void);
 263 
 264 typedef int (*aggr_grp_info_new_grp_fn_t)(void *, datalink_id_t, uint32_t,
 265     uchar_t *, boolean_t, boolean_t, uint32_t, uint32_t, aggr_lacp_mode_t,
 266     aggr_lacp_timer_t);
 267 typedef int (*aggr_grp_info_new_port_fn_t)(void *, datalink_id_t, uchar_t *,
 268     aggr_port_state_t, aggr_lacp_state_t *);
 269 
 270 extern void aggr_grp_init(void);
 271 extern void aggr_grp_fini(void);
 272 extern int aggr_grp_create(datalink_id_t, uint32_t, uint_t, laioc_port_t *,
 273     uint32_t, boolean_t, boolean_t, uchar_t *, aggr_lacp_mode_t,
 274     aggr_lacp_timer_t, cred_t *);
 275 extern int aggr_grp_delete(datalink_id_t, cred_t *);
 276 extern void aggr_grp_free(aggr_grp_t *);