Print this page
fixup .text where possible
additional style updates in crypto
7127  remove -Wno-missing-braces from Makefile.uts


 137                 /* A 28 char function name doesn't leave much line space */
 138 
 139 /*
 140  * Module linkage.
 141  */
 142 static struct modldrv modldrv = {
 143         &mod_driverops,             /* drv_modops */
 144         IDENT,                  /* drv_linkinfo */
 145         &devops,            /* drv_dev_ops */
 146 };
 147 
 148 extern struct mod_ops mod_cryptoops;
 149 
 150 static struct modlcrypto modlcrypto = {
 151         &mod_cryptoops,
 152         IDENT3
 153 };
 154 
 155 static struct modlinkage modlinkage = {
 156         MODREV_1,               /* ml_rev */
 157         &modldrv,           /* ml_linkage */
 158         &modlcrypto,
 159         NULL
 160 };
 161 
 162 /*
 163  * CSPI information (entry points, provider info, etc.)
 164  */
 165 
 166 /* Mechanisms for the symmetric cipher provider */
 167 static crypto_mech_info_t dca_mech_info_tab1[] = {
 168         /* DES-CBC */
 169         {SUN_CKM_DES_CBC, DES_CBC_MECH_INFO_TYPE,
 170             CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT |
 171             CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC,
 172             DES_KEY_LEN, DES_KEY_LEN, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
 173         /* 3DES-CBC */
 174         {SUN_CKM_DES3_CBC, DES3_CBC_MECH_INFO_TYPE,
 175             CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT |
 176             CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC,
 177             DES3_MIN_KEY_LEN, DES3_MAX_KEY_LEN, CRYPTO_KEYSIZE_UNIT_IN_BYTES}
 178 };
 179 


 334         NULL,                   /* init_pin */
 335         NULL                    /* set_pin */
 336 };
 337 
 338 static crypto_provider_management_ops_t dca_provmanage_ops_2 = {
 339         ext_info_asym,          /* ext_info */
 340         NULL,                   /* init_token */
 341         NULL,                   /* init_pin */
 342         NULL                    /* set_pin */
 343 };
 344 
 345 int dca_free_context(crypto_ctx_t *);
 346 
 347 static crypto_ctx_ops_t dca_ctx_ops = {
 348         NULL,
 349         dca_free_context
 350 };
 351 
 352 /* Operations for the symmetric cipher provider */
 353 static crypto_ops_t dca_crypto_ops1 = {
 354         &dca_control_ops,
 355         NULL,                           /* digest_ops */
 356         &dca_cipher_ops,
 357         NULL,                           /* mac_ops */
 358         NULL,                           /* sign_ops */
 359         NULL,                           /* verify_ops */
 360         NULL,                           /* dual_ops */
 361         NULL,                           /* cipher_mac_ops */
 362         NULL,                           /* random_number_ops */
 363         NULL,                           /* session_ops */
 364         NULL,                           /* object_ops */
 365         NULL,                           /* key_ops */
 366         &dca_provmanage_ops_1,              /* management_ops */
 367         &dca_ctx_ops
 368 };
 369 
 370 /* Operations for the asymmetric cipher provider */
 371 static crypto_ops_t dca_crypto_ops2 = {
 372         &dca_control_ops,
 373         NULL,                           /* digest_ops */
 374         &dca_cipher_ops,
 375         NULL,                           /* mac_ops */
 376         &dca_sign_ops,
 377         &dca_verify_ops,
 378         NULL,                           /* dual_ops */
 379         NULL,                           /* cipher_mac_ops */
 380         &dca_random_number_ops,
 381         NULL,                           /* session_ops */
 382         NULL,                           /* object_ops */
 383         NULL,                           /* key_ops */
 384         &dca_provmanage_ops_2,              /* management_ops */
 385         &dca_ctx_ops
 386 };
 387 
 388 /* Provider information for the symmetric cipher provider */
 389 static crypto_provider_info_t dca_prov_info1 = {
 390         CRYPTO_SPI_VERSION_1,
 391         NULL,                           /* pi_provider_description */
 392         CRYPTO_HW_PROVIDER,
 393         NULL,                           /* pi_provider_dev */
 394         NULL,                           /* pi_provider_handle */
 395         &dca_crypto_ops1,
 396         sizeof (dca_mech_info_tab1)/sizeof (crypto_mech_info_t),
 397         dca_mech_info_tab1,
 398         0,                              /* pi_logical_provider_count */
 399         NULL                            /* pi_logical_providers */
 400 };
 401 
 402 /* Provider information for the asymmetric cipher provider */
 403 static crypto_provider_info_t dca_prov_info2 = {
 404         CRYPTO_SPI_VERSION_1,
 405         NULL,                           /* pi_provider_description */
 406         CRYPTO_HW_PROVIDER,
 407         NULL,                           /* pi_provider_dev */
 408         NULL,                           /* pi_provider_handle */
 409         &dca_crypto_ops2,
 410         sizeof (dca_mech_info_tab2)/sizeof (crypto_mech_info_t),
 411         dca_mech_info_tab2,
 412         0,                              /* pi_logical_provider_count */
 413         NULL                            /* pi_logical_providers */
 414 };
 415 
 416 /* Convenience macros */
 417 #define DCA_SOFTC_FROM_CTX(ctx) ((dca_t *)(ctx)->cc_provider)
 418 #define DCA_MECH_FROM_CTX(ctx) \
 419         (((dca_request_t *)(ctx)->cc_provider_private)->dr_ctx.ctx_cm_type)
 420 
 421 static int dca_bindchains_one(dca_request_t *reqp, size_t cnt, int dr_offset,
 422     caddr_t kaddr, ddi_dma_handle_t handle, uint_t flags,
 423     dca_chain_t *head, int *n_chain);
 424 static uint64_t dca_ena(uint64_t ena);
 425 static caddr_t dca_bufdaddr_out(crypto_data_t *data);
 426 static char *dca_fma_eclass_string(char *model, dca_fma_eclass_t index);
 427 static int dca_check_acc_handle(dca_t *dca, ddi_acc_handle_t handle,
 428     dca_fma_eclass_t eclass_index);
 429 
 430 static void dca_fma_init(dca_t *dca);
 431 static void dca_fma_fini(dca_t *dca);
 432 static int dca_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err,
 433     const void *impl_data);
 434 




 137                 /* A 28 char function name doesn't leave much line space */
 138 
 139 /*
 140  * Module linkage.
 141  */
 142 static struct modldrv modldrv = {
 143         &mod_driverops,             /* drv_modops */
 144         IDENT,                  /* drv_linkinfo */
 145         &devops,            /* drv_dev_ops */
 146 };
 147 
 148 extern struct mod_ops mod_cryptoops;
 149 
 150 static struct modlcrypto modlcrypto = {
 151         &mod_cryptoops,
 152         IDENT3
 153 };
 154 
 155 static struct modlinkage modlinkage = {
 156         MODREV_1,               /* ml_rev */
 157         {   &modldrv,               /* ml_linkage */
 158             &modlcrypto,
 159             NULL }
 160 };
 161 
 162 /*
 163  * CSPI information (entry points, provider info, etc.)
 164  */
 165 
 166 /* Mechanisms for the symmetric cipher provider */
 167 static crypto_mech_info_t dca_mech_info_tab1[] = {
 168         /* DES-CBC */
 169         {SUN_CKM_DES_CBC, DES_CBC_MECH_INFO_TYPE,
 170             CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT |
 171             CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC,
 172             DES_KEY_LEN, DES_KEY_LEN, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
 173         /* 3DES-CBC */
 174         {SUN_CKM_DES3_CBC, DES3_CBC_MECH_INFO_TYPE,
 175             CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT |
 176             CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC,
 177             DES3_MIN_KEY_LEN, DES3_MAX_KEY_LEN, CRYPTO_KEYSIZE_UNIT_IN_BYTES}
 178 };
 179 


 334         NULL,                   /* init_pin */
 335         NULL                    /* set_pin */
 336 };
 337 
 338 static crypto_provider_management_ops_t dca_provmanage_ops_2 = {
 339         ext_info_asym,          /* ext_info */
 340         NULL,                   /* init_token */
 341         NULL,                   /* init_pin */
 342         NULL                    /* set_pin */
 343 };
 344 
 345 int dca_free_context(crypto_ctx_t *);
 346 
 347 static crypto_ctx_ops_t dca_ctx_ops = {
 348         NULL,
 349         dca_free_context
 350 };
 351 
 352 /* Operations for the symmetric cipher provider */
 353 static crypto_ops_t dca_crypto_ops1 = {
 354         .co_control_ops = &dca_control_ops,
 355         .co_digest_ops = NULL,
 356         .co_cipher_ops = &dca_cipher_ops,
 357         .co_mac_ops = NULL,
 358         .co_sign_ops = NULL,
 359         .co_verify_ops = NULL,
 360         .co_dual_ops = NULL,
 361         .co_dual_cipher_mac_ops = NULL,
 362         .co_random_ops = NULL,
 363         .co_session_ops = NULL,
 364         .co_object_ops = NULL,
 365         .co_key_ops = NULL,
 366         .co_provider_ops = &dca_provmanage_ops_1,
 367         .co_ctx_ops = &dca_ctx_ops
 368 };
 369 
 370 /* Operations for the asymmetric cipher provider */
 371 static crypto_ops_t dca_crypto_ops2 = { .cou.cou_v1 = {
 372         &dca_control_ops,
 373         NULL,                           /* digest_ops */
 374         &dca_cipher_ops,
 375         NULL,                           /* mac_ops */
 376         &dca_sign_ops,
 377         &dca_verify_ops,
 378         NULL,                           /* dual_ops */
 379         NULL,                           /* cipher_mac_ops */
 380         &dca_random_number_ops,
 381         NULL,                           /* session_ops */
 382         NULL,                           /* object_ops */
 383         NULL,                           /* key_ops */
 384         &dca_provmanage_ops_2,              /* management_ops */
 385         &dca_ctx_ops
 386 }};
 387 
 388 /* Provider information for the symmetric cipher provider */
 389 static crypto_provider_info_t dca_prov_info1 = {{{{
 390         CRYPTO_SPI_VERSION_1,
 391         NULL,                           /* pi_provider_description */
 392         CRYPTO_HW_PROVIDER,
 393         { NULL },                       /* pi_provider_dev */
 394         NULL,                           /* pi_provider_handle */
 395         &dca_crypto_ops1,
 396         sizeof (dca_mech_info_tab1)/sizeof (crypto_mech_info_t),
 397         dca_mech_info_tab1,
 398         0,                              /* pi_logical_provider_count */
 399         NULL                            /* pi_logical_providers */
 400 }}}};
 401 
 402 /* Provider information for the asymmetric cipher provider */
 403 static crypto_provider_info_t dca_prov_info2 = {{{{
 404         CRYPTO_SPI_VERSION_1,
 405         NULL,                           /* pi_provider_description */
 406         CRYPTO_HW_PROVIDER,
 407         { NULL },                       /* pi_provider_dev */
 408         NULL,                           /* pi_provider_handle */
 409         &dca_crypto_ops2,
 410         sizeof (dca_mech_info_tab2)/sizeof (crypto_mech_info_t),
 411         dca_mech_info_tab2,
 412         0,                              /* pi_logical_provider_count */
 413         NULL                            /* pi_logical_providers */
 414 }}}};
 415 
 416 /* Convenience macros */
 417 #define DCA_SOFTC_FROM_CTX(ctx) ((dca_t *)(ctx)->cc_provider)
 418 #define DCA_MECH_FROM_CTX(ctx) \
 419         (((dca_request_t *)(ctx)->cc_provider_private)->dr_ctx.ctx_cm_type)
 420 
 421 static int dca_bindchains_one(dca_request_t *reqp, size_t cnt, int dr_offset,
 422     caddr_t kaddr, ddi_dma_handle_t handle, uint_t flags,
 423     dca_chain_t *head, int *n_chain);
 424 static uint64_t dca_ena(uint64_t ena);
 425 static caddr_t dca_bufdaddr_out(crypto_data_t *data);
 426 static char *dca_fma_eclass_string(char *model, dca_fma_eclass_t index);
 427 static int dca_check_acc_handle(dca_t *dca, ddi_acc_handle_t handle,
 428     dca_fma_eclass_t eclass_index);
 429 
 430 static void dca_fma_init(dca_t *dca);
 431 static void dca_fma_fini(dca_t *dca);
 432 static int dca_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err,
 433     const void *impl_data);
 434