Commit e892af6b authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Konrad Sztyber
Browse files

accel/mlx5: Allow to split crypto op by num of blocks



Signed-off-by: default avatarAlexey Marchuk <alexeymar@nvidia.com>
Change-Id: Idfa18001c423ed493cb2a846d99bd5d69808be40
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23115


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent c63da135
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ struct accel_mlx5_dev {
	struct accel_mlx5_crypto_dev_ctx *dev_ctx;
	uint32_t reqs_submitted;
	uint32_t max_reqs;
	uint16_t crypto_split_blocks;
	bool crypto_multi_block;
	/* Pending tasks waiting for requests resources */
	TAILQ_HEAD(, accel_mlx5_task) nomem;
@@ -631,6 +632,11 @@ accel_mlx5_task_init(struct accel_mlx5_task *mlx5_task, struct accel_mlx5_dev *d
	}

	if (dev->crypto_multi_block) {
		if (dev->crypto_split_blocks) {
			mlx5_task->num_reqs = SPDK_CEIL_DIV(mlx5_task->num_blocks, dev->crypto_split_blocks);
			/* Last req may consume less blocks */
			mlx5_task->blocks_per_req = spdk_min(mlx5_task->num_blocks, dev->crypto_split_blocks);
		} else {
			if (task->s.iovcnt > ACCEL_MLX5_MAX_SGE || task->d.iovcnt > ACCEL_MLX5_MAX_SGE) {
				uint32_t max_sge_count = spdk_max(task->s.iovcnt, task->d.iovcnt);

@@ -640,6 +646,7 @@ accel_mlx5_task_init(struct accel_mlx5_task *mlx5_task, struct accel_mlx5_dev *d
				mlx5_task->num_reqs = 1;
				mlx5_task->blocks_per_req = mlx5_task->num_blocks;
			}
		}
	} else {
		mlx5_task->num_reqs = mlx5_task->num_blocks;
		mlx5_task->blocks_per_req = 1;
@@ -972,6 +979,7 @@ accel_mlx5_create_cb(void *io_device, void *ctx_buf)
			goto err_out;
		}
		dev->crypto_multi_block = dev_ctx->crypto_multi_block;
		dev->crypto_split_blocks = dev_ctx->crypto_multi_block ? g_accel_mlx5.attr.crypto_split_blocks : 0;
	}

	ch->poller = SPDK_POLLER_REGISTER(accel_mlx5_poller, ch, 0);
@@ -991,6 +999,7 @@ accel_mlx5_get_default_attr(struct accel_mlx5_attr *attr)
	attr->qp_size = ACCEL_MLX5_QP_SIZE;
	attr->num_requests = ACCEL_MLX5_NUM_REQUESTS;
	attr->allowed_devs = NULL;
	attr->crypto_split_blocks = 0;
}

static void
@@ -1236,7 +1245,10 @@ accel_mlx5_dev_ctx_init(struct accel_mlx5_crypto_dev_ctx *dev_ctx, struct ibv_co

	if (g_accel_mlx5.crypto_supported) {
		dev_ctx->crypto_multi_block = caps->crypto.multi_block_be_tweak;

		if (!dev_ctx->crypto_multi_block && g_accel_mlx5.attr.crypto_split_blocks) {
			SPDK_WARNLOG("\"crypto_split_blocks\" is set but dev %s doesn't support multi block crypto\n",
				     dev->device->name);
		}
		rc = accel_mlx5_crypto_ctx_mkey_pool_create(dev_ctx, g_accel_mlx5.attr.num_requests);
		if (rc) {
			return rc;
@@ -1431,6 +1443,7 @@ accel_mlx5_write_config_json(struct spdk_json_write_ctx *w)
		if (g_accel_mlx5.attr.allowed_devs) {
			spdk_json_write_named_string(w, "allowed_devs", g_accel_mlx5.attr.allowed_devs);
		}
		spdk_json_write_named_uint16(w, "crypto_split_blocks", g_accel_mlx5.attr.crypto_split_blocks);
		spdk_json_write_object_end(w);
		spdk_json_write_object_end(w);
	}
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ struct accel_mlx5_attr {
	uint32_t num_requests;
	/* Comma separated list of allowed device names */
	char *allowed_devs;
	/* Apply crypto operation for each X data blocks. Works only if multiblock crypto operation is supported by HW.
	 * 0 means no limit */
	uint16_t crypto_split_blocks;
};

void accel_mlx5_get_default_attr(struct accel_mlx5_attr *attr);
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ static const struct spdk_json_object_decoder rpc_mlx5_module_decoder[] = {
	{"qp_size", offsetof(struct accel_mlx5_attr, qp_size), spdk_json_decode_uint16, true},
	{"num_requests", offsetof(struct accel_mlx5_attr, num_requests), spdk_json_decode_uint32, true},
	{"allowed_devs", offsetof(struct accel_mlx5_attr, allowed_devs), spdk_json_decode_string, true},
	{"crypto_split_blocks", offsetof(struct accel_mlx5_attr, crypto_split_blocks), spdk_json_decode_uint16, true},
};

static void
+4 −1
Original line number Diff line number Diff line
@@ -5,13 +5,14 @@
from spdk.rpc.helpers import deprecated_alias


def mlx5_scan_accel_module(client, qp_size=None, num_requests=None, allowed_devs=None,):
def mlx5_scan_accel_module(client, qp_size=None, num_requests=None, allowed_devs=None, crypto_split_blocks=None):
    """Enable mlx5 accel module. Scans all mlx5 devices which can perform needed operations

    Args:
        qp_size: Qpair size. (optional)
        num_requests: size of a global requests pool per mlx5 device (optional)
        allowed_devs: Comma separated list of allowed device names, e.g. mlx5_0,mlx5_1
        crypto_split_blocks: Number of data blocks to be processed in 1 crypto UMR. [0-65535], 0 means no limit
    """
    params = {}

@@ -21,4 +22,6 @@ def mlx5_scan_accel_module(client, qp_size=None, num_requests=None, allowed_devs
        params['num_requests'] = num_requests
    if allowed_devs is not None:
        params['allowed_devs'] = allowed_devs
    if crypto_split_blocks is not None:
        params['crypto_split_blocks'] = crypto_split_blocks
    return client.call('mlx5_scan_accel_module', params)
+4 −1
Original line number Diff line number Diff line
@@ -3327,12 +3327,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
        rpc.mlx5.mlx5_scan_accel_module(args.client,
                                        qp_size=args.qp_size,
                                        num_requests=args.num_requests,
                                        allowed_devs=args.allowed_devs)
                                        allowed_devs=args.allowed_devs,
                                        crypto_split_blocks=args.crypto_split_blocks)

    p = subparsers.add_parser('mlx5_scan_accel_module', help='Enable mlx5 accel module.')
    p.add_argument('-q', '--qp-size', type=int, help='QP size')
    p.add_argument('-r', '--num-requests', type=int, help='Size of the shared requests pool')
    p.add_argument('-d', '--allowed-devs', help="Comma separated list of allowed device names, e.g. mlx5_0,mlx5_1")
    p.add_argument('-s', '--crypto-split-blocks', type=int,
                   help="Number of data blocks to be processed in 1 crypto UMR. [0-65535], 0 means no limit")
    p.set_defaults(func=mlx5_scan_accel_module)

    # accel_error
Loading