/* * Cryptographic API for the NX-842 hardware compression. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Copyright (C) IBM Corporation, 2011-2015 * * Designer of the Power data compression engine: * Bulent Abali * * Original Authors: Robert Jennings * Seth Jennings * * Rewrite: Dan Streetman * * This is an interface to the NX-842 compression hardware in PowerPC * processors. Most of the complexity of this drvier is due to the fact that * the NX-842 compression hardware requires the input and output data buffers * to be specifically aligned, to be a specific multiple in length, and within * specific minimum and maximum lengths. Those restrictions, provided by the * nx-842 driver via nx842_constraints, mean this driver must use bounce * buffers and headers to correct misaligned in or out buffers, and to split * input buffers that are too large. * * This driver will fall back to software decompression if the hardware * decompression fails, so this driver's decompression should never fail as * long as the provided compressed buffer is valid. Any compressed buffer * created by this driver will have a header (except ones where the input * perfectly matches the constraints); so users of this driver cannot simply * pass a compressed buffer created by this driver over to the 842 software * decompression library. Instead, users must use this driver to decompress; * if the hardware fails or is unavailable, the compressed buffer will be * parsed and the header removed, and the raw 842 buffer(s) passed to the 842 * software decompression library. * * This does not fall back to software compression, however, since the caller * of this function is specifically requesting hardware compression; if the * hardware compression fails, the caller can fall back to software * compression, and the raw 842 compressed buffer that the software compressor * creates can be passed to this driver for hardware decompression; any * buffer without our specific header magic is assumed to be a raw 842 buffer * and passed directly to the hardware. Note that the software compression * library will produce a compressed buffer that is incompatible with the * hardware decompressor if the original input buffer length is not a multiple * of 8; if such a compressed buffer is passed to this driver for * decompression, the hardware will reject it and this driver will then pass * it over to the software library for decompression. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include "nx-842.h" /* The first 5 bits of this magic are 0x1f, which is an invalid 842 5-bit * template (see lib/842/842.h), so this magic number will never appear at * the start of a raw 842 compressed buffer. That is important, as any buffer * passed to us without this magic is assumed to be a raw 842 compressed * buffer, and passed directly to the hardware to decompress. */ #define NX842_CRYPTO_MAGIC (0xf842) #define NX842_CRYPTO_HEADER_SIZE(g) \ (sizeof(struct nx842_crypto_header) + \ sizeof(struct nx842_crypto_header_group) * (g)) #define NX842_CRYPTO_HEADER_MAX_SIZE \ NX842_CRYPTO_HEADER_SIZE(NX842_CRYPTO_GROUP_MAX) /* bounce buffer size */ #define BOUNCE_BUFFER_ORDER (2) #define BOUNCE_BUFFER_SIZE \ ((unsigned int)(PAGE_SIZE << BOUNCE_BUFFER_ORDER)) /* try longer on comp because we can fallback to sw decomp if hw is busy */ #define COMP_BUSY_TIMEOUT (250) /* ms */ #define DECOMP_BUSY_TIMEOUT (50) /* ms */ struct nx842_crypto_param { u8 *in; unsigned int iremain; u8 *out; unsigned int oremain; unsigned int ototal; }; static int update_param(struct nx842_crypto_param *p, unsigned int slen, unsigned int dlen) { if (p->iremain < slen) return -EOVERFLOW; if (p->oremain < dlen) return -ENOSPC; p->in += slen; p->iremain -= slen; p->out += dlen; p->oremain -= dlen; p->ototal += dlen; return 0; } int nx842_crypto_init(struct crypto_tfm *tfm, struct nx842_driver *driver) { struct nx842_crypto_ctx *ctx = crypto_tfm_ctx(tfm); spin_lock_init(&ctx->lock); ctx->driver = driver; ctx->wmem = kmalloc(driver->workmem_size, GFP_KERNEL); ctx->sbounce = (u8 *)__get_free_pages(GFP_KER
##############################################################################
# Copyright (c) 2017 Mirantis Inc., Enea AB and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
classes:
  - cluster.baremetal-mcp-pike-odl-ha.infra.config
parameters:
  _param:
    linux_system_codename: xenial
    reclass_data_revision: master
  linux:
    system:
      name: cfg01
      domain: