Lines Matching +full:csr +full:- +full:2 +full:l

3 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
9 * Copyright (c) 2000-2001 Network Security Technologies, Inc.
14 * requested: Please send any comments, feedback, bug-fixes, or feature
23 * 2. Redistributions in binary form must reproduce the above copyright
42 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
171 u_int32_t v = bus_space_read_4(sc->sc_st0, sc->sc_sh0, reg); in READ_REG_0()
172 sc->sc_bar0_lastreg = (bus_size_t) -1; in READ_REG_0()
180 u_int32_t v = bus_space_read_4(sc->sc_st1, sc->sc_sh1, reg); in READ_REG_1()
181 sc->sc_bar1_lastreg = (bus_size_t) -1; in READ_REG_1()
229 *paddr = segs->ds_addr; in hifn_dmamap_cb()
236 switch (pci_get_vendor(sc->sc_dev)) { in hifn_partname()
238 switch (pci_get_device(sc->sc_dev)) { in hifn_partname()
246 return "Hifn unknown-part"; in hifn_partname()
248 switch (pci_get_device(sc->sc_dev)) { in hifn_partname()
251 return "Invertex unknown-part"; in hifn_partname()
253 switch (pci_get_device(sc->sc_dev)) { in hifn_partname()
256 return "NetSec unknown-part"; in hifn_partname()
258 return "Unknown-vendor unknown-part"; in hifn_partname()
304 * non-PCI-compliant spread-spectrum clocks, which can confuse the pll.
345 mul = checkmaxmin(dev, "PLL divisor", (266 / freq) &~ 1, 2, 12); in hifn_getpllconfig()
346 pllconfig |= (mul / 2 - 1) << HIFN_PLL_ND_SHIFT; in hifn_getpllconfig()
364 sc->sc_dev = dev; in hifn_attach()
366 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "hifn driver", MTX_DEF); in hifn_attach()
378 sc->sc_flags = HIFN_HAS_RNG | HIFN_HAS_PUBLIC; in hifn_attach()
385 sc->sc_flags |= HIFN_IS_7811 | HIFN_HAS_RNG; in hifn_attach()
393 sc->sc_flags |= HIFN_IS_7956 | HIFN_HAS_AES; in hifn_attach()
399 hifn_getpllconfig(dev, &sc->sc_pllconfig); in hifn_attach()
411 sc->sc_bar0res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in hifn_attach()
413 if (sc->sc_bar0res == NULL) { in hifn_attach()
417 sc->sc_st0 = rman_get_bustag(sc->sc_bar0res); in hifn_attach()
418 sc->sc_sh0 = rman_get_bushandle(sc->sc_bar0res); in hifn_attach()
419 sc->sc_bar0_lastreg = (bus_size_t) -1; in hifn_attach()
422 sc->sc_bar1res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in hifn_attach()
424 if (sc->sc_bar1res == NULL) { in hifn_attach()
428 sc->sc_st1 = rman_get_bustag(sc->sc_bar1res); in hifn_attach()
429 sc->sc_sh1 = rman_get_bushandle(sc->sc_bar1res); in hifn_attach()
430 sc->sc_bar1_lastreg = (bus_size_t) -1; in hifn_attach()
449 &sc->sc_dmat)) { in hifn_attach()
453 if (bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT, &sc->sc_dmamap)) { in hifn_attach()
455 bus_dma_tag_destroy(sc->sc_dmat); in hifn_attach()
458 if (bus_dmamem_alloc(sc->sc_dmat, (void**) &kva, BUS_DMA_NOWAIT, &sc->sc_dmamap)) { in hifn_attach()
460 bus_dmamap_destroy(sc->sc_dmat, sc->sc_dmamap); in hifn_attach()
461 bus_dma_tag_destroy(sc->sc_dmat); in hifn_attach()
464 if (bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap, kva, in hifn_attach()
465 sizeof (*sc->sc_dma), in hifn_attach()
466 hifn_dmamap_cb, &sc->sc_dma_physaddr, in hifn_attach()
469 bus_dmamem_free(sc->sc_dmat, kva, sc->sc_dmamap); in hifn_attach()
470 bus_dma_tag_destroy(sc->sc_dmat); in hifn_attach()
473 sc->sc_dma = (struct hifn_dma *)kva; in hifn_attach()
474 bzero(sc->sc_dma, sizeof(*sc->sc_dma)); in hifn_attach()
476 KASSERT(sc->sc_st0 != 0, ("hifn_attach: null bar0 tag!")); in hifn_attach()
477 KASSERT(sc->sc_sh0 != 0, ("hifn_attach: null bar0 handle!")); in hifn_attach()
478 KASSERT(sc->sc_st1 != 0, ("hifn_attach: null bar1 tag!")); in hifn_attach()
479 KASSERT(sc->sc_sh1 != 0, ("hifn_attach: null bar1 handle!")); in hifn_attach()
501 if (sc->sc_flags & HIFN_IS_7956) in hifn_attach()
502 sc->sc_drammodel = 1; in hifn_attach()
506 if (sc->sc_drammodel == 0) in hifn_attach()
518 sc->sc_ramsize >>= 1; in hifn_attach()
524 sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in hifn_attach()
526 if (sc->sc_irq == NULL) { in hifn_attach()
534 if (bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, in hifn_attach()
535 NULL, hifn_intr, sc, &sc->sc_intrhand)) { in hifn_attach()
548 rseg = sc->sc_ramsize / 1024; in hifn_attach()
550 if (sc->sc_ramsize >= (1024 * 1024)) { in hifn_attach()
554 device_printf(sc->sc_dev, "%s, rev %u, %d%cB %cram", in hifn_attach()
556 rseg, rbase, sc->sc_drammodel ? 'd' : 's'); in hifn_attach()
557 if (sc->sc_flags & HIFN_IS_7956) in hifn_attach()
559 sc->sc_pllconfig, in hifn_attach()
560 sc->sc_pllconfig & HIFN_PLL_REF_SEL ? "ext" : "pci", in hifn_attach()
561 2 + 2*((sc->sc_pllconfig & HIFN_PLL_ND) >> 11)); in hifn_attach()
566 sc->sc_ena = READ_REG_0(sc, HIFN_0_PUSTAT) & HIFN_PUSTAT_CHIPENA; in hifn_attach()
568 switch (sc->sc_ena) { in hifn_attach()
571 sc->sc_cid = crypto_get_driverid(dev, in hifn_attach()
573 if (sc->sc_cid < 0) { in hifn_attach()
580 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_attach()
583 if (sc->sc_flags & (HIFN_HAS_PUBLIC | HIFN_HAS_RNG)) in hifn_attach()
586 callout_init(&sc->sc_tickto, 1); in hifn_attach()
587 callout_reset(&sc->sc_tickto, hz, hifn_tick, sc); in hifn_attach()
592 bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand); in hifn_attach()
595 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); in hifn_attach()
597 bus_dmamap_unload(sc->sc_dmat, sc->sc_dmamap); in hifn_attach()
598 bus_dmamem_free(sc->sc_dmat, sc->sc_dma, sc->sc_dmamap); in hifn_attach()
599 bus_dma_tag_destroy(sc->sc_dmat); in hifn_attach()
605 bus_release_resource(dev, SYS_RES_MEMORY, HIFN_BAR1, sc->sc_bar1res); in hifn_attach()
607 bus_release_resource(dev, SYS_RES_MEMORY, HIFN_BAR0, sc->sc_bar0res); in hifn_attach()
609 mtx_destroy(&sc->sc_mtx); in hifn_attach()
627 callout_stop(&sc->sc_tickto); in hifn_detach()
628 callout_stop(&sc->sc_rngto); in hifn_detach()
630 if (sc->sc_rndtest) in hifn_detach()
631 rndtest_detach(sc->sc_rndtest); in hifn_detach()
638 crypto_unregister_all(sc->sc_cid); in hifn_detach()
640 bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand); in hifn_detach()
642 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); in hifn_detach()
644 bus_dmamap_unload(sc->sc_dmat, sc->sc_dmamap); in hifn_detach()
645 bus_dmamem_free(sc->sc_dmat, sc->sc_dma, sc->sc_dmamap); in hifn_detach()
646 bus_dma_tag_destroy(sc->sc_dmat); in hifn_detach()
648 bus_release_resource(dev, SYS_RES_MEMORY, HIFN_BAR1, sc->sc_bar1res); in hifn_detach()
649 bus_release_resource(dev, SYS_RES_MEMORY, HIFN_BAR0, sc->sc_bar0res); in hifn_detach()
651 mtx_destroy(&sc->sc_mtx); in hifn_detach()
681 sc->sc_suspended = 1; in hifn_suspend()
688 * doesn't, re-enable busmastering, and restart the interface if
697 if (ifp->if_flags & IFF_UP) in hifn_resume()
700 sc->sc_suspended = 0; in hifn_resume()
712 sc->sc_rndtest = rndtest_attach(sc->sc_dev); in hifn_init_pubrng()
713 if (sc->sc_rndtest) in hifn_init_pubrng()
714 sc->sc_harvest = rndtest_harvest; in hifn_init_pubrng()
716 sc->sc_harvest = default_harvest; in hifn_init_pubrng()
718 sc->sc_harvest = default_harvest; in hifn_init_pubrng()
720 if ((sc->sc_flags & HIFN_IS_7811) == 0) { in hifn_init_pubrng()
733 device_printf(sc->sc_dev, "public key init failed\n"); in hifn_init_pubrng()
739 if (sc->sc_flags & HIFN_HAS_RNG) { in hifn_init_pubrng()
740 if (sc->sc_flags & HIFN_IS_7811) { in hifn_init_pubrng()
755 sc->sc_rngfirst = 1; in hifn_init_pubrng()
757 sc->sc_rnghz = hz / 100; in hifn_init_pubrng()
759 sc->sc_rnghz = 1; in hifn_init_pubrng()
760 callout_init(&sc->sc_rngto, 1); in hifn_init_pubrng()
761 callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc); in hifn_init_pubrng()
765 if (sc->sc_flags & HIFN_HAS_PUBLIC) { in hifn_init_pubrng()
767 sc->sc_dmaier |= HIFN_DMAIER_PUBDONE; in hifn_init_pubrng()
768 WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); in hifn_init_pubrng()
770 sc->sc_pkdev = make_dev(&vulcanpk_cdevsw, 0, in hifn_init_pubrng()
773 sc->sc_pkdev->si_drv1 = sc; in hifn_init_pubrng()
785 u_int32_t sts, num[2]; in hifn_rng()
788 if (sc->sc_flags & HIFN_IS_7811) { in hifn_rng()
793 device_printf(sc->sc_dev, in hifn_rng()
807 if (sc->sc_rngfirst) in hifn_rng()
808 sc->sc_rngfirst = 0; in hifn_rng()
810 (*sc->sc_harvest)(sc->sc_rndtest, in hifn_rng()
817 if (sc->sc_rngfirst) in hifn_rng()
818 sc->sc_rngfirst = 0; in hifn_rng()
820 (*sc->sc_harvest)(sc->sc_rndtest, in hifn_rng()
824 callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc); in hifn_rng()
834 if (sc->sc_flags & HIFN_IS_7956) { in hifn_puc_wait()
838 for (i = 5000; i > 0; i--) { in hifn_puc_wait()
844 device_printf(sc->sc_dev, "proc unit did not reset\n"); in hifn_puc_wait()
856 if (sc->sc_flags & HIFN_IS_7956) { in hifn_reset_puc()
867 * 3.6 of "Specification Update SU-0014-04". Not clear if we
873 /* NB: RETRY only responds to 8-bit reads/writes */ in hifn_set_retry()
874 pci_write_config(sc->sc_dev, HIFN_RETRY_TIMEOUT, 0, 1); in hifn_set_retry()
875 pci_write_config(sc->sc_dev, HIFN_TRDY_TIMEOUT, 0, 1); in hifn_set_retry()
910 KASSERT(sc->sc_dma != NULL, ("hifn_reset_board: null DMA tag!")); in hifn_reset_board()
911 bzero(sc->sc_dma, sizeof(*sc->sc_dma)); in hifn_reset_board()
920 if (sc->sc_flags & HIFN_IS_7811) { in hifn_reset_board()
930 /* set up DMA configuration register #2 */ in hifn_reset_board()
935 (2 << HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT)| in hifn_reset_board()
936 (2 << HIFN_DMACNFG2_TGT_READ_BURST_SHIFT)); in hifn_reset_board()
954 v ^= v >> 2; in hifn_next_signature()
1024 if (pci2id[i].pci_vendor == pci_get_vendor(sc->sc_dev) && in hifn_enable_crypto()
1025 pci2id[i].pci_prod == pci_get_device(sc->sc_dev)) { in hifn_enable_crypto()
1031 device_printf(sc->sc_dev, "Unknown card!\n"); in hifn_enable_crypto()
1047 * Make sure we don't re-unlock. Two unlocks kills chip until the in hifn_enable_crypto()
1053 device_printf(sc->sc_dev, in hifn_enable_crypto()
1062 device_printf(sc->sc_dev, in hifn_enable_crypto()
1089 device_printf(sc->sc_dev, "Engine is permanently " in hifn_enable_crypto()
1092 device_printf(sc->sc_dev, "Engine enabled " in hifn_enable_crypto()
1107 device_printf(sc->sc_dev, "disabled"); in hifn_enable_crypto()
1127 WRITE_REG_1(sc, HIFN_1_DMA_CRAR, sc->sc_dma_physaddr + in hifn_init_pci_registers()
1129 WRITE_REG_1(sc, HIFN_1_DMA_SRAR, sc->sc_dma_physaddr + in hifn_init_pci_registers()
1131 WRITE_REG_1(sc, HIFN_1_DMA_DRAR, sc->sc_dma_physaddr + in hifn_init_pci_registers()
1133 WRITE_REG_1(sc, HIFN_1_DMA_RRAR, sc->sc_dma_physaddr + in hifn_init_pci_registers()
1151 ((sc->sc_flags & HIFN_HAS_PUBLIC) ? in hifn_init_pci_registers()
1153 ((sc->sc_flags & HIFN_IS_7811) ? in hifn_init_pci_registers()
1156 sc->sc_d_busy = sc->sc_r_busy = sc->sc_s_busy = sc->sc_c_busy = 0; in hifn_init_pci_registers()
1157 sc->sc_dmaier |= HIFN_DMAIER_R_DONE | HIFN_DMAIER_C_ABORT | in hifn_init_pci_registers()
1160 ((sc->sc_flags & HIFN_IS_7811) ? in hifn_init_pci_registers()
1162 sc->sc_dmaier &= ~HIFN_DMAIER_C_WAIT; in hifn_init_pci_registers()
1163 WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); in hifn_init_pci_registers()
1166 if (sc->sc_flags & HIFN_IS_7956) { in hifn_init_pci_registers()
1181 pll = (pll &~ HIFN_PLL_CONFIG) | sc->sc_pllconfig; in hifn_init_pci_registers()
1195 (sc->sc_drammodel ? HIFN_PUCNFG_DRAM : HIFN_PUCNFG_SRAM)); in hifn_init_pci_registers()
1228 if (sc->sc_flags & HIFN_IS_7956) in hifn_sessions()
1229 sc->sc_maxses = 32768 / ctxsize; in hifn_sessions()
1231 sc->sc_maxses = 1 + in hifn_sessions()
1232 ((sc->sc_ramsize - 32768) / ctxsize); in hifn_sessions()
1234 sc->sc_maxses = sc->sc_ramsize / 16384; in hifn_sessions()
1236 if (sc->sc_maxses > 2048) in hifn_sessions()
1237 sc->sc_maxses = 2048; in hifn_sessions()
1253 return (-1); in hifn_ramtype()
1255 return (-1); in hifn_ramtype()
1257 sc->sc_drammodel = 1; in hifn_ramtype()
1264 return (-1); in hifn_ramtype()
1266 return (-1); in hifn_ramtype()
1268 sc->sc_drammodel = 1; in hifn_ramtype()
1290 for (i = HIFN_SRAM_GRANULARITY - 1; i >= 0; i--) { in hifn_sramsize()
1303 sc->sc_ramsize = a + HIFN_SRAM_STEP_SIZE; in hifn_sramsize()
1319 if (sc->sc_flags & HIFN_IS_7956) { in hifn_dramsize()
1323 sc->sc_ramsize = 32768; in hifn_dramsize()
1327 sc->sc_ramsize = 1 << ((cnfg >> 13) + 18); in hifn_dramsize()
1335 struct hifn_dma *dma = sc->sc_dma; in hifn_alloc_slot()
1337 if (sc->sc_cmdi == HIFN_D_CMD_RSIZE) { in hifn_alloc_slot()
1338 sc->sc_cmdi = 0; in hifn_alloc_slot()
1339 dma->cmdr[HIFN_D_CMD_RSIZE].l = htole32(HIFN_D_VALID | in hifn_alloc_slot()
1344 *cmdp = sc->sc_cmdi++; in hifn_alloc_slot()
1345 sc->sc_cmdk = sc->sc_cmdi; in hifn_alloc_slot()
1347 if (sc->sc_srci == HIFN_D_SRC_RSIZE) { in hifn_alloc_slot()
1348 sc->sc_srci = 0; in hifn_alloc_slot()
1349 dma->srcr[HIFN_D_SRC_RSIZE].l = htole32(HIFN_D_VALID | in hifn_alloc_slot()
1354 *srcp = sc->sc_srci++; in hifn_alloc_slot()
1355 sc->sc_srck = sc->sc_srci; in hifn_alloc_slot()
1357 if (sc->sc_dsti == HIFN_D_DST_RSIZE) { in hifn_alloc_slot()
1358 sc->sc_dsti = 0; in hifn_alloc_slot()
1359 dma->dstr[HIFN_D_DST_RSIZE].l = htole32(HIFN_D_VALID | in hifn_alloc_slot()
1364 *dstp = sc->sc_dsti++; in hifn_alloc_slot()
1365 sc->sc_dstk = sc->sc_dsti; in hifn_alloc_slot()
1367 if (sc->sc_resi == HIFN_D_RES_RSIZE) { in hifn_alloc_slot()
1368 sc->sc_resi = 0; in hifn_alloc_slot()
1369 dma->resr[HIFN_D_RES_RSIZE].l = htole32(HIFN_D_VALID | in hifn_alloc_slot()
1374 *resp = sc->sc_resi++; in hifn_alloc_slot()
1375 sc->sc_resk = sc->sc_resi; in hifn_alloc_slot()
1381 struct hifn_dma *dma = sc->sc_dma; in hifn_writeramaddr()
1398 bzero(dma->command_bufs[cmdi], HIFN_MAX_COMMAND); in hifn_writeramaddr()
1399 *(hifn_base_command_t *)dma->command_bufs[cmdi] = wc; in hifn_writeramaddr()
1400 bcopy(data, &dma->test_src, sizeof(dma->test_src)); in hifn_writeramaddr()
1402 dma->srcr[srci].p = htole32(sc->sc_dma_physaddr in hifn_writeramaddr()
1404 dma->dstr[dsti].p = htole32(sc->sc_dma_physaddr in hifn_writeramaddr()
1407 dma->cmdr[cmdi].l = htole32(16 | masks); in hifn_writeramaddr()
1408 dma->srcr[srci].l = htole32(8 | masks); in hifn_writeramaddr()
1409 dma->dstr[dsti].l = htole32(4 | masks); in hifn_writeramaddr()
1410 dma->resr[resi].l = htole32(4 | masks); in hifn_writeramaddr()
1412 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_writeramaddr()
1415 for (r = 10000; r >= 0; r--) { in hifn_writeramaddr()
1417 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_writeramaddr()
1419 if ((dma->resr[resi].l & htole32(HIFN_D_VALID)) == 0) in hifn_writeramaddr()
1421 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_writeramaddr()
1425 device_printf(sc->sc_dev, "writeramaddr -- " in hifn_writeramaddr()
1427 r = -1; in hifn_writeramaddr()
1428 return (-1); in hifn_writeramaddr()
1442 struct hifn_dma *dma = sc->sc_dma; in hifn_readramaddr()
1447 rc.masks = htole16(2 << 13); in hifn_readramaddr()
1458 bzero(dma->command_bufs[cmdi], HIFN_MAX_COMMAND); in hifn_readramaddr()
1459 *(hifn_base_command_t *)dma->command_bufs[cmdi] = rc; in hifn_readramaddr()
1461 dma->srcr[srci].p = htole32(sc->sc_dma_physaddr + in hifn_readramaddr()
1463 dma->test_src = 0; in hifn_readramaddr()
1464 dma->dstr[dsti].p = htole32(sc->sc_dma_physaddr + in hifn_readramaddr()
1466 dma->test_dst = 0; in hifn_readramaddr()
1467 dma->cmdr[cmdi].l = htole32(8 | masks); in hifn_readramaddr()
1468 dma->srcr[srci].l = htole32(8 | masks); in hifn_readramaddr()
1469 dma->dstr[dsti].l = htole32(8 | masks); in hifn_readramaddr()
1470 dma->resr[resi].l = htole32(HIFN_MAX_RESULT | masks); in hifn_readramaddr()
1472 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_readramaddr()
1475 for (r = 10000; r >= 0; r--) { in hifn_readramaddr()
1477 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_readramaddr()
1479 if ((dma->resr[resi].l & htole32(HIFN_D_VALID)) == 0) in hifn_readramaddr()
1481 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_readramaddr()
1485 device_printf(sc->sc_dev, "readramaddr -- " in hifn_readramaddr()
1487 r = -1; in hifn_readramaddr()
1490 bcopy(&dma->test_dst, data, sizeof(dma->test_dst)); in hifn_readramaddr()
1506 struct hifn_dma *dma = sc->sc_dma; in hifn_init_dma()
1513 dma->cmdr[i].p = htole32(sc->sc_dma_physaddr + in hifn_init_dma()
1516 dma->resr[i].p = htole32(sc->sc_dma_physaddr + in hifn_init_dma()
1519 dma->cmdr[HIFN_D_CMD_RSIZE].p = in hifn_init_dma()
1520 htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, cmdr[0])); in hifn_init_dma()
1521 dma->srcr[HIFN_D_SRC_RSIZE].p = in hifn_init_dma()
1522 htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, srcr[0])); in hifn_init_dma()
1523 dma->dstr[HIFN_D_DST_RSIZE].p = in hifn_init_dma()
1524 htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, dstr[0])); in hifn_init_dma()
1525 dma->resr[HIFN_D_RES_RSIZE].p = in hifn_init_dma()
1526 htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, resr[0])); in hifn_init_dma()
1528 sc->sc_cmdu = sc->sc_srcu = sc->sc_dstu = sc->sc_resu = 0; in hifn_init_dma()
1529 sc->sc_cmdi = sc->sc_srci = sc->sc_dsti = sc->sc_resi = 0; in hifn_init_dma()
1530 sc->sc_cmdk = sc->sc_srck = sc->sc_dstk = sc->sc_resk = 0; in hifn_init_dma()
1548 crp = cmd->crp; in hifn_write_command()
1550 using_mac = cmd->base_masks & HIFN_BASE_CMD_MAC; in hifn_write_command()
1551 using_crypt = cmd->base_masks & HIFN_BASE_CMD_CRYPT; in hifn_write_command()
1554 base_cmd->masks = htole16(cmd->base_masks); in hifn_write_command()
1555 slen = cmd->src_mapsize; in hifn_write_command()
1556 if (cmd->sloplen) in hifn_write_command()
1557 dlen = cmd->dst_mapsize - cmd->sloplen + sizeof(u_int32_t); in hifn_write_command()
1559 dlen = cmd->dst_mapsize; in hifn_write_command()
1560 base_cmd->total_source_count = htole16(slen & HIFN_BASE_CMD_LENMASK_LO); in hifn_write_command()
1561 base_cmd->total_dest_count = htole16(dlen & HIFN_BASE_CMD_LENMASK_LO); in hifn_write_command()
1564 base_cmd->session_num = htole16( in hifn_write_command()
1571 dlen = crp->crp_aad_length + crp->crp_payload_length; in hifn_write_command()
1572 mac_cmd->source_count = htole16(dlen & 0xffff); in hifn_write_command()
1574 mac_cmd->masks = htole16(cmd->mac_masks | in hifn_write_command()
1576 if (crp->crp_aad_length != 0) in hifn_write_command()
1577 mac_cmd->header_skip = htole16(crp->crp_aad_start); in hifn_write_command()
1579 mac_cmd->header_skip = htole16(crp->crp_payload_start); in hifn_write_command()
1580 mac_cmd->reserved = 0; in hifn_write_command()
1586 dlen = crp->crp_payload_length; in hifn_write_command()
1587 cry_cmd->source_count = htole16(dlen & 0xffff); in hifn_write_command()
1589 cry_cmd->masks = htole16(cmd->cry_masks | in hifn_write_command()
1591 cry_cmd->header_skip = htole16(crp->crp_payload_length); in hifn_write_command()
1592 cry_cmd->reserved = 0; in hifn_write_command()
1596 if (using_mac && cmd->mac_masks & HIFN_MAC_CMD_NEW_KEY) { in hifn_write_command()
1597 bcopy(cmd->mac, buf_pos, HIFN_MAC_KEY_LENGTH); in hifn_write_command()
1601 if (using_crypt && cmd->cry_masks & HIFN_CRYPT_CMD_NEW_KEY) { in hifn_write_command()
1602 switch (cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) { in hifn_write_command()
1608 bcopy(cmd->ck, buf_pos, cmd->cklen); in hifn_write_command()
1609 buf_pos += cmd->cklen; in hifn_write_command()
1614 if (using_crypt && cmd->cry_masks & HIFN_CRYPT_CMD_NEW_IV) { in hifn_write_command()
1615 switch (cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) { in hifn_write_command()
1623 bcopy(cmd->iv, buf_pos, ivlen); in hifn_write_command()
1627 if ((cmd->base_masks & (HIFN_BASE_CMD_MAC|HIFN_BASE_CMD_CRYPT)) == 0) { in hifn_write_command()
1632 return (buf_pos - buf); in hifn_write_command()
1640 for (i = 0; i < op->nsegs; i++) { in hifn_dmamap_aligned()
1641 if (op->segs[i].ds_addr & 3) in hifn_dmamap_aligned()
1643 if ((i != (op->nsegs - 1)) && (op->segs[i].ds_len & 3)) in hifn_dmamap_aligned()
1652 struct hifn_dma *dma = sc->sc_dma; in hifn_dmamap_dstwrap()
1655 dma->dstr[idx].l = htole32(HIFN_D_VALID | HIFN_D_JUMP | in hifn_dmamap_dstwrap()
1667 struct hifn_dma *dma = sc->sc_dma; in hifn_dmamap_load_dst()
1668 struct hifn_operand *dst = &cmd->dst; in hifn_dmamap_load_dst()
1669 u_int32_t p, l; in hifn_dmamap_load_dst() local
1672 idx = sc->sc_dsti; in hifn_dmamap_load_dst()
1673 for (i = 0; i < dst->nsegs - 1; i++) { in hifn_dmamap_load_dst()
1674 dma->dstr[idx].p = htole32(dst->segs[i].ds_addr); in hifn_dmamap_load_dst()
1675 dma->dstr[idx].l = htole32(HIFN_D_VALID | in hifn_dmamap_load_dst()
1676 HIFN_D_MASKDONEIRQ | dst->segs[i].ds_len); in hifn_dmamap_load_dst()
1684 if (cmd->sloplen == 0) { in hifn_dmamap_load_dst()
1685 p = dst->segs[i].ds_addr; in hifn_dmamap_load_dst()
1686 l = HIFN_D_VALID | HIFN_D_MASKDONEIRQ | HIFN_D_LAST | in hifn_dmamap_load_dst()
1687 dst->segs[i].ds_len; in hifn_dmamap_load_dst()
1689 p = sc->sc_dma_physaddr + in hifn_dmamap_load_dst()
1690 offsetof(struct hifn_dma, slop[cmd->slopidx]); in hifn_dmamap_load_dst()
1691 l = HIFN_D_VALID | HIFN_D_MASKDONEIRQ | HIFN_D_LAST | in hifn_dmamap_load_dst()
1694 if ((dst->segs[i].ds_len - cmd->sloplen) != 0) { in hifn_dmamap_load_dst()
1695 dma->dstr[idx].p = htole32(dst->segs[i].ds_addr); in hifn_dmamap_load_dst()
1696 dma->dstr[idx].l = htole32(HIFN_D_VALID | in hifn_dmamap_load_dst()
1698 (dst->segs[i].ds_len - cmd->sloplen)); in hifn_dmamap_load_dst()
1706 dma->dstr[idx].p = htole32(p); in hifn_dmamap_load_dst()
1707 dma->dstr[idx].l = htole32(l); in hifn_dmamap_load_dst()
1713 sc->sc_dsti = idx; in hifn_dmamap_load_dst()
1714 sc->sc_dstu += used; in hifn_dmamap_load_dst()
1721 struct hifn_dma *dma = sc->sc_dma; in hifn_dmamap_srcwrap()
1724 dma->srcr[idx].l = htole32(HIFN_D_VALID | in hifn_dmamap_srcwrap()
1736 struct hifn_dma *dma = sc->sc_dma; in hifn_dmamap_load_src()
1737 struct hifn_operand *src = &cmd->src; in hifn_dmamap_load_src()
1741 idx = sc->sc_srci; in hifn_dmamap_load_src()
1742 for (i = 0; i < src->nsegs; i++) { in hifn_dmamap_load_src()
1743 if (i == src->nsegs - 1) in hifn_dmamap_load_src()
1746 dma->srcr[idx].p = htole32(src->segs[i].ds_addr); in hifn_dmamap_load_src()
1747 dma->srcr[idx].l = htole32(src->segs[i].ds_len | in hifn_dmamap_load_src()
1754 sc->sc_srci = idx; in hifn_dmamap_load_src()
1755 sc->sc_srcu += src->nsegs; in hifn_dmamap_load_src()
1767 op->nsegs = nsegs; in hifn_op_cb()
1768 bcopy(seg, op->segs, nsegs * sizeof (seg[0])); in hifn_op_cb()
1778 struct hifn_dma *dma = sc->sc_dma; in hifn_crypto()
1779 u_int32_t cmdlen, csr; in hifn_crypto() local
1788 if ((sc->sc_cmdu + 1) > HIFN_D_CMD_RSIZE || in hifn_crypto()
1789 (sc->sc_resu + 1) > HIFN_D_RES_RSIZE) { in hifn_crypto()
1792 device_printf(sc->sc_dev, in hifn_crypto()
1794 sc->sc_cmdu, sc->sc_resu); in hifn_crypto()
1802 if (bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT, &cmd->src_map)) { in hifn_crypto()
1808 if (bus_dmamap_load_crp(sc->sc_dmat, cmd->src_map, crp, hifn_op_cb, in hifn_crypto()
1809 &cmd->src, BUS_DMA_NOWAIT)) { in hifn_crypto()
1814 cmd->src_mapsize = crypto_buffer_len(&crp->crp_buf); in hifn_crypto()
1816 if (hifn_dmamap_aligned(&cmd->src)) { in hifn_crypto()
1817 cmd->sloplen = cmd->src_mapsize & 3; in hifn_crypto()
1818 cmd->dst = cmd->src; in hifn_crypto()
1819 } else if (crp->crp_buf.cb_type == CRYPTO_BUF_MBUF) { in hifn_crypto()
1823 KASSERT(cmd->dst_m == NULL, in hifn_crypto()
1834 * have no guarantee that we'll be re-entered. in hifn_crypto()
1836 totlen = cmd->src_mapsize; in hifn_crypto()
1837 if (crp->crp_buf.cb_mbuf->m_flags & M_PKTHDR) { in hifn_crypto()
1840 if (m0 && !m_dup_pkthdr(m0, crp->crp_buf.cb_mbuf, in hifn_crypto()
1851 err = sc->sc_cmdu ? ERESTART : ENOMEM; in hifn_crypto()
1857 err = sc->sc_cmdu ? ERESTART : ENOMEM; in hifn_crypto()
1863 totlen -= len; in hifn_crypto()
1864 m0->m_pkthdr.len = m0->m_len = len; in hifn_crypto()
1871 err = sc->sc_cmdu ? ERESTART : ENOMEM; in hifn_crypto()
1879 err = sc->sc_cmdu ? ERESTART : ENOMEM; in hifn_crypto()
1880 mlast->m_next = m; in hifn_crypto()
1887 m->m_len = len; in hifn_crypto()
1888 m0->m_pkthdr.len += len; in hifn_crypto()
1889 totlen -= len; in hifn_crypto()
1891 mlast->m_next = m; in hifn_crypto()
1894 cmd->dst_m = m0; in hifn_crypto()
1896 if (bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT, in hifn_crypto()
1897 &cmd->dst_map)) { in hifn_crypto()
1903 if (bus_dmamap_load_mbuf_sg(sc->sc_dmat, cmd->dst_map, m0, in hifn_crypto()
1904 cmd->dst_segs, &cmd->dst_nsegs, 0)) { in hifn_crypto()
1909 cmd->dst_mapsize = m0->m_pkthdr.len; in hifn_crypto()
1917 device_printf(sc->sc_dev, in hifn_crypto()
1921 sc->sc_cmdu, sc->sc_srcu, sc->sc_dstu, sc->sc_resu, in hifn_crypto()
1922 cmd->src_nsegs, cmd->dst_nsegs); in hifn_crypto()
1926 if (cmd->src_map == cmd->dst_map) { in hifn_crypto()
1927 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_crypto()
1930 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_crypto()
1932 bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, in hifn_crypto()
1939 if ((sc->sc_srcu + cmd->src_nsegs) > HIFN_D_SRC_RSIZE || in hifn_crypto()
1940 (sc->sc_dstu + cmd->dst_nsegs + 1) > HIFN_D_DST_RSIZE) { in hifn_crypto()
1943 device_printf(sc->sc_dev, in hifn_crypto()
1945 sc->sc_srcu, cmd->src_nsegs, in hifn_crypto()
1946 sc->sc_dstu, cmd->dst_nsegs); in hifn_crypto()
1954 if (sc->sc_cmdi == HIFN_D_CMD_RSIZE) { in hifn_crypto()
1955 sc->sc_cmdi = 0; in hifn_crypto()
1956 dma->cmdr[HIFN_D_CMD_RSIZE].l = htole32(HIFN_D_VALID | in hifn_crypto()
1961 cmdi = sc->sc_cmdi++; in hifn_crypto()
1962 cmdlen = hifn_write_command(cmd, dma->command_bufs[cmdi]); in hifn_crypto()
1966 dma->cmdr[cmdi].l = htole32(cmdlen | HIFN_D_VALID | HIFN_D_LAST | in hifn_crypto()
1970 sc->sc_cmdu++; in hifn_crypto()
1977 if (sc->sc_cmdu > 1) { in hifn_crypto()
1978 sc->sc_dmaier |= HIFN_DMAIER_C_WAIT; in hifn_crypto()
1979 WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); in hifn_crypto()
1983 hifnstats.hst_ibytes += cmd->src_mapsize; in hifn_crypto()
1995 if (sc->sc_resi == HIFN_D_RES_RSIZE) { in hifn_crypto()
1996 sc->sc_resi = 0; in hifn_crypto()
1997 dma->resr[HIFN_D_RES_RSIZE].l = htole32(HIFN_D_VALID | in hifn_crypto()
2002 resi = sc->sc_resi++; in hifn_crypto()
2003 KASSERT(sc->sc_hifn_commands[resi] == NULL, in hifn_crypto()
2005 sc->sc_hifn_commands[resi] = cmd; in hifn_crypto()
2007 if ((hint & CRYPTO_HINT_MORE) && sc->sc_curbatch < hifn_maxbatch) { in hifn_crypto()
2008 dma->resr[resi].l = htole32(HIFN_MAX_RESULT | in hifn_crypto()
2010 sc->sc_curbatch++; in hifn_crypto()
2011 if (sc->sc_curbatch > hifnstats.hst_maxbatch) in hifn_crypto()
2012 hifnstats.hst_maxbatch = sc->sc_curbatch; in hifn_crypto()
2015 dma->resr[resi].l = htole32(HIFN_MAX_RESULT | in hifn_crypto()
2017 sc->sc_curbatch = 0; in hifn_crypto()
2021 sc->sc_resu++; in hifn_crypto()
2023 if (cmd->sloplen) in hifn_crypto()
2024 cmd->slopidx = resi; in hifn_crypto()
2028 csr = 0; in hifn_crypto()
2029 if (sc->sc_c_busy == 0) { in hifn_crypto()
2030 csr |= HIFN_DMACSR_C_CTRL_ENA; in hifn_crypto()
2031 sc->sc_c_busy = 1; in hifn_crypto()
2033 if (sc->sc_s_busy == 0) { in hifn_crypto()
2034 csr |= HIFN_DMACSR_S_CTRL_ENA; in hifn_crypto()
2035 sc->sc_s_busy = 1; in hifn_crypto()
2037 if (sc->sc_r_busy == 0) { in hifn_crypto()
2038 csr |= HIFN_DMACSR_R_CTRL_ENA; in hifn_crypto()
2039 sc->sc_r_busy = 1; in hifn_crypto()
2041 if (sc->sc_d_busy == 0) { in hifn_crypto()
2042 csr |= HIFN_DMACSR_D_CTRL_ENA; in hifn_crypto()
2043 sc->sc_d_busy = 1; in hifn_crypto()
2045 if (csr) in hifn_crypto()
2046 WRITE_REG_1(sc, HIFN_1_DMA_CSR, csr); in hifn_crypto()
2050 device_printf(sc->sc_dev, "command: stat %8x ier %8x\n", in hifn_crypto()
2056 sc->sc_active = 5; in hifn_crypto()
2062 if (cmd->src_map != cmd->dst_map) in hifn_crypto()
2063 bus_dmamap_unload(sc->sc_dmat, cmd->dst_map); in hifn_crypto()
2065 if (cmd->src_map != cmd->dst_map) in hifn_crypto()
2066 bus_dmamap_destroy(sc->sc_dmat, cmd->dst_map); in hifn_crypto()
2068 if (crp->crp_buf.cb_type == CRYPTO_BUF_MBUF) { in hifn_crypto()
2069 if (cmd->dst_m != NULL) in hifn_crypto()
2070 m_freem(cmd->dst_m); in hifn_crypto()
2072 bus_dmamap_unload(sc->sc_dmat, cmd->src_map); in hifn_crypto()
2074 bus_dmamap_destroy(sc->sc_dmat, cmd->src_map); in hifn_crypto()
2085 if (sc->sc_active == 0) { in hifn_tick()
2088 if (sc->sc_cmdu == 0 && sc->sc_c_busy) { in hifn_tick()
2089 sc->sc_c_busy = 0; in hifn_tick()
2092 if (sc->sc_srcu == 0 && sc->sc_s_busy) { in hifn_tick()
2093 sc->sc_s_busy = 0; in hifn_tick()
2096 if (sc->sc_dstu == 0 && sc->sc_d_busy) { in hifn_tick()
2097 sc->sc_d_busy = 0; in hifn_tick()
2100 if (sc->sc_resu == 0 && sc->sc_r_busy) { in hifn_tick()
2101 sc->sc_r_busy = 0; in hifn_tick()
2107 sc->sc_active--; in hifn_tick()
2109 callout_reset(&sc->sc_tickto, hz, hifn_tick, sc); in hifn_tick()
2123 if ((dmacsr & sc->sc_dmaier) == 0) in hifn_intr()
2128 dma = sc->sc_dma; in hifn_intr()
2132 device_printf(sc->sc_dev, in hifn_intr()
2134 dmacsr, READ_REG_1(sc, HIFN_1_DMA_IER), sc->sc_dmaier, in hifn_intr()
2135 sc->sc_cmdi, sc->sc_srci, sc->sc_dsti, sc->sc_resi, in hifn_intr()
2136 sc->sc_cmdk, sc->sc_srck, sc->sc_dstk, sc->sc_resk, in hifn_intr()
2137 sc->sc_cmdu, sc->sc_srcu, sc->sc_dstu, sc->sc_resu); in hifn_intr()
2141 WRITE_REG_1(sc, HIFN_1_DMA_CSR, dmacsr & sc->sc_dmaier); in hifn_intr()
2143 if ((sc->sc_flags & HIFN_HAS_PUBLIC) && in hifn_intr()
2150 device_printf(sc->sc_dev, "overrun %x\n", dmacsr); in hifn_intr()
2152 if (sc->sc_flags & HIFN_IS_7811) { in hifn_intr()
2154 device_printf(sc->sc_dev, "illegal read\n"); in hifn_intr()
2156 device_printf(sc->sc_dev, "illegal write\n"); in hifn_intr()
2162 device_printf(sc->sc_dev, "abort, resetting.\n"); in hifn_intr()
2169 if ((dmacsr & HIFN_DMACSR_C_WAIT) && (sc->sc_cmdu == 0)) { in hifn_intr()
2175 sc->sc_dmaier &= ~HIFN_DMAIER_C_WAIT; in hifn_intr()
2176 WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); in hifn_intr()
2180 i = sc->sc_resk; u = sc->sc_resu; in hifn_intr()
2184 if (dma->resr[i].l & htole32(HIFN_D_VALID)) { in hifn_intr()
2195 cmd = sc->sc_hifn_commands[i]; in hifn_intr()
2198 sc->sc_hifn_commands[i] = NULL; in hifn_intr()
2200 if (cmd->base_masks & HIFN_BASE_CMD_MAC) { in hifn_intr()
2201 macbuf = dma->result_bufs[i]; in hifn_intr()
2207 u--; in hifn_intr()
2213 sc->sc_resk = i; sc->sc_resu = u; in hifn_intr()
2215 i = sc->sc_srck; u = sc->sc_srcu; in hifn_intr()
2221 if (dma->srcr[i].l & htole32(HIFN_D_VALID)) { in hifn_intr()
2226 i++, u--; in hifn_intr()
2228 sc->sc_srck = i; sc->sc_srcu = u; in hifn_intr()
2230 i = sc->sc_cmdk; u = sc->sc_cmdu; in hifn_intr()
2234 if (dma->cmdr[i].l & htole32(HIFN_D_VALID)) { in hifn_intr()
2240 u--; in hifn_intr()
2246 sc->sc_cmdk = i; sc->sc_cmdu = u; in hifn_intr()
2250 if (sc->sc_needwakeup) { /* XXX check high watermark */ in hifn_intr()
2251 int wakeup = sc->sc_needwakeup & CRYPTO_SYMQ; in hifn_intr()
2254 device_printf(sc->sc_dev, in hifn_intr()
2256 sc->sc_needwakeup, in hifn_intr()
2257 sc->sc_cmdu, sc->sc_srcu, sc->sc_dstu, sc->sc_resu); in hifn_intr()
2259 sc->sc_needwakeup &= ~wakeup; in hifn_intr()
2260 crypto_unblock(sc->sc_cid, wakeup); in hifn_intr()
2269 switch (sc->sc_ena) { in hifn_auth_supported()
2277 switch (csp->csp_auth_alg) { in hifn_auth_supported()
2281 if (csp->csp_auth_klen > HIFN_MAC_KEY_LENGTH) in hifn_auth_supported()
2296 if (csp->csp_cipher_klen == 0) in hifn_cipher_supported()
2298 if (csp->csp_ivlen > HIFN_MAX_IV_LENGTH) in hifn_cipher_supported()
2300 switch (sc->sc_ena) { in hifn_cipher_supported()
2302 switch (csp->csp_cipher_alg) { in hifn_cipher_supported()
2304 if ((sc->sc_flags & HIFN_HAS_AES) == 0) in hifn_cipher_supported()
2306 switch (csp->csp_cipher_klen) { in hifn_cipher_supported()
2326 if (csp->csp_flags != 0) in hifn_probesession()
2328 switch (csp->csp_mode) { in hifn_probesession()
2360 if (csp->csp_auth_alg != 0) { in hifn_newsession()
2361 if (csp->csp_auth_mlen == 0) in hifn_newsession()
2362 ses->hs_mlen = crypto_auth_hash(csp)->hashsize; in hifn_newsession()
2364 ses->hs_mlen = csp->csp_auth_mlen; in hifn_newsession()
2385 ses = crypto_get_driver_session(crp->crp_session); in hifn_process()
2394 csp = crypto_get_params(crp->crp_session); in hifn_process()
2400 if (csp->csp_mode == CSP_MODE_ETA && crp->crp_aad_length != 0 && in hifn_process()
2401 crp->crp_aad_start + crp->crp_aad_length != in hifn_process()
2402 crp->crp_payload_start) { in hifn_process()
2407 switch (csp->csp_mode) { in hifn_process()
2410 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) in hifn_process()
2411 cmd->base_masks |= HIFN_BASE_CMD_DECODE; in hifn_process()
2412 cmd->base_masks |= HIFN_BASE_CMD_CRYPT; in hifn_process()
2413 switch (csp->csp_cipher_alg) { in hifn_process()
2415 cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_AES | in hifn_process()
2423 crypto_read_iv(crp, cmd->iv); in hifn_process()
2425 if (crp->crp_cipher_key != NULL) in hifn_process()
2426 cmd->ck = crp->crp_cipher_key; in hifn_process()
2428 cmd->ck = csp->csp_cipher_key; in hifn_process()
2429 cmd->cklen = csp->csp_cipher_klen; in hifn_process()
2430 cmd->cry_masks |= HIFN_CRYPT_CMD_NEW_KEY; in hifn_process()
2435 if ((cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) == in hifn_process()
2437 switch (cmd->cklen) { in hifn_process()
2439 cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_128; in hifn_process()
2442 cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_192; in hifn_process()
2445 cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_256; in hifn_process()
2455 switch (csp->csp_mode) { in hifn_process()
2458 cmd->base_masks |= HIFN_BASE_CMD_MAC; in hifn_process()
2460 switch (csp->csp_auth_alg) { in hifn_process()
2462 cmd->mac_masks |= HIFN_MAC_CMD_ALG_SHA1 | in hifn_process()
2467 cmd->mac_masks |= HIFN_MAC_CMD_ALG_SHA1 | in hifn_process()
2473 if (csp->csp_auth_alg == CRYPTO_SHA1_HMAC) { in hifn_process()
2474 cmd->mac_masks |= HIFN_MAC_CMD_NEW_KEY; in hifn_process()
2475 if (crp->crp_auth_key != NULL) in hifn_process()
2476 mackey = crp->crp_auth_key; in hifn_process()
2478 mackey = csp->csp_auth_key; in hifn_process()
2479 keylen = csp->csp_auth_klen; in hifn_process()
2480 bcopy(mackey, cmd->mac, keylen); in hifn_process()
2481 bzero(cmd->mac + keylen, HIFN_MAC_KEY_LENGTH - keylen); in hifn_process()
2485 cmd->crp = crp; in hifn_process()
2486 cmd->session = ses; in hifn_process()
2487 cmd->softc = sc; in hifn_process()
2500 device_printf(sc->sc_dev, "requeue request\n"); in hifn_process()
2503 sc->sc_needwakeup |= CRYPTO_SYMQ; in hifn_process()
2514 crp->crp_etype = err; in hifn_process()
2522 struct hifn_dma *dma = sc->sc_dma; in hifn_abort()
2527 i = sc->sc_resk; u = sc->sc_resu; in hifn_abort()
2529 cmd = sc->sc_hifn_commands[i]; in hifn_abort()
2531 sc->sc_hifn_commands[i] = NULL; in hifn_abort()
2532 crp = cmd->crp; in hifn_abort()
2534 if ((dma->resr[i].l & htole32(HIFN_D_VALID)) == 0) { in hifn_abort()
2538 if (cmd->base_masks & HIFN_BASE_CMD_MAC) { in hifn_abort()
2539 macbuf = dma->result_bufs[i]; in hifn_abort()
2546 if (cmd->src_map == cmd->dst_map) { in hifn_abort()
2547 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_abort()
2550 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_abort()
2552 bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, in hifn_abort()
2556 if (cmd->dst_m != NULL) { in hifn_abort()
2557 m_freem(cmd->dst_m); in hifn_abort()
2560 /* non-shared buffers cannot be restarted */ in hifn_abort()
2561 if (cmd->src_map != cmd->dst_map) { in hifn_abort()
2566 crp->crp_etype = ENOMEM; in hifn_abort()
2567 bus_dmamap_unload(sc->sc_dmat, cmd->dst_map); in hifn_abort()
2568 bus_dmamap_destroy(sc->sc_dmat, cmd->dst_map); in hifn_abort()
2570 crp->crp_etype = ENOMEM; in hifn_abort()
2572 bus_dmamap_unload(sc->sc_dmat, cmd->src_map); in hifn_abort()
2573 bus_dmamap_destroy(sc->sc_dmat, cmd->src_map); in hifn_abort()
2576 if (crp->crp_etype != EAGAIN) in hifn_abort()
2582 u--; in hifn_abort()
2584 sc->sc_resk = i; sc->sc_resu = u; in hifn_abort()
2594 struct hifn_dma *dma = sc->sc_dma; in hifn_callback()
2595 struct cryptop *crp = cmd->crp; in hifn_callback()
2600 if (cmd->src_map == cmd->dst_map) { in hifn_callback()
2601 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_callback()
2604 bus_dmamap_sync(sc->sc_dmat, cmd->src_map, in hifn_callback()
2606 bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, in hifn_callback()
2610 if (crp->crp_buf.cb_type == CRYPTO_BUF_MBUF) { in hifn_callback()
2611 if (cmd->dst_m != NULL) { in hifn_callback()
2612 totlen = cmd->src_mapsize; in hifn_callback()
2613 for (m = cmd->dst_m; m != NULL; m = m->m_next) { in hifn_callback()
2614 if (totlen < m->m_len) { in hifn_callback()
2615 m->m_len = totlen; in hifn_callback()
2618 totlen -= m->m_len; in hifn_callback()
2620 cmd->dst_m->m_pkthdr.len = in hifn_callback()
2621 crp->crp_buf.cb_mbuf->m_pkthdr.len; in hifn_callback()
2622 m_freem(crp->crp_buf.cb_mbuf); in hifn_callback()
2623 crp->crp_buf.cb_mbuf = cmd->dst_m; in hifn_callback()
2627 if (cmd->sloplen != 0) { in hifn_callback()
2628 crypto_copyback(crp, cmd->src_mapsize - cmd->sloplen, in hifn_callback()
2629 cmd->sloplen, &dma->slop[cmd->slopidx]); in hifn_callback()
2632 i = sc->sc_dstk; u = sc->sc_dstu; in hifn_callback()
2636 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_callback()
2638 if (dma->dstr[i].l & htole32(HIFN_D_VALID)) { in hifn_callback()
2639 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, in hifn_callback()
2643 i++, u--; in hifn_callback()
2645 sc->sc_dstk = i; sc->sc_dstu = u; in hifn_callback()
2647 hifnstats.hst_obytes += cmd->dst_mapsize; in hifn_callback()
2650 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in hifn_callback()
2651 crypto_copydata(crp, crp->crp_digest_start, in hifn_callback()
2652 cmd->session->hs_mlen, macbuf2); in hifn_callback()
2654 cmd->session->hs_mlen) != 0) in hifn_callback()
2655 crp->crp_etype = EBADMSG; in hifn_callback()
2657 crypto_copyback(crp, crp->crp_digest_start, in hifn_callback()
2658 cmd->session->hs_mlen, macbuf); in hifn_callback()
2661 if (cmd->src_map != cmd->dst_map) { in hifn_callback()
2662 bus_dmamap_unload(sc->sc_dmat, cmd->dst_map); in hifn_callback()
2663 bus_dmamap_destroy(sc->sc_dmat, cmd->dst_map); in hifn_callback()
2665 bus_dmamap_unload(sc->sc_dmat, cmd->src_map); in hifn_callback()
2666 bus_dmamap_destroy(sc->sc_dmat, cmd->src_map); in hifn_callback()
2672 * 7811 PB3 rev/2 parts lock-up on burst writes to Group 0
2683 if (sc->sc_flags & HIFN_IS_7811) { in hifn_write_reg_0()
2684 if (sc->sc_bar0_lastreg == reg - 4) in hifn_write_reg_0()
2685 bus_space_read_4(sc->sc_st0, sc->sc_sh0, HIFN_0_PUCNFG); in hifn_write_reg_0()
2686 sc->sc_bar0_lastreg = reg; in hifn_write_reg_0()
2688 bus_space_write_4(sc->sc_st0, sc->sc_sh0, reg, val); in hifn_write_reg_0()
2694 if (sc->sc_flags & HIFN_IS_7811) { in hifn_write_reg_1()
2695 if (sc->sc_bar1_lastreg == reg - 4) in hifn_write_reg_1()
2696 bus_space_read_4(sc->sc_st1, sc->sc_sh1, HIFN_1_REVID); in hifn_write_reg_1()
2697 sc->sc_bar1_lastreg = reg; in hifn_write_reg_1()
2699 bus_space_write_4(sc->sc_st1, sc->sc_sh1, reg, val); in hifn_write_reg_1()
2716 sc = dev->si_drv1; in vulcanpk_mmap()
2718 pd = rman_get_start(sc->sc_bar1res); in vulcanpk_mmap()
2719 b = rman_get_virtual(sc->sc_bar1res); in vulcanpk_mmap()
2731 return (-1); in vulcanpk_mmap()