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


 379  * pd_mutex:            Protects array and count of disabled mechanisms.
 380  * pd_disabled_count:   Count of disabled mechanisms.
 381  * pd_disabled_mechs:   Array of disabled mechanisms.
 382  */
 383 typedef struct kcf_policy_desc {
 384         crypto_provider_type_t  pd_prov_type;
 385         char                    *pd_name;
 386         uint_t                  pd_instance;
 387         uint_t                  pd_refcnt;
 388         kmutex_t                pd_mutex;
 389         uint_t                  pd_disabled_count;
 390         crypto_mech_name_t      *pd_disabled_mechs;
 391 } kcf_policy_desc_t;
 392 
 393 /*
 394  * If a component has a reference to a kcf_policy_desc_t,
 395  * it REFHOLD()s. A new policy descriptor which is referenced only
 396  * by the policy table has a reference count of one.
 397  */
 398 #define KCF_POLICY_REFHOLD(desc) {              \
 399         atomic_add_32(&(desc)->pd_refcnt, 1);    \
 400         ASSERT((desc)->pd_refcnt != 0);              \
 401 }
 402 
 403 /*
 404  * Releases a reference to a policy descriptor. When the last
 405  * reference is released, the descriptor is freed.
 406  */
 407 #define KCF_POLICY_REFRELE(desc) {                              \
 408         ASSERT((desc)->pd_refcnt != 0);                              \
 409         membar_exit();                                          \
 410         if (atomic_add_32_nv(&(desc)->pd_refcnt, -1) == 0)       \
 411                 kcf_policy_free_desc(desc);                     \
 412 }
 413 
 414 /*
 415  * This entry stores the name of a software module and its
 416  * mechanisms.  The mechanisms are 'hints' that are used to
 417  * trigger loading of the module.
 418  */
 419 typedef struct kcf_soft_conf_entry {
 420         struct kcf_soft_conf_entry      *ce_next;
 421         char                            *ce_name;
 422         crypto_mech_name_t              *ce_mechs;
 423         uint_t                          ce_count;
 424 } kcf_soft_conf_entry_t;
 425 
 426 extern kmutex_t soft_config_mutex;
 427 extern kcf_soft_conf_entry_t *soft_config_list;
 428 
 429 /*
 430  * Global tables. The sizes are from the predefined PKCS#11 v2.20 mechanisms,




 379  * pd_mutex:            Protects array and count of disabled mechanisms.
 380  * pd_disabled_count:   Count of disabled mechanisms.
 381  * pd_disabled_mechs:   Array of disabled mechanisms.
 382  */
 383 typedef struct kcf_policy_desc {
 384         crypto_provider_type_t  pd_prov_type;
 385         char                    *pd_name;
 386         uint_t                  pd_instance;
 387         uint_t                  pd_refcnt;
 388         kmutex_t                pd_mutex;
 389         uint_t                  pd_disabled_count;
 390         crypto_mech_name_t      *pd_disabled_mechs;
 391 } kcf_policy_desc_t;
 392 
 393 /*
 394  * If a component has a reference to a kcf_policy_desc_t,
 395  * it REFHOLD()s. A new policy descriptor which is referenced only
 396  * by the policy table has a reference count of one.
 397  */
 398 #define KCF_POLICY_REFHOLD(desc) {              \
 399         atomic_inc_32(&(desc)->pd_refcnt);       \
 400         ASSERT((desc)->pd_refcnt != 0);              \
 401 }
 402 
 403 /*
 404  * Releases a reference to a policy descriptor. When the last
 405  * reference is released, the descriptor is freed.
 406  */
 407 #define KCF_POLICY_REFRELE(desc) {                              \
 408         ASSERT((desc)->pd_refcnt != 0);                              \
 409         membar_exit();                                          \
 410         if (atomic_dec_32_nv(&(desc)->pd_refcnt) == 0)   \
 411                 kcf_policy_free_desc(desc);                     \
 412 }
 413 
 414 /*
 415  * This entry stores the name of a software module and its
 416  * mechanisms.  The mechanisms are 'hints' that are used to
 417  * trigger loading of the module.
 418  */
 419 typedef struct kcf_soft_conf_entry {
 420         struct kcf_soft_conf_entry      *ce_next;
 421         char                            *ce_name;
 422         crypto_mech_name_t              *ce_mechs;
 423         uint_t                          ce_count;
 424 } kcf_soft_conf_entry_t;
 425 
 426 extern kmutex_t soft_config_mutex;
 427 extern kcf_soft_conf_entry_t *soft_config_list;
 428 
 429 /*
 430  * Global tables. The sizes are from the predefined PKCS#11 v2.20 mechanisms,