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


 387  *
 388  * slc_report_time stores the time when cmn_err() is called to report that the
 389  * max has been exceeeded.  Report is done at most once every
 390  * SCTP_SLC_REPORT_INTERVAL mins for a listener.
 391  *
 392  * slc_drop stores the number of connection attempt dropped because the
 393  * limit has reached.
 394  */
 395 typedef struct sctp_listen_cnt_s {
 396         uint32_t        slc_max;
 397         uint32_t        slc_cnt;
 398         int64_t         slc_report_time;
 399         uint32_t        slc_drop;
 400 } sctp_listen_cnt_t;
 401 
 402 #define SCTP_SLC_REPORT_INTERVAL        (30 * MINUTES)
 403 
 404 #define SCTP_DECR_LISTEN_CNT(sctp)                                      \
 405 {                                                                       \
 406         ASSERT((sctp)->sctp_listen_cnt->slc_cnt > 0);                  \
 407         if (atomic_add_32_nv(&(sctp)->sctp_listen_cnt->slc_cnt, -1) == 0) \
 408                 kmem_free((sctp)->sctp_listen_cnt, sizeof (sctp_listen_cnt_t));\
 409         (sctp)->sctp_listen_cnt = NULL;                                      \
 410 }
 411 
 412 /* Increment and decrement the number of associations in sctp_stack_t. */
 413 #define SCTPS_ASSOC_INC(sctps)                                          \
 414         atomic_inc_64(                                                  \
 415             (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
 416 
 417 #define SCTPS_ASSOC_DEC(sctps)                                          \
 418         atomic_dec_64(                                                  \
 419             (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
 420 
 421 #define SCTP_ASSOC_EST(sctps, sctp)                                     \
 422 {                                                                       \
 423         (sctp)->sctp_state = SCTPS_ESTABLISHED;                              \
 424         (sctp)->sctp_assoc_start_time = (uint32_t)LBOLT_FASTPATH64;  \
 425         SCTPS_ASSOC_INC(sctps);                                         \
 426 }
 427 




 387  *
 388  * slc_report_time stores the time when cmn_err() is called to report that the
 389  * max has been exceeeded.  Report is done at most once every
 390  * SCTP_SLC_REPORT_INTERVAL mins for a listener.
 391  *
 392  * slc_drop stores the number of connection attempt dropped because the
 393  * limit has reached.
 394  */
 395 typedef struct sctp_listen_cnt_s {
 396         uint32_t        slc_max;
 397         uint32_t        slc_cnt;
 398         int64_t         slc_report_time;
 399         uint32_t        slc_drop;
 400 } sctp_listen_cnt_t;
 401 
 402 #define SCTP_SLC_REPORT_INTERVAL        (30 * MINUTES)
 403 
 404 #define SCTP_DECR_LISTEN_CNT(sctp)                                      \
 405 {                                                                       \
 406         ASSERT((sctp)->sctp_listen_cnt->slc_cnt > 0);                  \
 407         if (atomic_dec_32_nv(&(sctp)->sctp_listen_cnt->slc_cnt) == 0) \
 408                 kmem_free((sctp)->sctp_listen_cnt, sizeof (sctp_listen_cnt_t));\
 409         (sctp)->sctp_listen_cnt = NULL;                                      \
 410 }
 411 
 412 /* Increment and decrement the number of associations in sctp_stack_t. */
 413 #define SCTPS_ASSOC_INC(sctps)                                          \
 414         atomic_inc_64(                                                  \
 415             (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
 416 
 417 #define SCTPS_ASSOC_DEC(sctps)                                          \
 418         atomic_dec_64(                                                  \
 419             (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
 420 
 421 #define SCTP_ASSOC_EST(sctps, sctp)                                     \
 422 {                                                                       \
 423         (sctp)->sctp_state = SCTPS_ESTABLISHED;                              \
 424         (sctp)->sctp_assoc_start_time = (uint32_t)LBOLT_FASTPATH64;  \
 425         SCTPS_ASSOC_INC(sctps);                                         \
 426 }
 427