Skip to content

Commit

Permalink
lib/liquid_crypto: add device ops APIs
Browse files Browse the repository at this point in the history
Add framework and device control ops APIs.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Change-Id: I1a1ab8ee8cb62f02218c337210c70f96ce3654a7
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/147608
Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com>
  • Loading branch information
anoobj authored and jerinjacobk committed Mar 5, 2025
1 parent 1d5e642 commit 15473ec
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/api/doxy-api-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ The public API headers are grouped by topics

- **transport**
- [eth_transport] (@ref dao_eth_trs.h)

- **liquid crypto**
- [liquid crypto] (@ref dao_liquid_crypto.h)
1 change: 1 addition & 0 deletions doc/api/doxy-api.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ INPUT = @TOPDIR@/doxy-api-index.md \
@TOPDIR@/../../lib/common \
@TOPDIR@/../../lib/eth_transport \
@TOPDIR@/../../lib/flow \
@TOPDIR@/../../lib/liquid_crypto \
@TOPDIR@/../../lib/pem \
@TOPDIR@/../../lib/portgroup \
@TOPDIR@/../../lib/featurearc \
Expand Down
170 changes: 170 additions & 0 deletions lib/liquid_crypto/dao_liquid_crypto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/* SPDX-License-Identifier: Marvell-MIT
* Copyright (c) 2025 Marvell.
*/

#ifndef __DAO_LIQUID_CRYPTO_H__
#define __DAO_LIQUID_CRYPTO_H__

/**
* @file dao_liquid_crypto.h
*
* This file contains the API for liquid crypto.
*/

#include <stdbool.h>
#include <stdint.h>

/** The maximum length of the version string. */
#define DAO_CRYPTO_VERSION_LEN 32
/** The maximum number of devices supported by the liquid crypto library. */
#define DAO_CRYPTO_MAX_NB_DEV 1

/**
* The liquid crypto information structure.
*/
struct dao_liquid_crypto_info {
/** The version of the liquid crypto library. */
char version[DAO_CRYPTO_VERSION_LEN];
/** The number of devices supported by the liquid crypto library. */
uint8_t nb_dev;
/** The number of queue pairs supported by the liquid crypto library. */
uint16_t nb_qp[DAO_CRYPTO_MAX_NB_DEV];
};

/**
* The liquid crypto queue pair configuration structure.
*
* This structure is used to configure a liquid crypto queue pair.
*
*/
struct dao_liquid_crypto_qp_conf {
/** Enable out of order delivery. */
bool out_of_order_delivery_en;
/**
* The number of descriptors in the queue pair. For performance benefits, the actual
* number of descriptors would be rounded up to a power of 2.
*/
uint16_t nb_desc;
/** The maximum segment size. */
uint16_t max_seg_size;
};

/**
* Initialize liquid crypto.
*
* This function initializes the liquid crypto library. This API must be called
* before any other liquid crypto API and must be called after calling
* rte_eal_init().
*
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_init(void);

/**
* Cleanup liquid crypto.
*
* This function cleans up the liquid crypto library.
*
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_fini(void);

/**
* Get liquid crypto information.
*
* This function retrieves the liquid crypto information.
*
* @param info [out]
* A pointer to the liquid crypto information structure.
*
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_info_get(struct dao_liquid_crypto_info *info);

/**
* Create a liquid crypto device.
*
* This function creates a liquid crypto device.
*
* @param dev_id
* The device identifier. Value must between 0 and
* ``dao_liquid_crypto_info.nb_dev`` - 1.
* @param nb_qp
* The number of queue pairs.
*
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_dev_create(uint8_t dev_id, uint16_t nb_qp);

/**
* Destroy a liquid crypto device.
*
* This function destroys a liquid crypto device. The device must be stopped
* before it can be destroyed.
*
* @param dev_id
* The device identifier.
*
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_dev_destroy(uint8_t dev_id);

/**
* Configure a liquid crypto queue pair.
*
* This function configures a liquid crypto queue pair. Queue pairs can be
* configured only when the device is stopped.
*
* @param dev_id
* The device identifier. Value must between 0 and
* ``dao_liquid_crypto_info.nb_dev`` - 1.
* @param qp_id
* The queue pair identifier. Value must between 0 and
* ``dao_liquid_crypto_info.nb_qp[dev_id]`` - 1.
* @param conf
* A pointer to the liquid crypto queue pair configuration structure.
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_qp_configure(uint8_t dev_id, uint16_t qp_id,
struct dao_liquid_crypto_qp_conf *conf);

/**
* Start a liquid crypto device.
*
* This function starts a liquid crypto device. The device must be created
* before it can be started.
*
* @param dev_id
* The device identifier.
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_dev_start(uint8_t dev_id);

/**
* Stop a liquid crypto device.
*
* This function stops a liquid crypto device.
*
* @param dev_id
* The device identifier.
* @return
* - On success, 0 is returned.
* - On failure, a negative value is returned indicating the cause
*/
int dao_liquid_crypto_dev_stop(uint8_t dev_id);

#endif /* __DAO_LIQUID_CRYPTO_H__ */
47 changes: 47 additions & 0 deletions lib/liquid_crypto/liquid_crypto_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* SPDX-License-Identifier: Marvell-MIT
* Copyright (c) 2025 Marvell.
*/

#include <string.h>

#include <rte_eal.h>

#include <dao_liquid_crypto.h>
#include <dao_log.h>

static struct dao_liquid_crypto_info liquid_crypto_info;

int
dao_liquid_crypto_init(void)
{
memset(&liquid_crypto_info, 0, sizeof(liquid_crypto_info));

/* Call eth TRS API
* - Get the count of eth devices
*/

/* Save the info here. */

return 0;
}

int
dao_liquid_crypto_fini(void)
{
memset(&liquid_crypto_info, 0, sizeof(liquid_crypto_info));

return 0;
}

int
dao_liquid_crypto_info_get(struct dao_liquid_crypto_info *info)
{
if (info == NULL) {
dao_err("Invalid argument.");
return -EINVAL;
}

memcpy(info, &liquid_crypto_info, sizeof(liquid_crypto_info));

return 0;
}
12 changes: 12 additions & 0 deletions lib/liquid_crypto/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Marvell-MIT
# Copyright (c) 2025 Marvell.

sources = files(
'liquid_crypto_api.c'
)

headers = files(
'dao_liquid_crypto.h',
)

deps += ['common']
1 change: 1 addition & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
libraries = [
'common',
'eth_transport',
'liquid_crypto',
'portgroup',
'vfio',
'pem',
Expand Down

0 comments on commit 15473ec

Please sign in to comment.