Lines Matching refs:dev

601 	struct hifn_device	*dev;  member
616 struct hifn_device *dev; member
629 static inline u32 hifn_read_0(struct hifn_device *dev, u32 reg) in hifn_read_0() argument
631 return readl(dev->bar[0] + reg); in hifn_read_0()
634 static inline u32 hifn_read_1(struct hifn_device *dev, u32 reg) in hifn_read_1() argument
636 return readl(dev->bar[1] + reg); in hifn_read_1()
639 static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val) in hifn_write_0() argument
641 writel((__force u32)cpu_to_le32(val), dev->bar[0] + reg); in hifn_write_0()
644 static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val) in hifn_write_1() argument
646 writel((__force u32)cpu_to_le32(val), dev->bar[1] + reg); in hifn_write_1()
649 static void hifn_wait_puc(struct hifn_device *dev) in hifn_wait_puc() argument
655 ret = hifn_read_0(dev, HIFN_0_PUCTRL); in hifn_wait_puc()
663 dev_err(&dev->pdev->dev, "Failed to reset PUC unit.\n"); in hifn_wait_puc()
666 static void hifn_reset_puc(struct hifn_device *dev) in hifn_reset_puc() argument
668 hifn_write_0(dev, HIFN_0_PUCTRL, HIFN_PUCTRL_DMAENA); in hifn_reset_puc()
669 hifn_wait_puc(dev); in hifn_reset_puc()
672 static void hifn_stop_device(struct hifn_device *dev) in hifn_stop_device() argument
674 hifn_write_1(dev, HIFN_1_DMA_CSR, in hifn_stop_device()
677 hifn_write_0(dev, HIFN_0_PUIER, 0); in hifn_stop_device()
678 hifn_write_1(dev, HIFN_1_DMA_IER, 0); in hifn_stop_device()
681 static void hifn_reset_dma(struct hifn_device *dev, int full) in hifn_reset_dma() argument
683 hifn_stop_device(dev); in hifn_reset_dma()
688 hifn_write_1(dev, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | in hifn_reset_dma()
696 hifn_write_1(dev, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MODE); in hifn_reset_dma()
699 hifn_write_1(dev, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MODE | in hifn_reset_dma()
701 hifn_reset_puc(dev); in hifn_reset_dma()
704 hifn_write_1(dev, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | in hifn_reset_dma()
707 hifn_reset_puc(dev); in hifn_reset_dma()
752 struct hifn_device *dev = (struct hifn_device *)rng->priv; in hifn_rng_data_present() local
755 nsec = ktime_to_ns(ktime_sub(ktime_get(), dev->rngtime)); in hifn_rng_data_present()
756 nsec -= dev->rng_wait_time; in hifn_rng_data_present()
767 struct hifn_device *dev = (struct hifn_device *)rng->priv; in hifn_rng_data_read() local
769 *data = hifn_read_1(dev, HIFN_1_RNG_DATA); in hifn_rng_data_read()
770 dev->rngtime = ktime_get(); in hifn_rng_data_read()
774 static int hifn_register_rng(struct hifn_device *dev) in hifn_register_rng() argument
779 dev->rng_wait_time = DIV_ROUND_UP_ULL(NSEC_PER_SEC, in hifn_register_rng()
780 dev->pk_clk_freq) * 256; in hifn_register_rng()
782 dev->rng.name = dev->name; in hifn_register_rng()
783 dev->rng.data_present = hifn_rng_data_present; in hifn_register_rng()
784 dev->rng.data_read = hifn_rng_data_read; in hifn_register_rng()
785 dev->rng.priv = (unsigned long)dev; in hifn_register_rng()
787 return hwrng_register(&dev->rng); in hifn_register_rng()
790 static void hifn_unregister_rng(struct hifn_device *dev) in hifn_unregister_rng() argument
792 hwrng_unregister(&dev->rng); in hifn_unregister_rng()
795 #define hifn_register_rng(dev) 0 argument
796 #define hifn_unregister_rng(dev) argument
799 static int hifn_init_pubrng(struct hifn_device *dev) in hifn_init_pubrng() argument
803 hifn_write_1(dev, HIFN_1_PUB_RESET, hifn_read_1(dev, HIFN_1_PUB_RESET) | in hifn_init_pubrng()
809 if ((hifn_read_1(dev, HIFN_1_PUB_RESET) & HIFN_PUBRST_RESET) == 0) in hifn_init_pubrng()
814 dev_err(&dev->pdev->dev, "Failed to initialise public key engine.\n"); in hifn_init_pubrng()
816 hifn_write_1(dev, HIFN_1_PUB_IEN, HIFN_PUBIEN_DONE); in hifn_init_pubrng()
817 dev->dmareg |= HIFN_DMAIER_PUBDONE; in hifn_init_pubrng()
818 hifn_write_1(dev, HIFN_1_DMA_IER, dev->dmareg); in hifn_init_pubrng()
820 dev_dbg(&dev->pdev->dev, "Public key engine has been successfully initialised.\n"); in hifn_init_pubrng()
825 hifn_write_1(dev, HIFN_1_RNG_CONFIG, in hifn_init_pubrng()
826 hifn_read_1(dev, HIFN_1_RNG_CONFIG) | HIFN_RNGCFG_ENA); in hifn_init_pubrng()
827 dev_dbg(&dev->pdev->dev, "RNG engine has been successfully initialised.\n"); in hifn_init_pubrng()
831 hifn_read_1(dev, HIFN_1_RNG_DATA); in hifn_init_pubrng()
832 dev->rngtime = ktime_get(); in hifn_init_pubrng()
837 static int hifn_enable_crypto(struct hifn_device *dev) in hifn_enable_crypto() argument
844 if (pci2id[i].pci_vendor == dev->pdev->vendor && in hifn_enable_crypto()
845 pci2id[i].pci_prod == dev->pdev->device) { in hifn_enable_crypto()
852 dev_err(&dev->pdev->dev, "Unknown card!\n"); in hifn_enable_crypto()
856 dmacfg = hifn_read_1(dev, HIFN_1_DMA_CNFG); in hifn_enable_crypto()
858 hifn_write_1(dev, HIFN_1_DMA_CNFG, in hifn_enable_crypto()
862 addr = hifn_read_1(dev, HIFN_1_UNLOCK_SECRET1); in hifn_enable_crypto()
864 hifn_write_1(dev, HIFN_1_UNLOCK_SECRET2, 0); in hifn_enable_crypto()
869 hifn_write_1(dev, HIFN_1_UNLOCK_SECRET2, addr); in hifn_enable_crypto()
873 hifn_write_1(dev, HIFN_1_DMA_CNFG, dmacfg); in hifn_enable_crypto()
875 dev_dbg(&dev->pdev->dev, "%s %s.\n", dev->name, pci_name(dev->pdev)); in hifn_enable_crypto()
880 static void hifn_init_dma(struct hifn_device *dev) in hifn_init_dma() argument
882 struct hifn_dma *dma = dev->desc_virt; in hifn_init_dma()
883 u32 dptr = dev->desc_dma; in hifn_init_dma()
921 static void hifn_init_pll(struct hifn_device *dev) in hifn_init_pll() argument
937 …dev_info(&dev->pdev->dev, "assuming %uMHz clock speed, override with hifn_pll_ref=%.3s<frequency>\… in hifn_init_pll()
950 hifn_write_1(dev, HIFN_1_PLL, pllcfg | in hifn_init_pll()
957 hifn_write_1(dev, HIFN_1_PLL, pllcfg | in hifn_init_pll()
961 hifn_write_1(dev, HIFN_1_PLL, pllcfg | in hifn_init_pll()
970 dev->pk_clk_freq = 1000000 * (freq + 1) * m / 2; in hifn_init_pll()
973 static void hifn_init_registers(struct hifn_device *dev) in hifn_init_registers() argument
975 u32 dptr = dev->desc_dma; in hifn_init_registers()
978 hifn_write_0(dev, HIFN_0_PUCTRL, HIFN_PUCTRL_DMAENA); in hifn_init_registers()
979 hifn_write_0(dev, HIFN_0_FIFOCNFG, HIFN_FIFOCNFG_THRESHOLD); in hifn_init_registers()
980 hifn_write_0(dev, HIFN_0_PUIER, HIFN_PUIER_DSTOVER); in hifn_init_registers()
983 hifn_write_1(dev, HIFN_1_DMA_CRAR, dptr + in hifn_init_registers()
985 hifn_write_1(dev, HIFN_1_DMA_SRAR, dptr + in hifn_init_registers()
987 hifn_write_1(dev, HIFN_1_DMA_DRAR, dptr + in hifn_init_registers()
989 hifn_write_1(dev, HIFN_1_DMA_RRAR, dptr + in hifn_init_registers()
994 hifn_write_1(dev, HIFN_1_DMA_CSR, in hifn_init_registers()
1008 hifn_write_1(dev, HIFN_1_DMA_CSR, in hifn_init_registers()
1022 hifn_read_1(dev, HIFN_1_DMA_CSR); in hifn_init_registers()
1024 dev->dmareg |= HIFN_DMAIER_R_DONE | HIFN_DMAIER_C_ABORT | in hifn_init_registers()
1028 dev->dmareg &= ~HIFN_DMAIER_C_WAIT; in hifn_init_registers()
1030 hifn_write_1(dev, HIFN_1_DMA_IER, dev->dmareg); in hifn_init_registers()
1031 hifn_read_1(dev, HIFN_1_DMA_IER); in hifn_init_registers()
1033 hifn_write_0(dev, HIFN_0_PUCNFG, HIFN_PUCNFG_ENCCNFG | in hifn_init_registers()
1038 hifn_write_0(dev, HIFN_0_PUCNFG, 0x10342); in hifn_init_registers()
1040 hifn_init_pll(dev); in hifn_init_registers()
1042 hifn_write_0(dev, HIFN_0_PUISR, HIFN_PUISR_DSTOVER); in hifn_init_registers()
1043 hifn_write_1(dev, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | in hifn_init_registers()
1049 static int hifn_setup_base_command(struct hifn_device *dev, u8 *buf, in hifn_setup_base_command() argument
1071 static int hifn_setup_crypto_command(struct hifn_device *dev, in hifn_setup_crypto_command() argument
1075 struct hifn_dma *dma = dev->desc_virt; in hifn_setup_crypto_command()
1094 dev->dmareg |= HIFN_DMAIER_C_WAIT; in hifn_setup_crypto_command()
1095 hifn_write_1(dev, HIFN_1_DMA_IER, dev->dmareg); in hifn_setup_crypto_command()
1112 static int hifn_setup_cmd_desc(struct hifn_device *dev, in hifn_setup_cmd_desc() argument
1116 struct hifn_dma *dma = dev->desc_virt; in hifn_setup_cmd_desc()
1139 buf_pos += hifn_setup_base_command(dev, buf_pos, nbytes, in hifn_setup_cmd_desc()
1140 nbytes, mask, dev->snum); in hifn_setup_cmd_desc()
1200 buf_pos += hifn_setup_crypto_command(dev, buf_pos, in hifn_setup_cmd_desc()
1205 dev->sa[sa_idx] = priv; in hifn_setup_cmd_desc()
1206 dev->started++; in hifn_setup_cmd_desc()
1221 if (!(dev->flags & HIFN_FLAG_CMD_BUSY)) { in hifn_setup_cmd_desc()
1222 hifn_write_1(dev, HIFN_1_DMA_CSR, HIFN_DMACSR_C_CTRL_ENA); in hifn_setup_cmd_desc()
1223 dev->flags |= HIFN_FLAG_CMD_BUSY; in hifn_setup_cmd_desc()
1231 static int hifn_setup_src_desc(struct hifn_device *dev, struct page *page, in hifn_setup_src_desc() argument
1234 struct hifn_dma *dma = dev->desc_virt; in hifn_setup_src_desc()
1238 addr = dma_map_page(&dev->pdev->dev, page, offset, size, in hifn_setup_src_desc()
1257 if (!(dev->flags & HIFN_FLAG_SRC_BUSY)) { in hifn_setup_src_desc()
1258 hifn_write_1(dev, HIFN_1_DMA_CSR, HIFN_DMACSR_S_CTRL_ENA); in hifn_setup_src_desc()
1259 dev->flags |= HIFN_FLAG_SRC_BUSY; in hifn_setup_src_desc()
1265 static void hifn_setup_res_desc(struct hifn_device *dev) in hifn_setup_res_desc() argument
1267 struct hifn_dma *dma = dev->desc_virt; in hifn_setup_res_desc()
1284 if (!(dev->flags & HIFN_FLAG_RES_BUSY)) { in hifn_setup_res_desc()
1285 hifn_write_1(dev, HIFN_1_DMA_CSR, HIFN_DMACSR_R_CTRL_ENA); in hifn_setup_res_desc()
1286 dev->flags |= HIFN_FLAG_RES_BUSY; in hifn_setup_res_desc()
1290 static void hifn_setup_dst_desc(struct hifn_device *dev, struct page *page, in hifn_setup_dst_desc() argument
1293 struct hifn_dma *dma = dev->desc_virt; in hifn_setup_dst_desc()
1297 addr = dma_map_page(&dev->pdev->dev, page, offset, size, in hifn_setup_dst_desc()
1314 if (!(dev->flags & HIFN_FLAG_DST_BUSY)) { in hifn_setup_dst_desc()
1315 hifn_write_1(dev, HIFN_1_DMA_CSR, HIFN_DMACSR_D_CTRL_ENA); in hifn_setup_dst_desc()
1316 dev->flags |= HIFN_FLAG_DST_BUSY; in hifn_setup_dst_desc()
1320 static int hifn_setup_dma(struct hifn_device *dev, in hifn_setup_dma() argument
1336 hifn_setup_src_desc(dev, spage, soff, len, n - len == 0); in hifn_setup_dma()
1358 hifn_setup_dst_desc(dev, dpage, doff, len, n - len == 0); in hifn_setup_dma()
1365 hifn_setup_cmd_desc(dev, ctx, rctx, priv, nbytes); in hifn_setup_dma()
1366 hifn_setup_res_desc(dev); in hifn_setup_dma()
1528 struct hifn_device *dev = ctx->dev; in hifn_setup_session() local
1563 spin_lock_irqsave(&dev->lock, flags); in hifn_setup_session()
1564 if (dev->started + sg_num > HIFN_QUEUE_LENGTH) { in hifn_setup_session()
1569 err = hifn_setup_dma(dev, ctx, rctx, req->src, req->dst, req->cryptlen, req); in hifn_setup_session()
1573 dev->snum++; in hifn_setup_session()
1575 dev->active = HIFN_DEFAULT_ACTIVE_NUM; in hifn_setup_session()
1576 spin_unlock_irqrestore(&dev->lock, flags); in hifn_setup_session()
1581 spin_unlock_irqrestore(&dev->lock, flags); in hifn_setup_session()
1584 dev_info(&dev->pdev->dev, "iv: %p [%d], key: %p [%d], mode: %u, op: %u, " in hifn_setup_session()
1594 static int hifn_start_device(struct hifn_device *dev) in hifn_start_device() argument
1598 dev->started = dev->active = 0; in hifn_start_device()
1599 hifn_reset_dma(dev, 1); in hifn_start_device()
1601 err = hifn_enable_crypto(dev); in hifn_start_device()
1605 hifn_reset_puc(dev); in hifn_start_device()
1607 hifn_init_dma(dev); in hifn_start_device()
1609 hifn_init_registers(dev); in hifn_start_device()
1611 hifn_init_pubrng(dev); in hifn_start_device()
1652 static inline void hifn_complete_sa(struct hifn_device *dev, int i) in hifn_complete_sa() argument
1656 spin_lock_irqsave(&dev->lock, flags); in hifn_complete_sa()
1657 dev->sa[i] = NULL; in hifn_complete_sa()
1658 dev->started--; in hifn_complete_sa()
1659 if (dev->started < 0) in hifn_complete_sa()
1660 dev_info(&dev->pdev->dev, "%s: started: %d.\n", __func__, in hifn_complete_sa()
1661 dev->started); in hifn_complete_sa()
1662 spin_unlock_irqrestore(&dev->lock, flags); in hifn_complete_sa()
1663 BUG_ON(dev->started < 0); in hifn_complete_sa()
1711 static void hifn_clear_rings(struct hifn_device *dev, int error) in hifn_clear_rings() argument
1713 struct hifn_dma *dma = dev->desc_virt; in hifn_clear_rings()
1716 dev_dbg(&dev->pdev->dev, "ring cleanup 1: i: %d.%d.%d.%d, u: %d.%d.%d.%d, " in hifn_clear_rings()
1727 if (dev->sa[i]) { in hifn_clear_rings()
1728 dev->success++; in hifn_clear_rings()
1729 dev->reset = 0; in hifn_clear_rings()
1730 hifn_process_ready(dev->sa[i], error); in hifn_clear_rings()
1731 hifn_complete_sa(dev, i); in hifn_clear_rings()
1770 dev_dbg(&dev->pdev->dev, "ring cleanup 2: i: %d.%d.%d.%d, u: %d.%d.%d.%d, " in hifn_clear_rings()
1780 struct hifn_device *dev = container_of(dw, struct hifn_device, work); in hifn_work() local
1785 spin_lock_irqsave(&dev->lock, flags); in hifn_work()
1786 if (dev->active == 0) { in hifn_work()
1787 struct hifn_dma *dma = dev->desc_virt; in hifn_work()
1789 if (dma->cmdu == 0 && (dev->flags & HIFN_FLAG_CMD_BUSY)) { in hifn_work()
1790 dev->flags &= ~HIFN_FLAG_CMD_BUSY; in hifn_work()
1793 if (dma->srcu == 0 && (dev->flags & HIFN_FLAG_SRC_BUSY)) { in hifn_work()
1794 dev->flags &= ~HIFN_FLAG_SRC_BUSY; in hifn_work()
1797 if (dma->dstu == 0 && (dev->flags & HIFN_FLAG_DST_BUSY)) { in hifn_work()
1798 dev->flags &= ~HIFN_FLAG_DST_BUSY; in hifn_work()
1801 if (dma->resu == 0 && (dev->flags & HIFN_FLAG_RES_BUSY)) { in hifn_work()
1802 dev->flags &= ~HIFN_FLAG_RES_BUSY; in hifn_work()
1806 hifn_write_1(dev, HIFN_1_DMA_CSR, r); in hifn_work()
1808 dev->active--; in hifn_work()
1810 if ((dev->prev_success == dev->success) && dev->started) in hifn_work()
1812 dev->prev_success = dev->success; in hifn_work()
1813 spin_unlock_irqrestore(&dev->lock, flags); in hifn_work()
1816 if (++dev->reset >= 5) { in hifn_work()
1818 struct hifn_dma *dma = dev->desc_virt; in hifn_work()
1820 dev_info(&dev->pdev->dev, in hifn_work()
1823 r, dev->active, dev->started, in hifn_work()
1824 dev->success, dev->queue.qlen, dev->queue.max_qlen, in hifn_work()
1827 dev_info(&dev->pdev->dev, "%s: res: ", __func__); in hifn_work()
1829 pr_info("%x.%p ", dma->resr[i].l, dev->sa[i]); in hifn_work()
1830 if (dev->sa[i]) { in hifn_work()
1831 hifn_process_ready(dev->sa[i], -ENODEV); in hifn_work()
1832 hifn_complete_sa(dev, i); in hifn_work()
1837 hifn_reset_dma(dev, 1); in hifn_work()
1838 hifn_stop_device(dev); in hifn_work()
1839 hifn_start_device(dev); in hifn_work()
1840 dev->reset = 0; in hifn_work()
1843 tasklet_schedule(&dev->tasklet); in hifn_work()
1846 schedule_delayed_work(&dev->work, HZ); in hifn_work()
1851 struct hifn_device *dev = data; in hifn_interrupt() local
1852 struct hifn_dma *dma = dev->desc_virt; in hifn_interrupt()
1855 dmacsr = hifn_read_1(dev, HIFN_1_DMA_CSR); in hifn_interrupt()
1857 dev_dbg(&dev->pdev->dev, "1 dmacsr: %08x, dmareg: %08x, res: %08x [%d], " in hifn_interrupt()
1859 dmacsr, dev->dmareg, dmacsr & dev->dmareg, dma->cmdi, in hifn_interrupt()
1863 if ((dmacsr & dev->dmareg) == 0) in hifn_interrupt()
1866 hifn_write_1(dev, HIFN_1_DMA_CSR, dmacsr & dev->dmareg); in hifn_interrupt()
1869 hifn_write_0(dev, HIFN_0_PUISR, hifn_read_0(dev, HIFN_0_PUISR)); in hifn_interrupt()
1871 hifn_write_1(dev, HIFN_1_PUB_STATUS, in hifn_interrupt()
1872 hifn_read_1(dev, HIFN_1_PUB_STATUS) | HIFN_PUBSTS_DONE); in hifn_interrupt()
1876 u32 puisr = hifn_read_0(dev, HIFN_0_PUISR); in hifn_interrupt()
1878 dev_warn(&dev->pdev->dev, "overflow: r: %d, d: %d, puisr: %08x, d: %u.\n", in hifn_interrupt()
1883 hifn_write_0(dev, HIFN_0_PUISR, HIFN_PUISR_DSTOVER); in hifn_interrupt()
1884 hifn_write_1(dev, HIFN_1_DMA_CSR, dmacsr & (HIFN_DMACSR_R_OVER | in hifn_interrupt()
1891 dev_warn(&dev->pdev->dev, "abort: c: %d, s: %d, d: %d, r: %d.\n", in hifn_interrupt()
1896 hifn_reset_dma(dev, 1); in hifn_interrupt()
1897 hifn_init_dma(dev); in hifn_interrupt()
1898 hifn_init_registers(dev); in hifn_interrupt()
1902 dev_dbg(&dev->pdev->dev, "wait on command.\n"); in hifn_interrupt()
1903 dev->dmareg &= ~(HIFN_DMAIER_C_WAIT); in hifn_interrupt()
1904 hifn_write_1(dev, HIFN_1_DMA_IER, dev->dmareg); in hifn_interrupt()
1907 tasklet_schedule(&dev->tasklet); in hifn_interrupt()
1912 static void hifn_flush(struct hifn_device *dev) in hifn_flush() argument
1917 struct hifn_dma *dma = dev->desc_virt; in hifn_flush()
1923 if (dev->sa[i]) { in hifn_flush()
1924 hifn_process_ready(dev->sa[i], in hifn_flush()
1926 hifn_complete_sa(dev, i); in hifn_flush()
1930 spin_lock_irqsave(&dev->lock, flags); in hifn_flush()
1931 while ((async_req = crypto_dequeue_request(&dev->queue))) { in hifn_flush()
1933 spin_unlock_irqrestore(&dev->lock, flags); in hifn_flush()
1937 spin_lock_irqsave(&dev->lock, flags); in hifn_flush()
1939 spin_unlock_irqrestore(&dev->lock, flags); in hifn_flush()
1946 struct hifn_device *dev = ctx->dev; in hifn_setkey() local
1953 dev->flags &= ~HIFN_FLAG_OLD_KEY; in hifn_setkey()
1965 struct hifn_device *dev = ctx->dev; in hifn_des3_setkey() local
1972 dev->flags &= ~HIFN_FLAG_OLD_KEY; in hifn_des3_setkey()
1983 struct hifn_device *dev = ctx->dev; in hifn_handle_req() local
1986 if (dev->started + DIV_ROUND_UP(req->cryptlen, PAGE_SIZE) <= HIFN_QUEUE_LENGTH) in hifn_handle_req()
1992 spin_lock_irqsave(&dev->lock, flags); in hifn_handle_req()
1993 err = crypto_enqueue_request(&dev->queue, &req->base); in hifn_handle_req()
1994 spin_unlock_irqrestore(&dev->lock, flags); in hifn_handle_req()
2040 static int hifn_process_queue(struct hifn_device *dev) in hifn_process_queue() argument
2047 while (dev->started < HIFN_QUEUE_LENGTH) { in hifn_process_queue()
2048 spin_lock_irqsave(&dev->lock, flags); in hifn_process_queue()
2049 backlog = crypto_get_backlog(&dev->queue); in hifn_process_queue()
2050 async_req = crypto_dequeue_request(&dev->queue); in hifn_process_queue()
2051 spin_unlock_irqrestore(&dev->lock, flags); in hifn_process_queue()
2074 struct hifn_device *dev = ctx->dev; in hifn_setup_crypto() local
2080 if (dev->started < HIFN_QUEUE_LENGTH && dev->queue.qlen) in hifn_setup_crypto()
2081 hifn_process_queue(dev); in hifn_setup_crypto()
2378 ctx->dev = ha->dev; in hifn_init_tfm()
2384 static int hifn_alg_alloc(struct hifn_device *dev, const struct hifn_alg_template *t) in hifn_alg_alloc() argument
2398 t->drv_name, dev->name); in hifn_alg_alloc()
2407 alg->dev = dev; in hifn_alg_alloc()
2409 list_add_tail(&alg->entry, &dev->alg_list); in hifn_alg_alloc()
2420 static void hifn_unregister_alg(struct hifn_device *dev) in hifn_unregister_alg() argument
2424 list_for_each_entry_safe(a, n, &dev->alg_list, entry) { in hifn_unregister_alg()
2431 static int hifn_register_alg(struct hifn_device *dev) in hifn_register_alg() argument
2436 err = hifn_alg_alloc(dev, &hifn_alg_templates[i]); in hifn_register_alg()
2444 hifn_unregister_alg(dev); in hifn_register_alg()
2450 struct hifn_device *dev = (struct hifn_device *)data; in hifn_tasklet_callback() local
2458 hifn_clear_rings(dev, 0); in hifn_tasklet_callback()
2460 if (dev->started < HIFN_QUEUE_LENGTH && dev->queue.qlen) in hifn_tasklet_callback()
2461 hifn_process_queue(dev); in hifn_tasklet_callback()
2467 struct hifn_device *dev; in hifn_probe() local
2475 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in hifn_probe()
2489 dev_err(&pdev->dev, "Broken hardware - I/O regions are too small.\n"); in hifn_probe()
2494 dev = kzalloc(sizeof(struct hifn_device) + sizeof(struct crypto_alg), in hifn_probe()
2496 if (!dev) { in hifn_probe()
2501 INIT_LIST_HEAD(&dev->alg_list); in hifn_probe()
2503 snprintf(dev->name, sizeof(dev->name), "%s", name); in hifn_probe()
2504 spin_lock_init(&dev->lock); in hifn_probe()
2512 dev->bar[i] = ioremap(addr, size); in hifn_probe()
2513 if (!dev->bar[i]) { in hifn_probe()
2519 dev->desc_virt = dma_alloc_coherent(&pdev->dev, in hifn_probe()
2521 &dev->desc_dma, GFP_KERNEL); in hifn_probe()
2522 if (!dev->desc_virt) { in hifn_probe()
2523 dev_err(&pdev->dev, "Failed to allocate descriptor rings.\n"); in hifn_probe()
2528 dev->pdev = pdev; in hifn_probe()
2529 dev->irq = pdev->irq; in hifn_probe()
2532 dev->sa[i] = NULL; in hifn_probe()
2534 pci_set_drvdata(pdev, dev); in hifn_probe()
2536 tasklet_init(&dev->tasklet, hifn_tasklet_callback, (unsigned long)dev); in hifn_probe()
2538 crypto_init_queue(&dev->queue, 1); in hifn_probe()
2540 err = request_irq(dev->irq, hifn_interrupt, IRQF_SHARED, dev->name, dev); in hifn_probe()
2542 dev_err(&pdev->dev, "Failed to request IRQ%d: err: %d.\n", in hifn_probe()
2543 dev->irq, err); in hifn_probe()
2544 dev->irq = 0; in hifn_probe()
2548 err = hifn_start_device(dev); in hifn_probe()
2552 err = hifn_register_rng(dev); in hifn_probe()
2556 err = hifn_register_alg(dev); in hifn_probe()
2560 INIT_DELAYED_WORK(&dev->work, hifn_work); in hifn_probe()
2561 schedule_delayed_work(&dev->work, HZ); in hifn_probe()
2563 dev_dbg(&pdev->dev, "HIFN crypto accelerator card at %s has been " in hifn_probe()
2565 pci_name(pdev), dev->name); in hifn_probe()
2570 hifn_unregister_rng(dev); in hifn_probe()
2572 hifn_reset_dma(dev, 1); in hifn_probe()
2573 hifn_stop_device(dev); in hifn_probe()
2575 free_irq(dev->irq, dev); in hifn_probe()
2576 tasklet_kill(&dev->tasklet); in hifn_probe()
2578 dma_free_coherent(&pdev->dev, sizeof(struct hifn_dma), dev->desc_virt, in hifn_probe()
2579 dev->desc_dma); in hifn_probe()
2583 if (dev->bar[i]) in hifn_probe()
2584 iounmap(dev->bar[i]); in hifn_probe()
2585 kfree(dev); in hifn_probe()
2599 struct hifn_device *dev; in hifn_remove() local
2601 dev = pci_get_drvdata(pdev); in hifn_remove()
2603 if (dev) { in hifn_remove()
2604 cancel_delayed_work_sync(&dev->work); in hifn_remove()
2606 hifn_unregister_rng(dev); in hifn_remove()
2607 hifn_unregister_alg(dev); in hifn_remove()
2608 hifn_reset_dma(dev, 1); in hifn_remove()
2609 hifn_stop_device(dev); in hifn_remove()
2611 free_irq(dev->irq, dev); in hifn_remove()
2612 tasklet_kill(&dev->tasklet); in hifn_remove()
2614 hifn_flush(dev); in hifn_remove()
2616 dma_free_coherent(&pdev->dev, sizeof(struct hifn_dma), in hifn_remove()
2617 dev->desc_virt, dev->desc_dma); in hifn_remove()
2619 if (dev->bar[i]) in hifn_remove()
2620 iounmap(dev->bar[i]); in hifn_remove()
2622 kfree(dev); in hifn_remove()