| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 2007+ Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru> |
|---|
| 3 | 4 | * All rights reserved. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 7 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | | - * (at your option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | |
|---|
| 16 | 7 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 30 | 21 | #include <linux/ktime.h> |
|---|
| 31 | 22 | |
|---|
| 32 | 23 | #include <crypto/algapi.h> |
|---|
| 33 | | -#include <crypto/des.h> |
|---|
| 24 | +#include <crypto/internal/des.h> |
|---|
| 25 | +#include <crypto/internal/skcipher.h> |
|---|
| 34 | 26 | |
|---|
| 35 | 27 | static char hifn_pll_ref[sizeof("extNNN")] = "ext"; |
|---|
| 36 | 28 | module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444); |
|---|
| .. | .. |
|---|
| 605 | 597 | |
|---|
| 606 | 598 | struct hifn_crypto_alg { |
|---|
| 607 | 599 | struct list_head entry; |
|---|
| 608 | | - struct crypto_alg alg; |
|---|
| 600 | + struct skcipher_alg alg; |
|---|
| 609 | 601 | struct hifn_device *dev; |
|---|
| 610 | 602 | }; |
|---|
| 611 | 603 | |
|---|
| .. | .. |
|---|
| 788 | 780 | dev->pk_clk_freq) * 256; |
|---|
| 789 | 781 | |
|---|
| 790 | 782 | dev->rng.name = dev->name; |
|---|
| 791 | | - dev->rng.data_present = hifn_rng_data_present, |
|---|
| 792 | | - dev->rng.data_read = hifn_rng_data_read, |
|---|
| 783 | + dev->rng.data_present = hifn_rng_data_present; |
|---|
| 784 | + dev->rng.data_read = hifn_rng_data_read; |
|---|
| 793 | 785 | dev->rng.priv = (unsigned long)dev; |
|---|
| 794 | 786 | |
|---|
| 795 | 787 | return hwrng_register(&dev->rng); |
|---|
| .. | .. |
|---|
| 1243 | 1235 | int idx; |
|---|
| 1244 | 1236 | dma_addr_t addr; |
|---|
| 1245 | 1237 | |
|---|
| 1246 | | - addr = pci_map_page(dev->pdev, page, offset, size, PCI_DMA_TODEVICE); |
|---|
| 1238 | + addr = dma_map_page(&dev->pdev->dev, page, offset, size, |
|---|
| 1239 | + DMA_TO_DEVICE); |
|---|
| 1247 | 1240 | |
|---|
| 1248 | 1241 | idx = dma->srci; |
|---|
| 1249 | 1242 | |
|---|
| .. | .. |
|---|
| 1301 | 1294 | int idx; |
|---|
| 1302 | 1295 | dma_addr_t addr; |
|---|
| 1303 | 1296 | |
|---|
| 1304 | | - addr = pci_map_page(dev->pdev, page, offset, size, PCI_DMA_FROMDEVICE); |
|---|
| 1297 | + addr = dma_map_page(&dev->pdev->dev, page, offset, size, |
|---|
| 1298 | + DMA_FROM_DEVICE); |
|---|
| 1305 | 1299 | |
|---|
| 1306 | 1300 | idx = dma->dsti; |
|---|
| 1307 | 1301 | dma->dstr[idx].p = __cpu_to_le32(addr); |
|---|
| .. | .. |
|---|
| 1413 | 1407 | w->num = 0; |
|---|
| 1414 | 1408 | } |
|---|
| 1415 | 1409 | |
|---|
| 1416 | | -static int ablkcipher_add(unsigned int *drestp, struct scatterlist *dst, |
|---|
| 1410 | +static int skcipher_add(unsigned int *drestp, struct scatterlist *dst, |
|---|
| 1417 | 1411 | unsigned int size, unsigned int *nbytesp) |
|---|
| 1418 | 1412 | { |
|---|
| 1419 | 1413 | unsigned int copy, drest = *drestp, nbytes = *nbytesp; |
|---|
| .. | .. |
|---|
| 1442 | 1436 | return idx; |
|---|
| 1443 | 1437 | } |
|---|
| 1444 | 1438 | |
|---|
| 1445 | | -static int hifn_cipher_walk(struct ablkcipher_request *req, |
|---|
| 1439 | +static int hifn_cipher_walk(struct skcipher_request *req, |
|---|
| 1446 | 1440 | struct hifn_cipher_walk *w) |
|---|
| 1447 | 1441 | { |
|---|
| 1448 | 1442 | struct scatterlist *dst, *t; |
|---|
| 1449 | | - unsigned int nbytes = req->nbytes, offset, copy, diff; |
|---|
| 1443 | + unsigned int nbytes = req->cryptlen, offset, copy, diff; |
|---|
| 1450 | 1444 | int idx, tidx, err; |
|---|
| 1451 | 1445 | |
|---|
| 1452 | 1446 | tidx = idx = 0; |
|---|
| .. | .. |
|---|
| 1468 | 1462 | |
|---|
| 1469 | 1463 | t = &w->cache[idx]; |
|---|
| 1470 | 1464 | |
|---|
| 1471 | | - err = ablkcipher_add(&dlen, dst, slen, &nbytes); |
|---|
| 1465 | + err = skcipher_add(&dlen, dst, slen, &nbytes); |
|---|
| 1472 | 1466 | if (err < 0) |
|---|
| 1473 | 1467 | return err; |
|---|
| 1474 | 1468 | |
|---|
| .. | .. |
|---|
| 1507 | 1501 | |
|---|
| 1508 | 1502 | dst = &req->dst[idx]; |
|---|
| 1509 | 1503 | |
|---|
| 1510 | | - err = ablkcipher_add(&dlen, dst, nbytes, &nbytes); |
|---|
| 1504 | + err = skcipher_add(&dlen, dst, nbytes, &nbytes); |
|---|
| 1511 | 1505 | if (err < 0) |
|---|
| 1512 | 1506 | return err; |
|---|
| 1513 | 1507 | |
|---|
| .. | .. |
|---|
| 1527 | 1521 | return tidx; |
|---|
| 1528 | 1522 | } |
|---|
| 1529 | 1523 | |
|---|
| 1530 | | -static int hifn_setup_session(struct ablkcipher_request *req) |
|---|
| 1524 | +static int hifn_setup_session(struct skcipher_request *req) |
|---|
| 1531 | 1525 | { |
|---|
| 1532 | 1526 | struct hifn_context *ctx = crypto_tfm_ctx(req->base.tfm); |
|---|
| 1533 | | - struct hifn_request_context *rctx = ablkcipher_request_ctx(req); |
|---|
| 1527 | + struct hifn_request_context *rctx = skcipher_request_ctx(req); |
|---|
| 1534 | 1528 | struct hifn_device *dev = ctx->dev; |
|---|
| 1535 | 1529 | unsigned long dlen, flags; |
|---|
| 1536 | | - unsigned int nbytes = req->nbytes, idx = 0; |
|---|
| 1530 | + unsigned int nbytes = req->cryptlen, idx = 0; |
|---|
| 1537 | 1531 | int err = -EINVAL, sg_num; |
|---|
| 1538 | 1532 | struct scatterlist *dst; |
|---|
| 1539 | 1533 | |
|---|
| .. | .. |
|---|
| 1572 | 1566 | goto err_out; |
|---|
| 1573 | 1567 | } |
|---|
| 1574 | 1568 | |
|---|
| 1575 | | - err = hifn_setup_dma(dev, ctx, rctx, req->src, req->dst, req->nbytes, req); |
|---|
| 1569 | + err = hifn_setup_dma(dev, ctx, rctx, req->src, req->dst, req->cryptlen, req); |
|---|
| 1576 | 1570 | if (err) |
|---|
| 1577 | 1571 | goto err_out; |
|---|
| 1578 | 1572 | |
|---|
| .. | .. |
|---|
| 1619 | 1613 | return 0; |
|---|
| 1620 | 1614 | } |
|---|
| 1621 | 1615 | |
|---|
| 1622 | | -static int ablkcipher_get(void *saddr, unsigned int *srestp, unsigned int offset, |
|---|
| 1616 | +static int skcipher_get(void *saddr, unsigned int *srestp, unsigned int offset, |
|---|
| 1623 | 1617 | struct scatterlist *dst, unsigned int size, unsigned int *nbytesp) |
|---|
| 1624 | 1618 | { |
|---|
| 1625 | 1619 | unsigned int srest = *srestp, nbytes = *nbytesp, copy; |
|---|
| .. | .. |
|---|
| 1669 | 1663 | BUG_ON(dev->started < 0); |
|---|
| 1670 | 1664 | } |
|---|
| 1671 | 1665 | |
|---|
| 1672 | | -static void hifn_process_ready(struct ablkcipher_request *req, int error) |
|---|
| 1666 | +static void hifn_process_ready(struct skcipher_request *req, int error) |
|---|
| 1673 | 1667 | { |
|---|
| 1674 | | - struct hifn_request_context *rctx = ablkcipher_request_ctx(req); |
|---|
| 1668 | + struct hifn_request_context *rctx = skcipher_request_ctx(req); |
|---|
| 1675 | 1669 | |
|---|
| 1676 | 1670 | if (rctx->walk.flags & ASYNC_FLAGS_MISALIGNED) { |
|---|
| 1677 | | - unsigned int nbytes = req->nbytes; |
|---|
| 1671 | + unsigned int nbytes = req->cryptlen; |
|---|
| 1678 | 1672 | int idx = 0, err; |
|---|
| 1679 | 1673 | struct scatterlist *dst, *t; |
|---|
| 1680 | 1674 | void *saddr; |
|---|
| .. | .. |
|---|
| 1697 | 1691 | |
|---|
| 1698 | 1692 | saddr = kmap_atomic(sg_page(t)); |
|---|
| 1699 | 1693 | |
|---|
| 1700 | | - err = ablkcipher_get(saddr, &t->length, t->offset, |
|---|
| 1694 | + err = skcipher_get(saddr, &t->length, t->offset, |
|---|
| 1701 | 1695 | dst, nbytes, &nbytes); |
|---|
| 1702 | 1696 | if (err < 0) { |
|---|
| 1703 | 1697 | kunmap_atomic(saddr); |
|---|
| .. | .. |
|---|
| 1919 | 1913 | { |
|---|
| 1920 | 1914 | unsigned long flags; |
|---|
| 1921 | 1915 | struct crypto_async_request *async_req; |
|---|
| 1922 | | - struct ablkcipher_request *req; |
|---|
| 1916 | + struct skcipher_request *req; |
|---|
| 1923 | 1917 | struct hifn_dma *dma = (struct hifn_dma *)dev->desc_virt; |
|---|
| 1924 | 1918 | int i; |
|---|
| 1925 | 1919 | |
|---|
| .. | .. |
|---|
| 1935 | 1929 | |
|---|
| 1936 | 1930 | spin_lock_irqsave(&dev->lock, flags); |
|---|
| 1937 | 1931 | while ((async_req = crypto_dequeue_request(&dev->queue))) { |
|---|
| 1938 | | - req = ablkcipher_request_cast(async_req); |
|---|
| 1932 | + req = skcipher_request_cast(async_req); |
|---|
| 1939 | 1933 | spin_unlock_irqrestore(&dev->lock, flags); |
|---|
| 1940 | 1934 | |
|---|
| 1941 | 1935 | hifn_process_ready(req, -ENODEV); |
|---|
| .. | .. |
|---|
| 1945 | 1939 | spin_unlock_irqrestore(&dev->lock, flags); |
|---|
| 1946 | 1940 | } |
|---|
| 1947 | 1941 | |
|---|
| 1948 | | -static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
|---|
| 1942 | +static int hifn_setkey(struct crypto_skcipher *cipher, const u8 *key, |
|---|
| 1949 | 1943 | unsigned int len) |
|---|
| 1950 | 1944 | { |
|---|
| 1951 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
|---|
| 1952 | | - struct hifn_context *ctx = crypto_tfm_ctx(tfm); |
|---|
| 1945 | + struct hifn_context *ctx = crypto_skcipher_ctx(cipher); |
|---|
| 1953 | 1946 | struct hifn_device *dev = ctx->dev; |
|---|
| 1947 | + int err; |
|---|
| 1954 | 1948 | |
|---|
| 1955 | | - if (len > HIFN_MAX_CRYPT_KEY_LENGTH) { |
|---|
| 1956 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
|---|
| 1957 | | - return -1; |
|---|
| 1958 | | - } |
|---|
| 1959 | | - |
|---|
| 1960 | | - if (len == HIFN_DES_KEY_LENGTH) { |
|---|
| 1961 | | - u32 tmp[DES_EXPKEY_WORDS]; |
|---|
| 1962 | | - int ret = des_ekey(tmp, key); |
|---|
| 1963 | | - |
|---|
| 1964 | | - if (unlikely(ret == 0) && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) { |
|---|
| 1965 | | - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; |
|---|
| 1966 | | - return -EINVAL; |
|---|
| 1967 | | - } |
|---|
| 1968 | | - } |
|---|
| 1949 | + err = verify_skcipher_des_key(cipher, key); |
|---|
| 1950 | + if (err) |
|---|
| 1951 | + return err; |
|---|
| 1969 | 1952 | |
|---|
| 1970 | 1953 | dev->flags &= ~HIFN_FLAG_OLD_KEY; |
|---|
| 1971 | 1954 | |
|---|
| .. | .. |
|---|
| 1975 | 1958 | return 0; |
|---|
| 1976 | 1959 | } |
|---|
| 1977 | 1960 | |
|---|
| 1978 | | -static int hifn_handle_req(struct ablkcipher_request *req) |
|---|
| 1961 | +static int hifn_des3_setkey(struct crypto_skcipher *cipher, const u8 *key, |
|---|
| 1962 | + unsigned int len) |
|---|
| 1963 | +{ |
|---|
| 1964 | + struct hifn_context *ctx = crypto_skcipher_ctx(cipher); |
|---|
| 1965 | + struct hifn_device *dev = ctx->dev; |
|---|
| 1966 | + int err; |
|---|
| 1967 | + |
|---|
| 1968 | + err = verify_skcipher_des3_key(cipher, key); |
|---|
| 1969 | + if (err) |
|---|
| 1970 | + return err; |
|---|
| 1971 | + |
|---|
| 1972 | + dev->flags &= ~HIFN_FLAG_OLD_KEY; |
|---|
| 1973 | + |
|---|
| 1974 | + memcpy(ctx->key, key, len); |
|---|
| 1975 | + ctx->keysize = len; |
|---|
| 1976 | + |
|---|
| 1977 | + return 0; |
|---|
| 1978 | +} |
|---|
| 1979 | + |
|---|
| 1980 | +static int hifn_handle_req(struct skcipher_request *req) |
|---|
| 1979 | 1981 | { |
|---|
| 1980 | 1982 | struct hifn_context *ctx = crypto_tfm_ctx(req->base.tfm); |
|---|
| 1981 | 1983 | struct hifn_device *dev = ctx->dev; |
|---|
| 1982 | 1984 | int err = -EAGAIN; |
|---|
| 1983 | 1985 | |
|---|
| 1984 | | - if (dev->started + DIV_ROUND_UP(req->nbytes, PAGE_SIZE) <= HIFN_QUEUE_LENGTH) |
|---|
| 1986 | + if (dev->started + DIV_ROUND_UP(req->cryptlen, PAGE_SIZE) <= HIFN_QUEUE_LENGTH) |
|---|
| 1985 | 1987 | err = hifn_setup_session(req); |
|---|
| 1986 | 1988 | |
|---|
| 1987 | 1989 | if (err == -EAGAIN) { |
|---|
| 1988 | 1990 | unsigned long flags; |
|---|
| 1989 | 1991 | |
|---|
| 1990 | 1992 | spin_lock_irqsave(&dev->lock, flags); |
|---|
| 1991 | | - err = ablkcipher_enqueue_request(&dev->queue, req); |
|---|
| 1993 | + err = crypto_enqueue_request(&dev->queue, &req->base); |
|---|
| 1992 | 1994 | spin_unlock_irqrestore(&dev->lock, flags); |
|---|
| 1993 | 1995 | } |
|---|
| 1994 | 1996 | |
|---|
| 1995 | 1997 | return err; |
|---|
| 1996 | 1998 | } |
|---|
| 1997 | 1999 | |
|---|
| 1998 | | -static int hifn_setup_crypto_req(struct ablkcipher_request *req, u8 op, |
|---|
| 2000 | +static int hifn_setup_crypto_req(struct skcipher_request *req, u8 op, |
|---|
| 1999 | 2001 | u8 type, u8 mode) |
|---|
| 2000 | 2002 | { |
|---|
| 2001 | 2003 | struct hifn_context *ctx = crypto_tfm_ctx(req->base.tfm); |
|---|
| 2002 | | - struct hifn_request_context *rctx = ablkcipher_request_ctx(req); |
|---|
| 2004 | + struct hifn_request_context *rctx = skcipher_request_ctx(req); |
|---|
| 2003 | 2005 | unsigned ivsize; |
|---|
| 2004 | 2006 | |
|---|
| 2005 | | - ivsize = crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(req)); |
|---|
| 2007 | + ivsize = crypto_skcipher_ivsize(crypto_skcipher_reqtfm(req)); |
|---|
| 2006 | 2008 | |
|---|
| 2007 | | - if (req->info && mode != ACRYPTO_MODE_ECB) { |
|---|
| 2009 | + if (req->iv && mode != ACRYPTO_MODE_ECB) { |
|---|
| 2008 | 2010 | if (type == ACRYPTO_TYPE_AES_128) |
|---|
| 2009 | 2011 | ivsize = HIFN_AES_IV_LENGTH; |
|---|
| 2010 | 2012 | else if (type == ACRYPTO_TYPE_DES) |
|---|
| .. | .. |
|---|
| 2023 | 2025 | rctx->op = op; |
|---|
| 2024 | 2026 | rctx->mode = mode; |
|---|
| 2025 | 2027 | rctx->type = type; |
|---|
| 2026 | | - rctx->iv = req->info; |
|---|
| 2028 | + rctx->iv = req->iv; |
|---|
| 2027 | 2029 | rctx->ivsize = ivsize; |
|---|
| 2028 | 2030 | |
|---|
| 2029 | 2031 | /* |
|---|
| .. | .. |
|---|
| 2038 | 2040 | static int hifn_process_queue(struct hifn_device *dev) |
|---|
| 2039 | 2041 | { |
|---|
| 2040 | 2042 | struct crypto_async_request *async_req, *backlog; |
|---|
| 2041 | | - struct ablkcipher_request *req; |
|---|
| 2043 | + struct skcipher_request *req; |
|---|
| 2042 | 2044 | unsigned long flags; |
|---|
| 2043 | 2045 | int err = 0; |
|---|
| 2044 | 2046 | |
|---|
| .. | .. |
|---|
| 2054 | 2056 | if (backlog) |
|---|
| 2055 | 2057 | backlog->complete(backlog, -EINPROGRESS); |
|---|
| 2056 | 2058 | |
|---|
| 2057 | | - req = ablkcipher_request_cast(async_req); |
|---|
| 2059 | + req = skcipher_request_cast(async_req); |
|---|
| 2058 | 2060 | |
|---|
| 2059 | 2061 | err = hifn_handle_req(req); |
|---|
| 2060 | 2062 | if (err) |
|---|
| .. | .. |
|---|
| 2064 | 2066 | return err; |
|---|
| 2065 | 2067 | } |
|---|
| 2066 | 2068 | |
|---|
| 2067 | | -static int hifn_setup_crypto(struct ablkcipher_request *req, u8 op, |
|---|
| 2069 | +static int hifn_setup_crypto(struct skcipher_request *req, u8 op, |
|---|
| 2068 | 2070 | u8 type, u8 mode) |
|---|
| 2069 | 2071 | { |
|---|
| 2070 | 2072 | int err; |
|---|
| .. | .. |
|---|
| 2084 | 2086 | /* |
|---|
| 2085 | 2087 | * AES ecryption functions. |
|---|
| 2086 | 2088 | */ |
|---|
| 2087 | | -static inline int hifn_encrypt_aes_ecb(struct ablkcipher_request *req) |
|---|
| 2089 | +static inline int hifn_encrypt_aes_ecb(struct skcipher_request *req) |
|---|
| 2088 | 2090 | { |
|---|
| 2089 | 2091 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2090 | 2092 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_ECB); |
|---|
| 2091 | 2093 | } |
|---|
| 2092 | | -static inline int hifn_encrypt_aes_cbc(struct ablkcipher_request *req) |
|---|
| 2094 | +static inline int hifn_encrypt_aes_cbc(struct skcipher_request *req) |
|---|
| 2093 | 2095 | { |
|---|
| 2094 | 2096 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2095 | 2097 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_CBC); |
|---|
| 2096 | 2098 | } |
|---|
| 2097 | | -static inline int hifn_encrypt_aes_cfb(struct ablkcipher_request *req) |
|---|
| 2099 | +static inline int hifn_encrypt_aes_cfb(struct skcipher_request *req) |
|---|
| 2098 | 2100 | { |
|---|
| 2099 | 2101 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2100 | 2102 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_CFB); |
|---|
| 2101 | 2103 | } |
|---|
| 2102 | | -static inline int hifn_encrypt_aes_ofb(struct ablkcipher_request *req) |
|---|
| 2104 | +static inline int hifn_encrypt_aes_ofb(struct skcipher_request *req) |
|---|
| 2103 | 2105 | { |
|---|
| 2104 | 2106 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2105 | 2107 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_OFB); |
|---|
| .. | .. |
|---|
| 2108 | 2110 | /* |
|---|
| 2109 | 2111 | * AES decryption functions. |
|---|
| 2110 | 2112 | */ |
|---|
| 2111 | | -static inline int hifn_decrypt_aes_ecb(struct ablkcipher_request *req) |
|---|
| 2113 | +static inline int hifn_decrypt_aes_ecb(struct skcipher_request *req) |
|---|
| 2112 | 2114 | { |
|---|
| 2113 | 2115 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2114 | 2116 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_ECB); |
|---|
| 2115 | 2117 | } |
|---|
| 2116 | | -static inline int hifn_decrypt_aes_cbc(struct ablkcipher_request *req) |
|---|
| 2118 | +static inline int hifn_decrypt_aes_cbc(struct skcipher_request *req) |
|---|
| 2117 | 2119 | { |
|---|
| 2118 | 2120 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2119 | 2121 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_CBC); |
|---|
| 2120 | 2122 | } |
|---|
| 2121 | | -static inline int hifn_decrypt_aes_cfb(struct ablkcipher_request *req) |
|---|
| 2123 | +static inline int hifn_decrypt_aes_cfb(struct skcipher_request *req) |
|---|
| 2122 | 2124 | { |
|---|
| 2123 | 2125 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2124 | 2126 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_CFB); |
|---|
| 2125 | 2127 | } |
|---|
| 2126 | | -static inline int hifn_decrypt_aes_ofb(struct ablkcipher_request *req) |
|---|
| 2128 | +static inline int hifn_decrypt_aes_ofb(struct skcipher_request *req) |
|---|
| 2127 | 2129 | { |
|---|
| 2128 | 2130 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2129 | 2131 | ACRYPTO_TYPE_AES_128, ACRYPTO_MODE_OFB); |
|---|
| .. | .. |
|---|
| 2132 | 2134 | /* |
|---|
| 2133 | 2135 | * DES ecryption functions. |
|---|
| 2134 | 2136 | */ |
|---|
| 2135 | | -static inline int hifn_encrypt_des_ecb(struct ablkcipher_request *req) |
|---|
| 2137 | +static inline int hifn_encrypt_des_ecb(struct skcipher_request *req) |
|---|
| 2136 | 2138 | { |
|---|
| 2137 | 2139 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2138 | 2140 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_ECB); |
|---|
| 2139 | 2141 | } |
|---|
| 2140 | | -static inline int hifn_encrypt_des_cbc(struct ablkcipher_request *req) |
|---|
| 2142 | +static inline int hifn_encrypt_des_cbc(struct skcipher_request *req) |
|---|
| 2141 | 2143 | { |
|---|
| 2142 | 2144 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2143 | 2145 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_CBC); |
|---|
| 2144 | 2146 | } |
|---|
| 2145 | | -static inline int hifn_encrypt_des_cfb(struct ablkcipher_request *req) |
|---|
| 2147 | +static inline int hifn_encrypt_des_cfb(struct skcipher_request *req) |
|---|
| 2146 | 2148 | { |
|---|
| 2147 | 2149 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2148 | 2150 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_CFB); |
|---|
| 2149 | 2151 | } |
|---|
| 2150 | | -static inline int hifn_encrypt_des_ofb(struct ablkcipher_request *req) |
|---|
| 2152 | +static inline int hifn_encrypt_des_ofb(struct skcipher_request *req) |
|---|
| 2151 | 2153 | { |
|---|
| 2152 | 2154 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2153 | 2155 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_OFB); |
|---|
| .. | .. |
|---|
| 2156 | 2158 | /* |
|---|
| 2157 | 2159 | * DES decryption functions. |
|---|
| 2158 | 2160 | */ |
|---|
| 2159 | | -static inline int hifn_decrypt_des_ecb(struct ablkcipher_request *req) |
|---|
| 2161 | +static inline int hifn_decrypt_des_ecb(struct skcipher_request *req) |
|---|
| 2160 | 2162 | { |
|---|
| 2161 | 2163 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2162 | 2164 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_ECB); |
|---|
| 2163 | 2165 | } |
|---|
| 2164 | | -static inline int hifn_decrypt_des_cbc(struct ablkcipher_request *req) |
|---|
| 2166 | +static inline int hifn_decrypt_des_cbc(struct skcipher_request *req) |
|---|
| 2165 | 2167 | { |
|---|
| 2166 | 2168 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2167 | 2169 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_CBC); |
|---|
| 2168 | 2170 | } |
|---|
| 2169 | | -static inline int hifn_decrypt_des_cfb(struct ablkcipher_request *req) |
|---|
| 2171 | +static inline int hifn_decrypt_des_cfb(struct skcipher_request *req) |
|---|
| 2170 | 2172 | { |
|---|
| 2171 | 2173 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2172 | 2174 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_CFB); |
|---|
| 2173 | 2175 | } |
|---|
| 2174 | | -static inline int hifn_decrypt_des_ofb(struct ablkcipher_request *req) |
|---|
| 2176 | +static inline int hifn_decrypt_des_ofb(struct skcipher_request *req) |
|---|
| 2175 | 2177 | { |
|---|
| 2176 | 2178 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2177 | 2179 | ACRYPTO_TYPE_DES, ACRYPTO_MODE_OFB); |
|---|
| .. | .. |
|---|
| 2180 | 2182 | /* |
|---|
| 2181 | 2183 | * 3DES ecryption functions. |
|---|
| 2182 | 2184 | */ |
|---|
| 2183 | | -static inline int hifn_encrypt_3des_ecb(struct ablkcipher_request *req) |
|---|
| 2185 | +static inline int hifn_encrypt_3des_ecb(struct skcipher_request *req) |
|---|
| 2184 | 2186 | { |
|---|
| 2185 | 2187 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2186 | 2188 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_ECB); |
|---|
| 2187 | 2189 | } |
|---|
| 2188 | | -static inline int hifn_encrypt_3des_cbc(struct ablkcipher_request *req) |
|---|
| 2190 | +static inline int hifn_encrypt_3des_cbc(struct skcipher_request *req) |
|---|
| 2189 | 2191 | { |
|---|
| 2190 | 2192 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2191 | 2193 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_CBC); |
|---|
| 2192 | 2194 | } |
|---|
| 2193 | | -static inline int hifn_encrypt_3des_cfb(struct ablkcipher_request *req) |
|---|
| 2195 | +static inline int hifn_encrypt_3des_cfb(struct skcipher_request *req) |
|---|
| 2194 | 2196 | { |
|---|
| 2195 | 2197 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2196 | 2198 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_CFB); |
|---|
| 2197 | 2199 | } |
|---|
| 2198 | | -static inline int hifn_encrypt_3des_ofb(struct ablkcipher_request *req) |
|---|
| 2200 | +static inline int hifn_encrypt_3des_ofb(struct skcipher_request *req) |
|---|
| 2199 | 2201 | { |
|---|
| 2200 | 2202 | return hifn_setup_crypto(req, ACRYPTO_OP_ENCRYPT, |
|---|
| 2201 | 2203 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_OFB); |
|---|
| 2202 | 2204 | } |
|---|
| 2203 | 2205 | |
|---|
| 2204 | 2206 | /* 3DES decryption functions. */ |
|---|
| 2205 | | -static inline int hifn_decrypt_3des_ecb(struct ablkcipher_request *req) |
|---|
| 2207 | +static inline int hifn_decrypt_3des_ecb(struct skcipher_request *req) |
|---|
| 2206 | 2208 | { |
|---|
| 2207 | 2209 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2208 | 2210 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_ECB); |
|---|
| 2209 | 2211 | } |
|---|
| 2210 | | -static inline int hifn_decrypt_3des_cbc(struct ablkcipher_request *req) |
|---|
| 2212 | +static inline int hifn_decrypt_3des_cbc(struct skcipher_request *req) |
|---|
| 2211 | 2213 | { |
|---|
| 2212 | 2214 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2213 | 2215 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_CBC); |
|---|
| 2214 | 2216 | } |
|---|
| 2215 | | -static inline int hifn_decrypt_3des_cfb(struct ablkcipher_request *req) |
|---|
| 2217 | +static inline int hifn_decrypt_3des_cfb(struct skcipher_request *req) |
|---|
| 2216 | 2218 | { |
|---|
| 2217 | 2219 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2218 | 2220 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_CFB); |
|---|
| 2219 | 2221 | } |
|---|
| 2220 | | -static inline int hifn_decrypt_3des_ofb(struct ablkcipher_request *req) |
|---|
| 2222 | +static inline int hifn_decrypt_3des_ofb(struct skcipher_request *req) |
|---|
| 2221 | 2223 | { |
|---|
| 2222 | 2224 | return hifn_setup_crypto(req, ACRYPTO_OP_DECRYPT, |
|---|
| 2223 | 2225 | ACRYPTO_TYPE_3DES, ACRYPTO_MODE_OFB); |
|---|
| .. | .. |
|---|
| 2227 | 2229 | char name[CRYPTO_MAX_ALG_NAME]; |
|---|
| 2228 | 2230 | char drv_name[CRYPTO_MAX_ALG_NAME]; |
|---|
| 2229 | 2231 | unsigned int bsize; |
|---|
| 2230 | | - struct ablkcipher_alg ablkcipher; |
|---|
| 2232 | + struct skcipher_alg skcipher; |
|---|
| 2231 | 2233 | }; |
|---|
| 2232 | 2234 | |
|---|
| 2233 | | -static struct hifn_alg_template hifn_alg_templates[] = { |
|---|
| 2235 | +static const struct hifn_alg_template hifn_alg_templates[] = { |
|---|
| 2234 | 2236 | /* |
|---|
| 2235 | 2237 | * 3DES ECB, CBC, CFB and OFB modes. |
|---|
| 2236 | 2238 | */ |
|---|
| 2237 | 2239 | { |
|---|
| 2238 | 2240 | .name = "cfb(des3_ede)", .drv_name = "cfb-3des", .bsize = 8, |
|---|
| 2239 | | - .ablkcipher = { |
|---|
| 2241 | + .skcipher = { |
|---|
| 2240 | 2242 | .min_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2241 | 2243 | .max_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2242 | | - .setkey = hifn_setkey, |
|---|
| 2244 | + .setkey = hifn_des3_setkey, |
|---|
| 2243 | 2245 | .encrypt = hifn_encrypt_3des_cfb, |
|---|
| 2244 | 2246 | .decrypt = hifn_decrypt_3des_cfb, |
|---|
| 2245 | 2247 | }, |
|---|
| 2246 | 2248 | }, |
|---|
| 2247 | 2249 | { |
|---|
| 2248 | 2250 | .name = "ofb(des3_ede)", .drv_name = "ofb-3des", .bsize = 8, |
|---|
| 2249 | | - .ablkcipher = { |
|---|
| 2251 | + .skcipher = { |
|---|
| 2250 | 2252 | .min_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2251 | 2253 | .max_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2252 | | - .setkey = hifn_setkey, |
|---|
| 2254 | + .setkey = hifn_des3_setkey, |
|---|
| 2253 | 2255 | .encrypt = hifn_encrypt_3des_ofb, |
|---|
| 2254 | 2256 | .decrypt = hifn_decrypt_3des_ofb, |
|---|
| 2255 | 2257 | }, |
|---|
| 2256 | 2258 | }, |
|---|
| 2257 | 2259 | { |
|---|
| 2258 | 2260 | .name = "cbc(des3_ede)", .drv_name = "cbc-3des", .bsize = 8, |
|---|
| 2259 | | - .ablkcipher = { |
|---|
| 2261 | + .skcipher = { |
|---|
| 2260 | 2262 | .ivsize = HIFN_IV_LENGTH, |
|---|
| 2261 | 2263 | .min_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2262 | 2264 | .max_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2263 | | - .setkey = hifn_setkey, |
|---|
| 2265 | + .setkey = hifn_des3_setkey, |
|---|
| 2264 | 2266 | .encrypt = hifn_encrypt_3des_cbc, |
|---|
| 2265 | 2267 | .decrypt = hifn_decrypt_3des_cbc, |
|---|
| 2266 | 2268 | }, |
|---|
| 2267 | 2269 | }, |
|---|
| 2268 | 2270 | { |
|---|
| 2269 | 2271 | .name = "ecb(des3_ede)", .drv_name = "ecb-3des", .bsize = 8, |
|---|
| 2270 | | - .ablkcipher = { |
|---|
| 2272 | + .skcipher = { |
|---|
| 2271 | 2273 | .min_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2272 | 2274 | .max_keysize = HIFN_3DES_KEY_LENGTH, |
|---|
| 2273 | | - .setkey = hifn_setkey, |
|---|
| 2275 | + .setkey = hifn_des3_setkey, |
|---|
| 2274 | 2276 | .encrypt = hifn_encrypt_3des_ecb, |
|---|
| 2275 | 2277 | .decrypt = hifn_decrypt_3des_ecb, |
|---|
| 2276 | 2278 | }, |
|---|
| .. | .. |
|---|
| 2281 | 2283 | */ |
|---|
| 2282 | 2284 | { |
|---|
| 2283 | 2285 | .name = "cfb(des)", .drv_name = "cfb-des", .bsize = 8, |
|---|
| 2284 | | - .ablkcipher = { |
|---|
| 2286 | + .skcipher = { |
|---|
| 2285 | 2287 | .min_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2286 | 2288 | .max_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2287 | 2289 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2291 | 2293 | }, |
|---|
| 2292 | 2294 | { |
|---|
| 2293 | 2295 | .name = "ofb(des)", .drv_name = "ofb-des", .bsize = 8, |
|---|
| 2294 | | - .ablkcipher = { |
|---|
| 2296 | + .skcipher = { |
|---|
| 2295 | 2297 | .min_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2296 | 2298 | .max_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2297 | 2299 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2301 | 2303 | }, |
|---|
| 2302 | 2304 | { |
|---|
| 2303 | 2305 | .name = "cbc(des)", .drv_name = "cbc-des", .bsize = 8, |
|---|
| 2304 | | - .ablkcipher = { |
|---|
| 2306 | + .skcipher = { |
|---|
| 2305 | 2307 | .ivsize = HIFN_IV_LENGTH, |
|---|
| 2306 | 2308 | .min_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2307 | 2309 | .max_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| .. | .. |
|---|
| 2312 | 2314 | }, |
|---|
| 2313 | 2315 | { |
|---|
| 2314 | 2316 | .name = "ecb(des)", .drv_name = "ecb-des", .bsize = 8, |
|---|
| 2315 | | - .ablkcipher = { |
|---|
| 2317 | + .skcipher = { |
|---|
| 2316 | 2318 | .min_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2317 | 2319 | .max_keysize = HIFN_DES_KEY_LENGTH, |
|---|
| 2318 | 2320 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2326 | 2328 | */ |
|---|
| 2327 | 2329 | { |
|---|
| 2328 | 2330 | .name = "ecb(aes)", .drv_name = "ecb-aes", .bsize = 16, |
|---|
| 2329 | | - .ablkcipher = { |
|---|
| 2331 | + .skcipher = { |
|---|
| 2330 | 2332 | .min_keysize = AES_MIN_KEY_SIZE, |
|---|
| 2331 | 2333 | .max_keysize = AES_MAX_KEY_SIZE, |
|---|
| 2332 | 2334 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2336 | 2338 | }, |
|---|
| 2337 | 2339 | { |
|---|
| 2338 | 2340 | .name = "cbc(aes)", .drv_name = "cbc-aes", .bsize = 16, |
|---|
| 2339 | | - .ablkcipher = { |
|---|
| 2341 | + .skcipher = { |
|---|
| 2340 | 2342 | .ivsize = HIFN_AES_IV_LENGTH, |
|---|
| 2341 | 2343 | .min_keysize = AES_MIN_KEY_SIZE, |
|---|
| 2342 | 2344 | .max_keysize = AES_MAX_KEY_SIZE, |
|---|
| .. | .. |
|---|
| 2347 | 2349 | }, |
|---|
| 2348 | 2350 | { |
|---|
| 2349 | 2351 | .name = "cfb(aes)", .drv_name = "cfb-aes", .bsize = 16, |
|---|
| 2350 | | - .ablkcipher = { |
|---|
| 2352 | + .skcipher = { |
|---|
| 2351 | 2353 | .min_keysize = AES_MIN_KEY_SIZE, |
|---|
| 2352 | 2354 | .max_keysize = AES_MAX_KEY_SIZE, |
|---|
| 2353 | 2355 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2357 | 2359 | }, |
|---|
| 2358 | 2360 | { |
|---|
| 2359 | 2361 | .name = "ofb(aes)", .drv_name = "ofb-aes", .bsize = 16, |
|---|
| 2360 | | - .ablkcipher = { |
|---|
| 2362 | + .skcipher = { |
|---|
| 2361 | 2363 | .min_keysize = AES_MIN_KEY_SIZE, |
|---|
| 2362 | 2364 | .max_keysize = AES_MAX_KEY_SIZE, |
|---|
| 2363 | 2365 | .setkey = hifn_setkey, |
|---|
| .. | .. |
|---|
| 2367 | 2369 | }, |
|---|
| 2368 | 2370 | }; |
|---|
| 2369 | 2371 | |
|---|
| 2370 | | -static int hifn_cra_init(struct crypto_tfm *tfm) |
|---|
| 2372 | +static int hifn_init_tfm(struct crypto_skcipher *tfm) |
|---|
| 2371 | 2373 | { |
|---|
| 2372 | | - struct crypto_alg *alg = tfm->__crt_alg; |
|---|
| 2374 | + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); |
|---|
| 2373 | 2375 | struct hifn_crypto_alg *ha = crypto_alg_to_hifn(alg); |
|---|
| 2374 | | - struct hifn_context *ctx = crypto_tfm_ctx(tfm); |
|---|
| 2376 | + struct hifn_context *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 2375 | 2377 | |
|---|
| 2376 | 2378 | ctx->dev = ha->dev; |
|---|
| 2377 | | - tfm->crt_ablkcipher.reqsize = sizeof(struct hifn_request_context); |
|---|
| 2379 | + crypto_skcipher_set_reqsize(tfm, sizeof(struct hifn_request_context)); |
|---|
| 2380 | + |
|---|
| 2378 | 2381 | return 0; |
|---|
| 2379 | 2382 | } |
|---|
| 2380 | 2383 | |
|---|
| 2381 | | -static int hifn_alg_alloc(struct hifn_device *dev, struct hifn_alg_template *t) |
|---|
| 2384 | +static int hifn_alg_alloc(struct hifn_device *dev, const struct hifn_alg_template *t) |
|---|
| 2382 | 2385 | { |
|---|
| 2383 | 2386 | struct hifn_crypto_alg *alg; |
|---|
| 2384 | 2387 | int err; |
|---|
| .. | .. |
|---|
| 2387 | 2390 | if (!alg) |
|---|
| 2388 | 2391 | return -ENOMEM; |
|---|
| 2389 | 2392 | |
|---|
| 2390 | | - snprintf(alg->alg.cra_name, CRYPTO_MAX_ALG_NAME, "%s", t->name); |
|---|
| 2391 | | - snprintf(alg->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s-%s", |
|---|
| 2393 | + alg->alg = t->skcipher; |
|---|
| 2394 | + alg->alg.init = hifn_init_tfm; |
|---|
| 2395 | + |
|---|
| 2396 | + snprintf(alg->alg.base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", t->name); |
|---|
| 2397 | + snprintf(alg->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s-%s", |
|---|
| 2392 | 2398 | t->drv_name, dev->name); |
|---|
| 2393 | 2399 | |
|---|
| 2394 | | - alg->alg.cra_priority = 300; |
|---|
| 2395 | | - alg->alg.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
|---|
| 2396 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC; |
|---|
| 2397 | | - alg->alg.cra_blocksize = t->bsize; |
|---|
| 2398 | | - alg->alg.cra_ctxsize = sizeof(struct hifn_context); |
|---|
| 2399 | | - alg->alg.cra_alignmask = 0; |
|---|
| 2400 | | - alg->alg.cra_type = &crypto_ablkcipher_type; |
|---|
| 2401 | | - alg->alg.cra_module = THIS_MODULE; |
|---|
| 2402 | | - alg->alg.cra_u.ablkcipher = t->ablkcipher; |
|---|
| 2403 | | - alg->alg.cra_init = hifn_cra_init; |
|---|
| 2400 | + alg->alg.base.cra_priority = 300; |
|---|
| 2401 | + alg->alg.base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC; |
|---|
| 2402 | + alg->alg.base.cra_blocksize = t->bsize; |
|---|
| 2403 | + alg->alg.base.cra_ctxsize = sizeof(struct hifn_context); |
|---|
| 2404 | + alg->alg.base.cra_alignmask = 0; |
|---|
| 2405 | + alg->alg.base.cra_module = THIS_MODULE; |
|---|
| 2404 | 2406 | |
|---|
| 2405 | 2407 | alg->dev = dev; |
|---|
| 2406 | 2408 | |
|---|
| 2407 | 2409 | list_add_tail(&alg->entry, &dev->alg_list); |
|---|
| 2408 | 2410 | |
|---|
| 2409 | | - err = crypto_register_alg(&alg->alg); |
|---|
| 2411 | + err = crypto_register_skcipher(&alg->alg); |
|---|
| 2410 | 2412 | if (err) { |
|---|
| 2411 | 2413 | list_del(&alg->entry); |
|---|
| 2412 | 2414 | kfree(alg); |
|---|
| .. | .. |
|---|
| 2421 | 2423 | |
|---|
| 2422 | 2424 | list_for_each_entry_safe(a, n, &dev->alg_list, entry) { |
|---|
| 2423 | 2425 | list_del(&a->entry); |
|---|
| 2424 | | - crypto_unregister_alg(&a->alg); |
|---|
| 2426 | + crypto_unregister_skcipher(&a->alg); |
|---|
| 2425 | 2427 | kfree(a); |
|---|
| 2426 | 2428 | } |
|---|
| 2427 | 2429 | } |
|---|
| .. | .. |
|---|
| 2470 | 2472 | return err; |
|---|
| 2471 | 2473 | pci_set_master(pdev); |
|---|
| 2472 | 2474 | |
|---|
| 2473 | | - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
|---|
| 2475 | + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 2474 | 2476 | if (err) |
|---|
| 2475 | 2477 | goto err_out_disable_pci_device; |
|---|
| 2476 | 2478 | |
|---|
| .. | .. |
|---|
| 2507 | 2509 | addr = pci_resource_start(pdev, i); |
|---|
| 2508 | 2510 | size = pci_resource_len(pdev, i); |
|---|
| 2509 | 2511 | |
|---|
| 2510 | | - dev->bar[i] = ioremap_nocache(addr, size); |
|---|
| 2512 | + dev->bar[i] = ioremap(addr, size); |
|---|
| 2511 | 2513 | if (!dev->bar[i]) { |
|---|
| 2512 | 2514 | err = -ENOMEM; |
|---|
| 2513 | 2515 | goto err_out_unmap_bars; |
|---|
| 2514 | 2516 | } |
|---|
| 2515 | 2517 | } |
|---|
| 2516 | 2518 | |
|---|
| 2517 | | - dev->desc_virt = pci_zalloc_consistent(pdev, sizeof(struct hifn_dma), |
|---|
| 2518 | | - &dev->desc_dma); |
|---|
| 2519 | + dev->desc_virt = dma_alloc_coherent(&pdev->dev, |
|---|
| 2520 | + sizeof(struct hifn_dma), |
|---|
| 2521 | + &dev->desc_dma, GFP_KERNEL); |
|---|
| 2519 | 2522 | if (!dev->desc_virt) { |
|---|
| 2520 | 2523 | dev_err(&pdev->dev, "Failed to allocate descriptor rings.\n"); |
|---|
| 2521 | 2524 | err = -ENOMEM; |
|---|
| .. | .. |
|---|
| 2572 | 2575 | free_irq(dev->irq, dev); |
|---|
| 2573 | 2576 | tasklet_kill(&dev->tasklet); |
|---|
| 2574 | 2577 | err_out_free_desc: |
|---|
| 2575 | | - pci_free_consistent(pdev, sizeof(struct hifn_dma), |
|---|
| 2576 | | - dev->desc_virt, dev->desc_dma); |
|---|
| 2578 | + dma_free_coherent(&pdev->dev, sizeof(struct hifn_dma), dev->desc_virt, |
|---|
| 2579 | + dev->desc_dma); |
|---|
| 2577 | 2580 | |
|---|
| 2578 | 2581 | err_out_unmap_bars: |
|---|
| 2579 | 2582 | for (i = 0; i < 3; ++i) |
|---|
| .. | .. |
|---|
| 2610 | 2613 | |
|---|
| 2611 | 2614 | hifn_flush(dev); |
|---|
| 2612 | 2615 | |
|---|
| 2613 | | - pci_free_consistent(pdev, sizeof(struct hifn_dma), |
|---|
| 2614 | | - dev->desc_virt, dev->desc_dma); |
|---|
| 2616 | + dma_free_coherent(&pdev->dev, sizeof(struct hifn_dma), |
|---|
| 2617 | + dev->desc_virt, dev->desc_dma); |
|---|
| 2615 | 2618 | for (i = 0; i < 3; ++i) |
|---|
| 2616 | 2619 | if (dev->bar[i]) |
|---|
| 2617 | 2620 | iounmap(dev->bar[i]); |
|---|
| .. | .. |
|---|
| 2641 | 2644 | { |
|---|
| 2642 | 2645 | unsigned int freq; |
|---|
| 2643 | 2646 | int err; |
|---|
| 2644 | | - |
|---|
| 2645 | | - /* HIFN supports only 32-bit addresses */ |
|---|
| 2646 | | - BUILD_BUG_ON(sizeof(dma_addr_t) != 4); |
|---|
| 2647 | 2647 | |
|---|
| 2648 | 2648 | if (strncmp(hifn_pll_ref, "ext", 3) && |
|---|
| 2649 | 2649 | strncmp(hifn_pll_ref, "pci", 3)) { |
|---|