crypto/ionic: introduce AMD Pensando ionic crypto driver
Subsystems (2)
cover crypto/ionic: introduce AMD Pensando ionic crypto driver
This patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
Andrew Boyer (6):
crypto/ionic: introduce AMD Pensando ionic crypto driver crypto/ionic: add device and admin command handlers common/ionic: add crypto vdev support crypto/ionic: add device object and vdev support crypto/ionic: add datapath and capabilities support crypto/ionic: add documentation and connect to build
MAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 39 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 361 ++++++++ drivers/crypto/ionic/ionic_crypto_caps.c | 55 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 651 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 993 +++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 606 +++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 +++ drivers/crypto/ionic/meson.build | 16 + drivers/crypto/meson.build | 1 + 16 files changed, 3969 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build
Signature · 1 line
2.17.1
PATCH 1/6 crypto/ionic: introduce AMD Pensando ionic crypto driver
Introduce a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
This commit adds the firmware interface definition file.
--- drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++++ 1 file changed, 1021 insertions(+) create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h
drivers/crypto/ionic/ionic_crypto_if.h new file +1021 -0
@@ -0,0 +1,1021 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#ifndef _IONIC_CRYPTO_IF_H_ +#define _IONIC_CRYPTO_IF_H_ + +#define IOCPT_DEV_INFO_SIGNATURE 0x43585660/* 'CRPT' */ +#define IOCPT_DEV_INFO_VERSION 1 +#define IOCPT_IFNAMSIZ 16 + +/** +* enum iocpt_cmd_opcode - Device commands +*/ +enum iocpt_cmd_opcode { +IOCPT_CMD_NOP =0 ,/* D, A */ + +/* Device commands */ +IOCPT_CMD_IDENTIFY =1 ,/* D */ +IOCPT_CMD_RESET =3 ,/* D */ + +/* LIF commands */ +IOCPT_CMD_LIF_IDENTIFY =20 ,/* D */ +IOCPT_CMD_LIF_INIT =21 ,/* D */ +IOCPT_CMD_LIF_RESET =22 ,/* D */ +IOCPT_CMD_LIF_GETATTR =23 ,/* D, A */ +IOCPT_CMD_LIF_SETATTR =24 ,/* D, A */ + +/* Queue commands */ +IOCPT_CMD_Q_IDENTIFY =39 ,/* D, A */ +IOCPT_CMD_Q_INIT =40 ,/* D, A */ +IOCPT_CMD_Q_CONTROL =41 ,/* D, A */ + +/* Session commands */ +IOCPT_CMD_SESS_CONTROL =45 ,/* D, A */ +}; + +/** +* enum iocpt_status_code - Device command return codes +*/ +enum iocpt_status_code { +IOCPT_RC_SUCCESS =0 ,/* Success */ +IOCPT_RC_EVERSION =1 ,/* Incorrect version for request */ +IOCPT_RC_EOPCODE =2 ,/* Invalid cmd opcode */ +IOCPT_RC_EIO =3 ,/* I/O error */ +IOCPT_RC_EPERM =4 ,/* Permission denied */ +IOCPT_RC_EQID =5 ,/* Bad qid */ +IOCPT_RC_EQTYPE =6 ,/* Bad qtype */ +IOCPT_RC_ENOENT =7 ,/* No such element */ +IOCPT_RC_EINTR =8 ,/* Operation interrupted */ +IOCPT_RC_EAGAIN =9 ,/* Try again */ +IOCPT_RC_ENOMEM =10 ,/* Out of memory */ +IOCPT_RC_EFAULT =11 ,/* Bad address */ +IOCPT_RC_EBUSY =12 ,/* Device or resource busy */ +IOCPT_RC_EEXIST =13 ,/* Object already exists */ +IOCPT_RC_EINVAL =14 ,/* Invalid argument */ +IOCPT_RC_ENOSPC =15 ,/* No space left or alloc failure */ +IOCPT_RC_ERANGE =16 ,/* Parameter out of range */ +IOCPT_RC_BAD_ADDR =17 ,/* Descriptor contains a bad ptr */ +IOCPT_RC_DEV_CMD =18 ,/* Device cmd attempted on AdminQ */ +IOCPT_RC_ENOSUPP =19 ,/* Operation not supported */ +IOCPT_RC_ERROR =29 ,/* Generic error */ +}; + +enum iocpt_notifyq_opcode { +IOCPT_EVENT_RESET =1 , +IOCPT_EVENT_HEARTBEAT =2 , +IOCPT_EVENT_LOG =3 , +}; + +enum iocpt_lif_type { +IOCPT_LIF_TYPE_DEFAULT =0 , +}; + +/** +* struct iocpt_admin_cmd - General admin command format +* @opcode: Opcode for the command +* @lif_index: LIF index +* @cmd_data: Opcode-specific command bytes +*/ +struct iocpt_admin_cmd { +u8 opcode; +u8 rsvd; +__le16 lif_index; +u8 cmd_data[60 ]; +}; + +/** +* struct iocpt_admin_comp - General admin command completion format +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @cmd_data: Command-specific bytes +* @color: Color bit (Always 0 for commands issued to the +* Device Cmd Registers) +*/ +struct iocpt_admin_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +u8 cmd_data[11 ]; +u8 color; +#define IOCPT_COMP_COLOR_MASK 0x80 +}; + +static inline u8 iocpt_color_match (u8 color,u8 done_color) +{ +return (!!(color &IOCPT_COMP_COLOR_MASK )) == done_color; +} + +/** +* struct iocpt_nop_cmd - NOP command +* @opcode: Opcode +*/ +struct iocpt_nop_cmd { +u8 opcode; +u8 rsvd[63 ]; +}; + +/** +* struct iocpt_nop_comp - NOP command completion +* @status: Status of the command (enum iocpt_status_code) +*/ +struct iocpt_nop_comp { +u8 status; +u8 rsvd[15 ]; +}; + +#define IOCPT_IDENTITY_VERSION_1 1 + +/** +* struct iocpt_dev_identify_cmd - Driver/device identify command +* @opcode: Opcode +* @ver: Highest version of identify supported by driver +*/ +struct iocpt_dev_identify_cmd { +u8 opcode; +u8 ver; +u8 rsvd[62 ]; +}; + +/** +* struct iocpt_dev_identify_comp - Device identify command completion +* @status: Status of the command (enum iocpt_status_code) +* @ver: Version of identify returned by device +*/ +struct iocpt_dev_identify_comp { +u8 status; +u8 ver; +u8 rsvd[14 ]; +}; + +/** +* struct iocpt_dev_reset_cmd - Device reset command +* Will reset all LIFs on the device. +* @opcode: Opcode +*/ +struct iocpt_dev_reset_cmd { +u8 opcode; +u8 rsvd[63 ]; +}; + +/** +* struct iocpt_dev_reset_comp - Reset command completion +* @status: Status of the command (enum iocpt_status_code) +*/ +struct iocpt_dev_reset_comp { +u8 status; +u8 rsvd[15 ]; +}; + +/** +* struct iocpt_lif_identify_cmd - LIF identify command +* @opcode: Opcode +* @type: LIF type (enum iocpt_lif_type) +* @lif_index: LIF index +* @ver: Version of identify returned by device +*/ +struct iocpt_lif_identify_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +u8 ver; +u8 rsvd[59 ]; +}; + +/** +* struct iocpt_lif_identify_comp - LIF identify command completion +* @status: Status of the command (enum iocpt_status_code) +* @ver: Version of identify returned by device +*/ +struct iocpt_lif_identify_comp { +u8 status; +u8 ver; +u8 rsvd2[14 ]; +}; + +/** +* struct iocpt_lif_init_cmd - LIF init command +* @opcode: Opcode +* @type: LIF type (enum iocpt_lif_type) +* @lif_index: LIF index +* @info_pa: Destination address for LIF info (struct iocpt_lif_info) +*/ +struct iocpt_lif_init_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +__le32 rsvd; +__le64 info_pa; +u8 rsvd2[48 ]; +}; + +/** +* struct iocpt_lif_init_comp - LIF init command completion +* @status: Status of the command (enum iocpt_status_code) +* @hw_index: Hardware index of the initialized LIF +*/ +struct iocpt_lif_init_comp { +u8 status; +u8 rsvd; +__le16 hw_index; +u8 rsvd2[12 ]; +}; + +/** +* struct iocpt_lif_reset_cmd - LIF reset command +* Will reset only the specified LIF. +* @opcode: Opcode +* @lif_index: LIF index +*/ +struct iocpt_lif_reset_cmd { +u8 opcode; +u8 rsvd; +__le16 lif_index; +__le32 rsvd2[15 ]; +}; + +/** +* enum iocpt_lif_attr - List of LIF attributes +* @IOCPT_LIF_ATTR_STATE: LIF state attribute +* @IOCPT_LIF_ATTR_NAME: LIF name attribute +* @IOCPT_LIF_ATTR_FEATURES: LIF features attribute +* @IOCPT_LIF_ATTR_STATS_CTRL: LIF statistics control attribute +*/ +enum iocpt_lif_attr { +IOCPT_LIF_ATTR_STATE =0 , +IOCPT_LIF_ATTR_NAME =1 , +IOCPT_LIF_ATTR_FEATURES =4 , +IOCPT_LIF_ATTR_STATS_CTRL =6 , +}; + +/** +* struct iocpt_lif_setattr_cmd - Set LIF attributes on the NIC +* @opcode: Opcode +* @attr: Attribute type (enum iocpt_lif_attr) +* @lif_index: LIF index +* @state: LIF state (enum iocpt_lif_state) +* @name: The name string, 0 terminated +* @features: Features (enum iocpt_hw_features) +* @stats_ctl: Stats control commands (enum iocpt_stats_ctl_cmd) +*/ +struct iocpt_lif_setattr_cmd { +u8 opcode; +u8 attr; +__le16 lif_index; +union { +u8 state; +char name[IOCPT_IFNAMSIZ ]; +__le64 features; +u8 stats_ctl; +u8 rsvd[60 ]; + } __rte_packed; +}; + +/** +* struct iocpt_lif_setattr_comp - LIF set attr command completion +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @features: Features (enum iocpt_hw_features) +* @color: Color bit +*/ +struct iocpt_lif_setattr_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +union { +__le64 features; +u8 rsvd2[11 ]; + } __rte_packed; +u8 color; +}; + +/** +* struct iocpt_lif_getattr_cmd - Get LIF attributes from the NIC +* @opcode: Opcode +* @attr: Attribute type (enum iocpt_lif_attr) +* @lif_index: LIF index +*/ +struct iocpt_lif_getattr_cmd { +u8 opcode; +u8 attr; +__le16 lif_index; +u8 rsvd[60 ]; +}; + +/** +* struct iocpt_lif_getattr_comp - LIF get attr command completion +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @state: LIF state (enum iocpt_lif_state) +* @name: LIF name string, 0 terminated +* @features: Features (enum iocpt_hw_features) +* @color: Color bit +*/ +struct iocpt_lif_getattr_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +union { +u8 state; +__le64 features; +u8 rsvd2[11 ]; + } __rte_packed; +u8 color; +}; + +/** +* enum iocpt_logical_qtype - Logical Queue Types +* @IOCPT_QTYPE_ADMINQ: Administrative Queue +* @IOCPT_QTYPE_NOTIFYQ: Notify Queue +* @IOCPT_QTYPE_CRYPTOQ: Cryptographic Queue +* @IOCPT_QTYPE_MAX: Max queue type supported +*/ +enum iocpt_logical_qtype { +IOCPT_QTYPE_ADMINQ =0 , +IOCPT_QTYPE_NOTIFYQ =1 , +IOCPT_QTYPE_CRYPTOQ =2 , +IOCPT_QTYPE_MAX =8 , +}; + +/** +* struct iocpt_q_identify_cmd - queue identify command +* @opcode: Opcode +* @type: Logical queue type (enum iocpt_logical_qtype) +* @lif_index: LIF index +* @ver: Highest queue type version that the driver supports +*/ +struct iocpt_q_identify_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +u8 ver; +u8 rsvd2[59 ]; +}; + +/** +* struct iocpt_q_identify_comp - queue identify command completion +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @ver: Queue type version that can be used with FW +*/ +struct iocpt_q_identify_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +u8 ver; +u8 rsvd2[11 ]; +}; + +/** +* struct iocpt_q_init_cmd - Queue init command +* @opcode: Opcode +* @type: Logical queue type +* @lif_index: LIF index +* @ver: Queue type version +* @index: (LIF, qtype) relative admin queue index +* @intr_index: Interrupt control register index, or Event queue index +* @pid: Process ID +* @flags: +* IRQ: Interrupt requested on completion +* ENA: Enable the queue. If ENA=0 the queue is initialized +* but remains disabled, to be later enabled with the +* Queue Enable command. If ENA=1, then queue is +* initialized and then enabled. +* SG: Enable Scatter-Gather on the queue. +* @cos: Class of service for this queue +* @ring_size: Queue ring size, encoded as a log2(size), in +* number of descriptors. The actual ring size is +* (1 << ring_size). For example, to select a ring size +* of 64 descriptors write ring_size = 6. The minimum +* ring_size value is 2 for a ring of 4 descriptors. +* The maximum ring_size value is 12 for a ring of 4k +* descriptors. Values of ring_size <2 and >12 are +* reserved. +* @ring_base: Queue ring base address +* @cq_ring_base: Completion queue ring base address +* @sg_ring_base: Scatter/Gather ring base address +*/ +struct iocpt_q_init_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +u8 ver; +u8 rsvd[3 ]; +__le32 index; +__le16 pid; +__le16 intr_index; +__le16 flags; +#define IOCPT_QINIT_F_IRQ 0x01/* Request interrupt on completion */ +#define IOCPT_QINIT_F_ENA 0x02/* Enable the queue */ +#define IOCPT_QINIT_F_SG 0x04/* Enable scatter/gather on queue */ +u8 cos; +#define IOCPT_QSIZE_MIN_LG2 2 +#define IOCPT_QSIZE_MAX_LG2 12 +u8 ring_size; +__le64 ring_base; +__le64 cq_ring_base; +__le64 sg_ring_base; +u8 rsvd2[20 ]; +} __rte_packed; + +/** +* struct iocpt_q_init_comp - Queue init command completion +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @hw_index: Hardware Queue ID +* @hw_type: Hardware Queue type +* @color: Color +*/ +struct iocpt_q_init_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +__le32 hw_index; +u8 hw_type; +u8 rsvd2[6 ]; +u8 color; +}; + +enum iocpt_desc_opcode { +IOCPT_DESC_OPCODE_GCM_AEAD_ENCRYPT =0 , +IOCPT_DESC_OPCODE_GCM_AEAD_DECRYPT =1 , +IOCPT_DESC_OPCODE_XTS_ENCRYPT =2 , +IOCPT_DESC_OPCODE_XTS_DECRYPT =3 , +}; + +#define IOCPT_DESC_F_AAD_VALID 0x1 + +/** +* struct iocpt_desc - Crypto queue descriptor format +* @opcode: +* IOCPT_DESC_OPCODE_GCM_AEAD_ENCRYPT: +* Perform a GCM-AES encrypt operation +* +* IOCPT_DESC_OPCODE_GCM_AEAD_DECRYPT: +* Perform a GCM-AES decrypt operation +* +* IOCPT_DESC_OPCODE_XTS_ENCRYPT: +* Perform an XTS encrypt operation +* +* IOCPT_DESC_OPCODE_XTS_DECRYPT: +* Perform an XTS decrypt operation +* @flags: +* IOCPT_DESC_F_AAD_VALID: +* Source SGL contains an AAD addr and length +* @num_src_dst_sgs: Number of scatter-gather elements in SG +* descriptor (4 bits for source, 4 bits for destination) +* @session_tag: Session tag (key index) +* @intr_ctx_addr: Completion interrupt context address +* @intr_ctx_data: Completion interrupt context data +*/ +struct iocpt_crypto_desc { +uint8_t opcode; +uint8_t flags; +uint8_t num_src_dst_sgs; +#define IOCPT_DESC_NSGE_SRC_MASK 0xf +#define IOCPT_DESC_NSGE_SRC_SHIFT 0 +#define IOCPT_DESC_NSGE_DST_MASK 0xf +#define IOCPT_DESC_NSGE_DST_SHIFT 4 +uint8_t rsvd[9 ]; +__le32 session_tag; +__le64 intr_ctx_addr; +__le64 intr_ctx_data; +} __rte_packed; + +static inline uint8_t iocpt_encode_nsge_src_dst (uint8_t src,uint8_t dst) +{ +uint8_t nsge_src_dst; + + nsge_src_dst = (src &IOCPT_DESC_NSGE_SRC_MASK ) << +IOCPT_DESC_NSGE_SRC_SHIFT ; + nsge_src_dst |= (dst &IOCPT_DESC_NSGE_DST_MASK ) << +IOCPT_DESC_NSGE_DST_SHIFT ; + +return nsge_src_dst; +}; + +static inline void iocpt_decode_nsge_src_dst (uint8_t nsge_src_dst, +uint8_t *src,uint8_t *dst) +{ + *src = (nsge_src_dst >>IOCPT_DESC_NSGE_SRC_SHIFT ) & +IOCPT_DESC_NSGE_SRC_MASK ; + *dst = (nsge_src_dst >>IOCPT_DESC_NSGE_DST_SHIFT ) & +IOCPT_DESC_NSGE_DST_MASK ; +}; + +/** +* struct iocpt_crypto_sg_elem - Crypto scatter-gather (SG) descriptor element +* @addr: DMA address of SG element data buffer +* @len: Length of SG element data buffer, in bytes +*/ +struct iocpt_crypto_sg_elem { +__le64 addr; +__le16 len; +uint8_t rsvd[6 ]; +}; + +/** +* struct iocpt_crypto_sg_desc - Crypto scatter-gather (SG) list +* @src_elems: Source SG elements; also destination in IP case +* AES_GCM: +* SGE0: Nonce +* SGE1: AAD (see IOCPT_DESC_F_AAD_VALID) +* SGE2 to SGE(N): Payload +* SGE(N+1): Auth tag +* @dst_elems: Destination SG elements for OOP case; unused in IP case +*/ +struct iocpt_crypto_sg_desc { +#define IOCPT_CRYPTO_MAX_SG_ELEMS 8 +#define IOCPT_CRYPTO_NONCE_ELEM 0 +#define IOCPT_CRYPTO_AAD_ELEM 1 +struct iocpt_crypto_sg_elem src_elems[IOCPT_CRYPTO_MAX_SG_ELEMS ]; +struct iocpt_crypto_sg_elem dst_elems[IOCPT_CRYPTO_MAX_SG_ELEMS ]; +}; + +/** +* struct iocpt_crypto_comp - Crypto queue completion descriptor +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @color: Color bit +*/ +struct iocpt_crypto_comp { +#define IOCPT_COMP_SUCCESS 0 +#define IOCPT_COMP_INVAL_OPCODE_ERROR 1 +#define IOCPT_COMP_UNSUPP_OPCODE_ERROR 2 +#define IOCPT_COMP_SYMM_SRC_SG_ERROR 3 +#define IOCPT_COMP_SYMM_DST_SG_ERROR 4 +#define IOCPT_COMP_SYMM_SRC_DST_LEN_MISMATCH 5 +#define IOCPT_COMP_SYMM_HW_QAVAIL_ERROR 6 +#define IOCPT_COMP_SYMM_AUTH_VERIFY_ERROR 7 +#define IOCPT_COMP_SYMM_OTHER_VERIFY_ERROR 8 +#define IOCPT_COMP_SYMM_PI_MODE_CHKSUM_ERROR 9 +#define IOCPT_COMP_SYMM_HARDWARE_ERROR 10 +#define IOCPT_COMP_SYMM_KEY_IDX_ERROR 11 +u8 status; +u8 rsvd; +__le16 comp_index; +u8 rsvd2[11 ]; +u8 color; +}; + +/** +* enum iocpt_hw_features - Feature flags supported by hardware +* @IOCPT_HW_SYM: Symmetric crypto operations +* @IOCPT_HW_ASYM: Asymmetric crypto operations +* @IOCPT_HW_CHAIN: Chained crypto operations +* @IOCPT_HW_IP: In-Place (destination same as source) +* @IOCPT_HW_OOP: Out-Of-Place (destination differs from source) +*/ +enum iocpt_hw_features { +IOCPT_HW_SYM =BIT (0 ), +IOCPT_HW_ASYM =BIT (1 ), +IOCPT_HW_CHAIN =BIT (2 ), +IOCPT_HW_IP =BIT (3 ), +IOCPT_HW_OOP =BIT (4 ), +}; + +/** +* struct iocpt_q_control_cmd - Queue control command +* @opcode: Opcode +* @type: Queue type +* @lif_index: LIF index +* @index: Queue index +* @oper: Operation (enum iocpt_q_control_oper) +*/ +struct iocpt_q_control_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +__le32 index; +u8 oper; +u8 rsvd2[55 ]; +}; + +enum iocpt_q_control_oper { +IOCPT_Q_DISABLE =0 , +IOCPT_Q_ENABLE =1 , +}; + +/* NB: It will take 64 transfers to update a 2048B key */ +#define IOCPT_SESS_KEY_LEN_MIN 16 +#define IOCPT_SESS_KEY_LEN_MAX_SYMM 32 +#define IOCPT_SESS_KEY_LEN_MAX_ASYM 2048 +#define IOCPT_SESS_KEY_SEG_LEN 32 +#define IOCPT_SESS_KEY_SEG_SHFT 5 +#define IOCPT_SESS_KEY_SEG_CNT \ + (IOCPT_SESS_KEY_LEN_MAX_SYMM >> IOCPT_SESS_KEY_SEG_SHFT) + +enum iocpt_sess_type { +IOCPT_SESS_NONE =0 , +IOCPT_SESS_AEAD_AES_GCM =1 , +}; + +enum iocpt_sess_control_oper { +IOCPT_SESS_INIT =0 , +IOCPT_SESS_UPDATE_KEY =2 , +IOCPT_SESS_DISABLE =3 , +}; + +/** +* struct iocpt_sess_control_cmd - Session control command +* @opcode: Opcode +* @type: Session type (enum iocpt_sess_type) +* @lif_index: LIF index +* @oper: Operation (enum iocpt_sess_control_oper) +* @flags: +* END: Indicates that this is the final segment of the key. +* When this flag is set, a write will be triggered from the +* controller's memory into the dedicated key-storage area. +* @key_len: Crypto key length in bytes +* @index: Session index, as allocated by PMD +* @key_seg_len: Crypto key segment length in bytes +* @key_seg_idx: Crypto key segment index +* @key: Crypto key +*/ +struct iocpt_sess_control_cmd { +u8 opcode; +u8 type; +__le16 lif_index; +u8 oper; +u8 flags; +#define IOCPT_SCTL_F_END 0x01/* Final segment of key */ +__le16 key_len; +__le32 index; +u8 key_seg_len; +u8 key_seg_idx; +u8 rsvd[18 ]; +u8 key[IOCPT_SESS_KEY_SEG_LEN ]; +}; + +/** +* struct iocpt_sess_control_comp - Session control command completion +* @status: Status of the command (enum iocpt_status_code) +* @comp_index: Index in the descriptor ring for which this is the completion +* @index: Session index +* @hw_type: Hardware Session type +* @color: Color +*/ +struct iocpt_sess_control_comp { +u8 status; +u8 rsvd; +__le16 comp_index; +__le32 index; +u8 hw_type; +u8 rsvd2[6 ]; +u8 color; +}; + +/** +* enum iocpt_stats_ctl_cmd - List of commands for stats control +* @IOCPT_STATS_CTL_RESET: Reset statistics +*/ +enum iocpt_stats_ctl_cmd { +IOCPT_STATS_CTL_RESET =0 , +}; + +/** +* struct iocpt_dev_status - Device status register +* @eid: most recent NotifyQ event id +*/ +struct iocpt_dev_status { +__le64 eid; +u8 rsvd2[56 ]; +}; + +enum iocpt_dev_state { +IOCPT_DEV_DISABLE =0 , +IOCPT_DEV_ENABLE =1 , +IOCPT_DEV_HANG_RESET =2 , +}; + +/** +* enum iocpt_dev_attr - List of device attributes +* @IOCPT_DEV_ATTR_STATE: Device state attribute +* @IOCPT_DEV_ATTR_NAME: Device name attribute +* @IOCPT_DEV_ATTR_FEATURES: Device feature attributes +*/ +enum iocpt_dev_attr { +IOCPT_DEV_ATTR_STATE =0 , +IOCPT_DEV_ATTR_NAME =1 , +IOCPT_DEV_ATTR_FEATURES =2 , +}; + +/** +* struct iocpt_notify_event - Generic event reporting structure +* @eid: event number +* @ecode: event code +* @data: unspecified data about the event +* +* This is the generic event report struct from which the other +* actual events will be formed. +*/ +struct iocpt_notify_event { +__le64 eid; +__le16 ecode; +u8 data[54 ]; +}; + +/** +* struct iocpt_reset_event - Reset event notification +* @eid: event number +* @ecode: event code = IOCPT_EVENT_RESET +* @reset_code: reset type +* @state: 0=pending, 1=complete, 2=error +* +* Sent when the NIC or some subsystem is going to be or +* has been reset. +*/ +struct iocpt_reset_event { +__le64 eid; +__le16 ecode; +u8 reset_code; +u8 state; +u8 rsvd[52 ]; +}; + +/** +* struct iocpt_heartbeat_event - Sent periodically by NIC to indicate health +* @eid: event number +* @ecode: event code = IOCPT_EVENT_HEARTBEAT +*/ +struct iocpt_heartbeat_event { +__le64 eid; +__le16 ecode; +u8 rsvd[54 ]; +}; + +/** +* struct iocpt_log_event - Sent to notify the driver of an internal error +* @eid: event number +* @ecode: event code = IOCPT_EVENT_LOG +* @data: log data +*/ +struct iocpt_log_event { +__le64 eid; +__le16 ecode; +u8 data[54 ]; +}; + +/** +* union iocpt_lif_config - LIF configuration +* @state: LIF state (enum iocpt_lif_state) +* @name: LIF name +* @features: LIF features active (enum iocpt_hw_features) +* @queue_count: Queue counts per queue-type +*/ +union iocpt_lif_config { +struct { +u8 state; +u8 rsvd[3 ]; +char name[IOCPT_IFNAMSIZ ]; +u8 rsvd2[12 ]; +__le64 features; +__le32 queue_count[IOCPT_QTYPE_MAX ]; + } __rte_packed; +__le32 words[56 ]; +}; + +/** +* struct iocpt_lif_status - LIF status register +* @eid: most recent NotifyQ event id +*/ +struct iocpt_lif_status { +__le64 eid; +u8 rsvd[56 ]; +}; + +/** +* struct iocpt_lif_info - LIF info structure +* @config: LIF configuration structure +* @status: LIF status structure +* @stats: LIF statistics structure +*/ +struct iocpt_lif_info { +union iocpt_lif_config config; +struct iocpt_lif_status status; +}; + +union iocpt_dev_cmd { +u32 words[16 ]; +struct iocpt_admin_cmd cmd; +struct iocpt_nop_cmd nop; + +struct iocpt_dev_identify_cmd identify; +struct iocpt_dev_reset_cmd reset; + +struct iocpt_lif_identify_cmd lif_identify; +struct iocpt_lif_init_cmd lif_init; +struct iocpt_lif_reset_cmd lif_reset; +struct iocpt_lif_getattr_cmd lif_getattr; +struct iocpt_lif_setattr_cmd lif_setattr; + +struct iocpt_q_identify_cmd q_identify; +struct iocpt_q_init_cmd q_init; +struct iocpt_q_control_cmd q_control; + +struct iocpt_sess_control_cmd sess_control; +}; + +union iocpt_dev_cmd_comp { +u32 words[4 ]; +u8 status; +struct iocpt_admin_comp comp; +struct iocpt_nop_comp nop; + +struct iocpt_dev_identify_comp identify; +struct iocpt_dev_reset_comp reset; + +struct iocpt_lif_identify_comp lif_identify; +struct iocpt_lif_init_comp lif_init; +struct iocpt_lif_getattr_comp lif_getattr; +struct iocpt_lif_setattr_comp lif_setattr; + +struct iocpt_q_identify_comp q_identify; +struct iocpt_q_init_comp q_init; + +struct iocpt_sess_control_comp sess_control; +}; + +/** +* union iocpt_dev_info_regs - Device info register format (read-only) +* @signature: Signature value of 0x43585660 ('CRPT') +* @version: Current version of info +* @asic_type: Asic type +* @asic_rev: Asic revision +* @fw_status: Firmware status +* @fw_heartbeat: Firmware heartbeat counter +* @serial_num: Serial number +* @fw_version: Firmware version +*/ +union iocpt_dev_info_regs { +#define IOCPT_FWVERS_BUFLEN 32 +#define IOCPT_SERIAL_BUFLEN 32 +struct { +u32 signature; +u8 version; +u8 asic_type; +u8 asic_rev; +#define IOCPT_FW_STS_F_RUNNING 0x1 +u8 fw_status; +u32 fw_heartbeat; +char fw_version[IOCPT_FWVERS_BUFLEN ]; +char serial_num[IOCPT_SERIAL_BUFLEN ]; + }; +u32 words[512 ]; +}; + +/** +* union iocpt_dev_cmd_regs - Device command register format (read-write) +* @doorbell: Device Cmd Doorbell, write-only +* Write a 1 to signal device to process cmd, +* poll done for completion. +* @done: Done indicator, bit 0 == 1 when command is complete +* @cmd: Opcode-specific command bytes +* @comp: Opcode-specific response bytes +* @data: Opcode-specific side-data +*/ +union iocpt_dev_cmd_regs { +struct { +u32 doorbell; +u32 done; +union iocpt_dev_cmd cmd; +union iocpt_dev_cmd_comp comp; +u8 rsvd[48 ]; +u32 data[478 ]; + } __rte_packed; +u32 words[512 ]; +}; + +/** +* union iocpt_dev_regs - Device register format for bar 0 page 0 +* @info: Device info registers +* @devcmd: Device command registers +*/ +union iocpt_dev_regs { +struct { +union iocpt_dev_info_regs info; +union iocpt_dev_cmd_regs devcmd; + } __rte_packed; +__le32 words[1024 ]; +}; + +union iocpt_adminq_cmd { +struct iocpt_admin_cmd cmd; +struct iocpt_nop_cmd nop; +struct iocpt_q_identify_cmd q_identify; +struct iocpt_q_init_cmd q_init; +struct iocpt_q_control_cmd q_control; +struct iocpt_lif_setattr_cmd lif_setattr; +struct iocpt_lif_getattr_cmd lif_getattr; +struct iocpt_sess_control_cmd sess_control; +}; + +union iocpt_adminq_comp { +struct iocpt_admin_comp comp; +struct iocpt_nop_comp nop; +struct iocpt_q_identify_comp q_identify; +struct iocpt_q_init_comp q_init; +struct iocpt_lif_setattr_comp lif_setattr; +struct iocpt_lif_getattr_comp lif_getattr; +struct iocpt_sess_control_comp sess_control; +}; + +union iocpt_notify_comp { +struct iocpt_notify_event event; +struct iocpt_reset_event reset; +struct iocpt_heartbeat_event heartbeat; +struct iocpt_log_event log; +}; + +/** +* union iocpt_dev_identity - device identity information +* @version: Version of device identify +* @type: Identify type (0 for now) +* @state: Device state +* @nlifs: Number of LIFs provisioned +* @nintrs: Number of interrupts provisioned +* @ndbpgs_per_lif: Number of doorbell pages per LIF +* @intr_coal_mult: Interrupt coalescing multiplication factor +* Scale user-supplied interrupt coalescing +* value in usecs to device units using: +* device units = usecs * mult / div +* @intr_coal_div: Interrupt coalescing division factor +* Scale user-supplied interrupt coalescing +* value in usecs to device units using: +* device units = usecs * mult / div +*/ +union iocpt_dev_identity { +struct { +u8 version; +u8 type; +u8 state; +u8 rsvd; +__le32 nlifs; +__le32 nintrs; +__le32 ndbpgs_per_lif; +__le32 intr_coal_mult; +__le32 intr_coal_div; +u8 rsvd2[8 ]; + }; +__le32 words[8 ]; +}; + +/** +* union iocpt_lif_identity - LIF identity information (type-specific) +* +* @features: LIF features (see enum iocpt_hw_features) +* @version: Identify structure version +* @hw_index: LIF hardware index +* @max_nb_sessions: Maximum number of sessions supported +* @config: LIF config struct with features, q counts +*/ +union iocpt_lif_identity { +struct { +__le64 features; + +u8 version; +u8 hw_index; +u8 rsvd[2 ]; +__le32 max_nb_sessions; +u8 rsvd2[120 ]; +union iocpt_lif_config config; + } __rte_packed; +__le32 words[90 ]; +}; + +/** +* union iocpt_q_identity - queue identity information +* @version: Queue type version that can be used with FW +* @supported: Bitfield of queue versions, first bit = ver 0 +* @features: Queue features +* @desc_sz: Descriptor size +* @comp_sz: Completion descriptor size +* @sg_desc_sz: Scatter/Gather descriptor size +* @max_sg_elems: Maximum number of Scatter/Gather elements +* @sg_desc_stride: Number of Scatter/Gather elements per descriptor +*/ +union iocpt_q_identity { +struct { +u8 version; +u8 supported; +u8 rsvd[6 ]; +#define IOCPT_QIDENT_F_CQ 0x01/* queue has completion ring */ +#define IOCPT_QIDENT_F_SG 0x02/* queue has scatter/gather ring */ +__le64 features; +__le16 desc_sz; +__le16 comp_sz; +__le16 sg_desc_sz; +__le16 max_sg_elems; +__le16 sg_desc_stride; + }; +__le32 words[20 ]; +}; + +struct iocpt_identity { +union iocpt_dev_identity dev; +union iocpt_lif_identity lif; +union iocpt_q_identity q; +}; + +#endif /* _IONIC_CRYPTO_IF_H_ */
Signature · 1 line
2.17.1
PATCH 2/6 crypto/ionic: add device and admin command handlers
In reply to Andrew BoyerThis defines the handlers used for device (register-based) and admin (adminq-based) commands.
--- drivers/crypto/ionic/ionic_crypto.h | 210 ++++++++ drivers/crypto/ionic/ionic_crypto_cmds.c | 651 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 42 ++ drivers/crypto/ionic/meson.build | 12 + 4 files changed, 915 insertions(+) create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/meson.build
drivers/crypto/ionic/ionic_crypto.h new file +210 -0
@@ -0,0 +1,210 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#ifndef _IONIC_CRYPTO_H_ +#define _IONIC_CRYPTO_H_ + +#include <stdint.h> +#include <stdbool.h> +#include <inttypes.h> + +#include <rte_common.h> +#include <rte_dev.h> +#include <rte_cryptodev.h> +#include <cryptodev_pmd.h> +#include <rte_log.h> +#include <rte_bitmap.h> + +#include "ionic_common.h" +#include "ionic_crypto_if.h" +#include "ionic_regs.h" + +#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ + +#define IOCPT_CRYPTOQ_WAIT 10/* 1s */ + +extern int iocpt_logtype; +#define RTE_LOGTYPE_IOCPT iocpt_logtype + +#define IOCPT_PRINT (level, ...) \ + RTE_LOG_LINE_PREFIX(level, IOCPT, "%s(): ", __func__, __VA_ARGS__) + +#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") + +struct iocpt_qtype_info { +uint8_t version; +uint8_t supported; +uint64_t features; +uint16_t desc_sz; +uint16_t comp_sz; +uint16_t sg_desc_sz; +uint16_t max_sg_elems; +uint16_t sg_desc_stride; +}; + +#define IOCPT_Q_F_INITED BIT(0) +#define IOCPT_Q_F_DEFERRED BIT(1) +#define IOCPT_Q_F_SG BIT(2) + +#define Q_NEXT_TO_POST (_q, _n) (((_q)->head_idx + (_n)) & ((_q)->size_mask)) +#define Q_NEXT_TO_SRVC (_q, _n) (((_q)->tail_idx + (_n)) & ((_q)->size_mask)) + +#define IOCPT_INFO_SZ (_q) ((_q)->num_segs * sizeof(void *)) +#define IOCPT_INFO_IDX (_q, _i) ((_i) * (_q)->num_segs) +#define IOCPT_INFO_PTR (_q, _i) (&(_q)->info[IOCPT_INFO_IDX((_q), _i)]) + +struct iocpt_queue { +uint16_t num_descs; +uint16_t num_segs; +uint16_t head_idx; +uint16_t tail_idx; +uint16_t size_mask; +uint8_t type; +uint8_t hw_type; +void *base; +void *sg_base; +struct ionic_doorbell __iomem *db; +void **info; + +uint32_t index; +uint32_t hw_index; +rte_iova_t base_pa; +rte_iova_t sg_base_pa; +}; + +struct iocpt_cq { +uint16_t tail_idx; +uint16_t num_descs; +uint16_t size_mask; +bool done_color; +void *base; +rte_iova_t base_pa; +}; + +#define IOCPT_COMMON_FIELDS \ + struct iocpt_queue q; \ + struct iocpt_cq cq; \ + struct iocpt_dev *dev; \ + const struct rte_memzone *base_z; \ + void *base; \ + rte_iova_t base_pa + +struct iocpt_common_q { +IOCPT_COMMON_FIELDS ; +}; + +struct iocpt_admin_q { +IOCPT_COMMON_FIELDS ; + +uint16_t flags; +}; + +#define IOCPT_DEV_F_INITED BIT(0) +#define IOCPT_DEV_F_UP BIT(1) +#define IOCPT_DEV_F_FW_RESET BIT(2) + +/* Combined dev / LIF object */ +struct iocpt_dev { +const char *name; +char fw_version[IOCPT_FWVERS_BUFLEN ]; +struct iocpt_identity ident; + +void *bus_dev; +struct rte_cryptodev *crypto_dev; + +union iocpt_dev_info_regs __iomem *dev_info; +union iocpt_dev_cmd_regs __iomem *dev_cmd; + +struct ionic_doorbell __iomem *db_pages; +struct ionic_intr __iomem *intr_ctrl; + +uint32_t max_qps; +uint32_t max_sessions; +uint16_t state; +uint8_t driver_id; +uint8_t socket_id; + +rte_spinlock_t adminq_lock; +rte_spinlock_t adminq_service_lock; + +struct iocpt_admin_q *adminq; + +uint64_t features; +uint32_t hw_features; + +uint32_t info_sz; +struct iocpt_lif_info *info; +rte_iova_t info_pa; +const struct rte_memzone *info_z; + +struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX ]; +uint8_t qtype_ver[IOCPT_QTYPE_MAX ]; + +struct rte_cryptodev_stats stats_base; +}; + +/** iocpt_admin_ctx - Admin command context. +* @pending_work: Flag that indicates a completion. +* @cmd: Admin command (64B) to be copied to the queue. +* @comp: Admin completion (16B) copied from the queue. +*/ +struct iocpt_admin_ctx { +bool pending_work; +union iocpt_adminq_cmd cmd; +union iocpt_adminq_comp comp; +}; + +int iocpt_dev_identify (struct iocpt_dev *dev); +int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa); +int iocpt_dev_adminq_init (struct iocpt_dev *dev); +void iocpt_dev_reset (struct iocpt_dev *dev); + +int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); + +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev, +struct iocpt_queue *q); + +typedef bool (*iocpt_cq_cb )(struct iocpt_cq *cq,uint16_t cq_desc_index, +void *cb_arg); +uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do, +iocpt_cq_cb cb,void *cb_arg); + +static inline uint16_t +iocpt_q_space_avail (struct iocpt_queue *q) +{ +uint16_t avail = q->tail_idx; + +if (q->head_idx >= avail) + avail += q->num_descs - q->head_idx -1 ; +else + avail -= q->head_idx +1 ; + +return avail; +} + +static inline void +iocpt_q_flush (struct iocpt_queue *q) +{ +uint64_t val =IONIC_DBELL_QID (q->hw_index) | q->head_idx; + +#if defined(RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA ) +/* On some devices the standard 'dmb' barrier is insufficient */ + asmvolatile ("dsb st" : : :"memory" ); +rte_write64_relaxed (rte_cpu_to_le_64 (val), q->db); +#else +rte_write64 (rte_cpu_to_le_64 (val), q->db); +#endif +} + +static inline bool +iocpt_is_embedded (void ) +{ +#if defined(RTE_LIBRTE_IONIC_PMD_EMBEDDED ) +return true; +#else +return false; +#endif +} + +#endif /* _IONIC_CRYPTO_H_ */
drivers/crypto/ionic/ionic_crypto_cmds.c new file +651 -0
651 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c new file +42 -0
42 lines not on this page · raw message
drivers/crypto/ionic/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_cmds.c', + 'ionic_crypto_main.c', +) +name = 'ionic_crypto' + +includes += include_directories('../../common/ionic')
Signature · 1 line
2.17.1
Re: [PATCH 2/6] crypto/ionic: add device and admin command handlers
On Apr 19, 2024, at 3:53 PM, Boyer, Andrew <[email protected]> wrote:
drivers/crypto/ionic/ionic_crypto_main.c new file +14 -0
@@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#include <inttypes.h> + +#include <rte_common.h> +#include <rte_malloc.h> +#include <rte_bitops.h> + +#include "ionic_crypto.h" + +int iocpt_logtype; +
Oops - this int duplicates one inside RTE_LOG_REGISTER_DEFAULT(). I guess the github actions don't do any builds with GCC11 yet.
Akhil, I will respin once you do a first pass over the rest of it.
Thanks,
Andrew
PATCH 3/6 common/ionic: add crypto vdev support
In reply to Andrew BoyerThis adds support for cryptodevs to the common ionic library.
--- drivers/common/ionic/ionic_common.h | 2 ++ drivers/common/ionic/ionic_common_uio.c | 48 ++++++++++++++++++++++++- drivers/common/ionic/version.map | 1 + 3 files changed, 50 insertions(+), 1 deletion(-)
drivers/common/ionic/ionic_common.h +2 -0
@@ -32,6 +32,8 @@ struct ionic_dev_bar {__rte_internal void ionic_uio_scan_mnet_devices(void); +__rte_internal +void ionic_uio_scan_mcrypt_devices(void);__rte_internal void ionic_uio_get_rsrc(const char *name, int idx, struct ionic_dev_bar *bar);
drivers/common/ionic/ionic_common_uio.c +47 -1
69 lines not on this page · raw message
drivers/common/ionic/version.map +1 -0
@@ -2,6 +2,7 @@ INTERNAL { global: ionic_uio_scan_mnet_devices; + ionic_uio_scan_mcrypt_devices; ionic_uio_get_rsrc; ionic_uio_rel_rsrc;
Signature · 1 line
2.17.1
PATCH 4/6 crypto/ionic: add device object and vdev support
In reply to Andrew BoyerThis defines the main device object routines and the vdev support code. The vdev code uses the common library.
--- drivers/crypto/ionic/ionic_crypto.h | 89 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 538 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 ++++++ drivers/crypto/ionic/meson.build | 2 + 4 files changed, 757 insertions(+) create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c
drivers/crypto/ionic/ionic_crypto.h +89 -0
@@ -20,6 +20,11 @@#include "ionic_crypto_if.h" #include "ionic_regs.h" +/* Devargs */ +/* NONE */ + +#define IOCPT_MAX_RING_DESC 32768 +#define IOCPT_MIN_RING_DESC 16#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ #define IOCPT_CRYPTOQ_WAIT 10/* 1s */
@@ -32,6 +37,64 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +static inline void iocpt_struct_size_checks (void ) +{ +RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr_status ) !=8 ); + +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_regs ) !=4096 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_info_regs ) !=2048 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_cmd_regs ) !=2048 ); + +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_comp ) !=16 ); + +/* Device commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_comp ) !=16 ); + +/* LIF commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_comp ) !=16 ); + +/* Queue commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_control_cmd ) !=64 ); + +/* Crypto */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_desc ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_sg_desc ) !=256 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_comp ) !=16 ); +} + +struct iocpt_dev_bars { +struct ionic_dev_bar bar[IONIC_BARS_MAX ]; +uint32_t num_bars; +}; + +/* Queue watchdog */ +#define IOCPT_Q_WDOG_SESS_IDX 0 +#define IOCPT_Q_WDOG_KEY_LEN 16 +#define IOCPT_Q_WDOG_IV_LEN 12 +#define IOCPT_Q_WDOG_PLD_LEN 4 +#define IOCPT_Q_WDOG_TAG_LEN 16 +#define IOCPT_Q_WDOG_OP_TYPE RTE_CRYPTO_OP_TYPE_UNDEFINED +struct iocpt_qtype_info {uint8_t version;uint8_t supported;
@@ -108,8 +171,10 @@ struct iocpt_admin_q {struct iocpt_dev {const char *name;char fw_version[IOCPT_FWVERS_BUFLEN ]; +struct iocpt_dev_bars bars;struct iocpt_identity ident; +const struct iocpt_dev_intf *intf;void *bus_dev;struct rte_cryptodev *crypto_dev;
@@ -130,6 +195,8 @@ struct iocpt_dev {struct iocpt_admin_q *adminq; +struct rte_bitmap *sess_bm;/* SET bit indicates index is free */ +uint64_t features;uint32_t hw_features;
@@ -144,6 +211,20 @@ struct iocpt_dev {struct rte_cryptodev_stats stats_base; }; +struct iocpt_dev_intf { +int (*setup_bars)(struct iocpt_dev *dev); +void (*unmap_bars)(struct iocpt_dev *dev); +}; + +static inline int +iocpt_setup_bars (struct iocpt_dev *dev) +{ +if (dev->intf->setup_bars ==NULL ) +return -EINVAL ; + +return (*dev->intf->setup_bars)(dev); +} +/** iocpt_admin_ctx - Admin command context. * @pending_work: Flag that indicates a completion. * @cmd: Admin command (64B) to be copied to the queue.
@@ -155,6 +236,14 @@ struct iocpt_admin_ctx {union iocpt_adminq_comp comp; }; +int iocpt_probe (void *bus_dev,struct rte_device *rte_dev, +struct iocpt_dev_bars *bars,const struct iocpt_dev_intf *intf, +uint8_t driver_id,uint8_t socket_id); +int iocpt_remove (struct rte_device *rte_dev); + +void iocpt_configure (struct iocpt_dev *dev); +void iocpt_deinit (struct iocpt_dev *dev); +int iocpt_dev_identify (struct iocpt_dev *dev);int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa);int iocpt_dev_adminq_init (struct iocpt_dev *dev);
drivers/crypto/ionic/ionic_crypto_main.c +538 -0
554 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_vdev.c new file +128 -0
128 lines not on this page · raw message
drivers/crypto/ionic/meson.build +2 -0
@@ -1,11 +1,13 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2021-2024 Advanced Micro Devices, Inc. +deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', ) name = 'ionic_crypto'
Signature · 1 line
2.17.1
PATCH 5/6 crypto/ionic: add datapath and capabilities support
In reply to Andrew BoyerThis defines the main datapath and reports the device capabilities to the stack.
--- drivers/crypto/ionic/ionic_crypto.h | 62 +++ drivers/crypto/ionic/ionic_crypto_caps.c | 55 ++ drivers/crypto/ionic/ionic_crypto_main.c | 417 +++++++++++++++- drivers/crypto/ionic/ionic_crypto_ops.c | 606 +++++++++++++++++++++++ drivers/crypto/ionic/meson.build | 2 + 5 files changed, 1140 insertions(+), 2 deletions(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c
drivers/crypto/ionic/ionic_crypto.h +62 -0
@@ -37,6 +37,8 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +const struct rte_cryptodev_capabilities *iocpt_get_caps (uint64_t flags); +static inline void iocpt_struct_size_checks (void ) {RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 );
@@ -163,6 +165,50 @@ struct iocpt_admin_q {uint16_t flags; }; +struct iocpt_crypto_q { +/* cacheline0, cacheline1 */ +IOCPT_COMMON_FIELDS ; + +/* cacheline2 */ +uint64_t last_wdog_cycles; +uint16_t flags; + +/* cacheline3 */ +struct rte_cryptodev_stats stats; + +uint64_t enqueued_wdogs; +uint64_t dequeued_wdogs; +uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN ]; +uint8_t wdog_pld[IOCPT_Q_WDOG_PLD_LEN ]; +uint8_t wdog_tag[IOCPT_Q_WDOG_TAG_LEN ]; +}; + +#define IOCPT_S_F_INITED BIT(0) + +struct iocpt_session_priv { +struct iocpt_dev *dev; + +uint32_t index; + +uint16_t iv_offset; +uint16_t iv_length; +uint16_t digest_length; +uint16_t aad_length; + +uint8_t flags; +uint8_t op; +uint8_t type; + +uint16_t key_len; +uint8_t key[IOCPT_SESS_KEY_LEN_MAX_SYMM ]; +}; + +static inline uint32_t +iocpt_session_size (void ) +{ +return sizeof (struct iocpt_session_priv ); +} +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -194,6 +240,7 @@ struct iocpt_dev {rte_spinlock_t adminq_service_lock;struct iocpt_admin_q *adminq; +struct iocpt_crypto_q **cryptoqs;struct rte_bitmap *sess_bm;/* SET bit indicates index is free */
@@ -242,6 +289,9 @@ int iocpt_probe(void *bus_dev, struct rte_device *rte_dev,int iocpt_remove (struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev); +int iocpt_assign_ops (struct rte_cryptodev *cdev); +int iocpt_start (struct iocpt_dev *dev); +void iocpt_stop (struct iocpt_dev *dev);void iocpt_deinit (struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);
@@ -251,6 +301,14 @@ void iocpt_dev_reset(struct iocpt_dev *dev);int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); +int iocpt_cryptoq_alloc (struct iocpt_dev *dev,uint32_t socket_id, +uint32_t index,uint16_t ndescs); +void iocpt_cryptoq_free (struct iocpt_crypto_q *cptq); + +int iocpt_session_init (struct iocpt_session_priv *priv); +int iocpt_session_update (struct iocpt_session_priv *priv); +void iocpt_session_deinit (struct iocpt_session_priv *priv); +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev,struct iocpt_queue *q);
@@ -259,6 +317,10 @@ typedef bool (*iocpt_cq_cb)(struct iocpt_cq *cq, uint16_t cq_desc_index,uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do,iocpt_cq_cb cb,void *cb_arg); +void iocpt_get_stats (const struct iocpt_dev *dev, +struct rte_cryptodev_stats *stats); +void iocpt_reset_stats (struct iocpt_dev *dev); +static inline uint16_t iocpt_q_space_avail (struct iocpt_queue *q) {
drivers/crypto/ionic/ionic_crypto_caps.c new file +55 -0
55 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +415 -2
502 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c new file +606 -0
606 lines not on this page · raw message
drivers/crypto/ionic/meson.build +2 -0
@@ -5,8 +5,10 @@ deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( + 'ionic_crypto_caps.c', 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', + 'ionic_crypto_ops.c', 'ionic_crypto_vdev.c', ) name = 'ionic_crypto'
Signature · 1 line
2.17.1
PATCH 6/6 crypto/ionic: add documentation and connect to build
In reply to Andrew BoyerAdd a features list and guide for the ionic crypto PMD. Hook the new PMD up to the build.
--- MAINTAINERS | 7 +++++ doc/guides/cryptodevs/features/ionic.ini | 40 ++++++++++++++++++++++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 39 +++++++++++++++++++++++ drivers/crypto/meson.build | 1 + 5 files changed, 88 insertions(+) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst
MAINTAINERS +7 -0
@@ -1075,6 +1075,13 @@ F: drivers/crypto/ccp/ F: doc/guides/cryptodevs/ccp.rst F: doc/guides/cryptodevs/features/ccp.ini +AMD Pensando ionic crypto +M: Andrew Boyer <[email protected]> +F: drivers/crypto/ionic/ +F: drivers/common/ionic/ +F: doc/guides/cryptodevs/ionic.rst +F: doc/guides/cryptodevs/features/ionic.ini + ARMv8 Crypto M: Ruifeng Wang <[email protected]> F: drivers/crypto/armv8/
doc/guides/cryptodevs/features/ionic.ini new file +40 -0
@@ -0,0 +1,40 @@ +; +; Supported features of the 'ionic' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Symmetric crypto = Y +HW Accelerated = Y +In Place SGL = Y +OOP SGL In LB Out = Y +OOP SGL In SGL Out = Y +OOP LB In LB Out = Y + +; +; Supported crypto algorithms of 'ionic' crypto driver. +; +[Cipher] + +; +; Supported authentication algorithms of 'ionic' crypto driver. +; +[Auth] + +; +; Supported AEAD algorithms of 'ionic' crypto driver. +; +[AEAD] +AES GCM (128) = Y +AES GCM (256) = Y + +; +; Supported Asymmetric algorithms of the 'ionic' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'ionic' crypto driver. +; +[OS] +Linux = Y
doc/guides/cryptodevs/index.rst +1 -0
@@ -20,6 +20,7 @@ Crypto Device Drivers cnxk dpaa2_sec dpaa_sec + ionic kasumi octeontx openssl
doc/guides/cryptodevs/ionic.rst new file +39 -0
@@ -0,0 +1,39 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2021-2024 Advanced Micro Devices, Inc. + +IONIC Crypto Driver +=================== + +The ionic crypto driver provides support for offloading cryptographic operations +to hardware cryptographic blocks on AMD Pensando server adapters. +It currently supports the below models: + +- DSC-25 dual-port 25G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKurUAG>`__ +- DSC-100 dual-port 100G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKuwUAG>`__ +- DSC-200 dual-port 200G Distributed Services Card `(pdf) <https://www.amd.com/system/files/documents/pensando-dsc-200-product-brief.pdf>`__ + +Please visit the AMD Pensando web site at https://www.amd.com/en/accelerators/pensando for more information. + +Device Support +-------------- + +The ionic crypto PMD currently supports running directly on the device's embedded +processors. It does not yet support host-side access via PCI. +For help running the PMD, please contact AMD Pensando support. + +Runtime Configuration +--------------------- + +None + +Features +-------- + +The ionic crypto PMD has support for: + +Symmetric Crypto Algorithms +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +AEAD algorithms: + +* ``RTE_CRYPTO_AEAD_AES_GCM``
drivers/crypto/meson.build +1 -0
@@ -10,6 +10,7 @@ drivers = [ 'cnxk', 'dpaa_sec', 'dpaa2_sec', + 'ionic', 'ipsec_mb', 'mlx5', 'mvsam',
Signature · 1 line
2.17.1
Hi Andrew,
Quoted 11 lines
This patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
Andrew Boyer (6):
crypto/ionic: introduce AMD Pensando ionic crypto drivercrypto/ionic: add device and admin command handlers common/ionic: add crypto vdev supportcrypto/ionic: add device object and vdev supportcrypto/ionic: add datapath and capabilities supportcrypto/ionic: add documentation and connect to build
I did not review the patches completely yet,
but the patches are not organized properly.
Your 1st patch says introduce the new driver, But it is just adding a hardware specific header file.
Your 1st patch should add the base framework of the PMD
Which is compiled in the DPDK build system.
You can also add some part of documentation for introducing the new driver. MAINTAINERS file should also be updated for every new directory where it is introduced.
Once you have the base probe and remove added in your first patch,
You can add each of the driver ops in subsequent patches.
You can break queue pair related stuff in a single patch and session related stuff in another one. Capabilities can be a separate patch.
enqueue/dequeue can also be separate patches as well if they are big.
Add documentation changes in each of the patches wherever needed.
You may refer https://patches.dpdk.org/project/dpdk/list/?series=17483&state=%2A&archive=both
Quoted 31 lines
MAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 39 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 361 ++++++++ drivers/crypto/ionic/ionic_crypto_caps.c | 55 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 651 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 993 +++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 606 +++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 +++ drivers/crypto/ionic/meson.build | 16 + drivers/crypto/meson.build | 1 + 16 files changed, 3969 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build--
2.17.1
v2 cover crypto/ionic: introduce AMD Pensando ionic crypto driver
In reply to Andrew BoyerThis patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
V2:
- Remix patches as requested by review
- Fix duplicated logtype global int
- Do some very minor whitespace touchups
Andrew Boyer (9):
crypto/ionic: introduce AMD Pensando ionic crypto driver crypto/ionic: add the firmware interface definition file crypto/ionic: add device commands
crypto/ionic: add adminq command support crypto/ionic: add capabilities and basic ops crypto/ionic: add session support
crypto/ionic: add datapath
crypto/ionic: add a watchdog operation crypto/ionic: add stats support
MAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 39 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 361 ++++++++ drivers/crypto/ionic/ionic_crypto_caps.c | 55 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 650 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 991 +++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 606 +++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 +++ drivers/crypto/ionic/meson.build | 16 + drivers/crypto/meson.build | 1 + 16 files changed, 3966 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build
Signature · 1 line
2.17.1
PATCH v2 1/9 crypto/ionic: introduce AMD Pensando ionic crypto driver
Introduce a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
Add support for the cryptodevs to the common ionic library. Add the driver skeleton.
Add a skeleton features list and guide.
Hook the new PMD up to the build.
Update MAINTAINERS.
--- MAINTAINERS | 7 ++ doc/guides/cryptodevs/features/ionic.ini | 32 +++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 28 +++++ drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +++++++- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 92 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 148 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 91 ++++++++++++++ drivers/crypto/ionic/meson.build | 13 ++ drivers/crypto/meson.build | 1 + 12 files changed, 463 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build
MAINTAINERS +7 -0
@@ -1075,6 +1075,13 @@ F: drivers/crypto/ccp/ F: doc/guides/cryptodevs/ccp.rst F: doc/guides/cryptodevs/features/ccp.ini +AMD Pensando ionic crypto +M: Andrew Boyer <[email protected]> +F: drivers/crypto/ionic/ +F: drivers/common/ionic/ +F: doc/guides/cryptodevs/ionic.rst +F: doc/guides/cryptodevs/features/ionic.ini + ARMv8 Crypto M: Ruifeng Wang <[email protected]> F: drivers/crypto/armv8/
doc/guides/cryptodevs/features/ionic.ini new file +32 -0
@@ -0,0 +1,32 @@ +; +; Supported features of the 'ionic' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] + +; +; Supported crypto algorithms of 'ionic' crypto driver. +; +[Cipher] + +; +; Supported authentication algorithms of 'ionic' crypto driver. +; +[Auth] + +; +; Supported AEAD algorithms of 'ionic' crypto driver. +; +[AEAD] + +; +; Supported Asymmetric algorithms of the 'ionic' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'ionic' crypto driver. +; +[OS] +Linux = Y
doc/guides/cryptodevs/index.rst +1 -0
@@ -20,6 +20,7 @@ Crypto Device Drivers cnxk dpaa2_sec dpaa_sec + ionic kasumi octeontx openssl
doc/guides/cryptodevs/ionic.rst new file +28 -0
@@ -0,0 +1,28 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2021-2024 Advanced Micro Devices, Inc. + +IONIC Crypto Driver +=================== + +The ionic crypto driver provides support for offloading cryptographic operations +to hardware cryptographic blocks on AMD Pensando server adapters. +It currently supports the below models: + +- DSC-25 dual-port 25G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKurUAG>`__ +- DSC-100 dual-port 100G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKuwUAG>`__ +- DSC-200 dual-port 200G Distributed Services Card `(pdf) <https://www.amd.com/system/files/documents/pensando-dsc-200-product-brief.pdf>`__ + +Please visit the AMD Pensando web site at https://www.amd.com/en/accelerators/pensando for more information. + +Device Support +-------------- + +The ionic crypto PMD currently supports running directly on the device's embedded +processors. It does not yet support host-side access via PCI. +For help running the PMD, please contact AMD Pensando support. + +Runtime Configuration +--------------------- + +None +
drivers/common/ionic/ionic_common.h +2 -0
@@ -32,6 +32,8 @@ struct ionic_dev_bar {__rte_internal void ionic_uio_scan_mnet_devices(void); +__rte_internal +void ionic_uio_scan_mcrypt_devices(void);__rte_internal void ionic_uio_get_rsrc(const char *name, int idx, struct ionic_dev_bar *bar);
drivers/common/ionic/ionic_common_uio.c +47 -1
69 lines not on this page · raw message
drivers/common/ionic/version.map +1 -0
@@ -2,6 +2,7 @@ INTERNAL { global: ionic_uio_scan_mnet_devices; + ionic_uio_scan_mcrypt_devices; ionic_uio_get_rsrc; ionic_uio_rel_rsrc;
drivers/crypto/ionic/ionic_crypto.h new file +92 -0
92 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c new file +148 -0
148 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_vdev.c new file +91 -0
91 lines not on this page · raw message
drivers/crypto/ionic/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto' + +includes += include_directories('../../common/ionic')
drivers/crypto/meson.build +1 -0
@@ -10,6 +10,7 @@ drivers = [ 'cnxk', 'dpaa_sec', 'dpaa2_sec', + 'ionic', 'ipsec_mb', 'mlx5', 'mvsam',
Signature · 1 line
2.17.1
Quoted 3 lines
Subject: [EXTERNAL] [PATCH v2 1/9]
crypto/ionic: introduce AMD Pensando ionic crypto driver
Title should be "crypto/ionic: introduce AMD Pensando driver" Do not repeat words in title.
Quoted 7 lines
doc/guides/cryptodevs/ionic.rst new file +5
-0+ +Device Support +-------------- + +The ionic crypto PMD currently supports running directly on the device'sembedded
+processors. It does not yet support host-side access via PCI.
This can be part of driver limitations.
Quoted 27 lines
doc/guides/cryptodevs/ionic.rst new file +7
-0+For help running the PMD, please contact AMD Pensando support. + +Runtime Configuration +--------------------- + +None +drivers/common/ionic/ionic_common.h +2
-0@@ -32,6 +32,8 @@ struct ionic_dev_bar {__rte_internal void ionic_uio_scan_mnet_devices(void); +__rte_internal +void ionic_uio_scan_mcrypt_devices(void);__rte_internal void ionic_uio_get_rsrc(const char *name, int idx, struct ionic_dev_bar *bar);drivers/common/ionic/ionic_common_uio.c +0
-0
drivers/common/ionic/ionic_common_uio.c line 26
Quoted 4 lines
drivers/common/ionic/ionic_common_uio.c +1
-0@@ -23,10 +23,12 @@#define IONIC_MDEV_UNK "mdev_unknown"#define IONIC_MNIC "cpu_mnic" +#define IONIC_MCRYPT "cpu_mcrypt"
Any specific reason for using the word mcrypt. Can we use mcrypto everywhere?
Quoted 241 lines
drivers/common/ionic/ionic_common_uio.c +3
-1#define IONIC_MAX_NAME_LEN 20#define IONIC_MAX_MNETS 5 -#define IONIC_MAX_DEVICES (IONIC_MAX_MNETS) +#define IONIC_MAX_MCPTS 1 +#define IONIC_MAX_DEVICES (IONIC_MAX_MNETS + IONIC_MAX_MCPTS)#define IONIC_MAX_U16_IDX 0xFFFF#define IONIC_UIO_MAX_TRIES 32@@ -49,6 +51,7 @@ struct ionic_map_tbl ionic_mdev_map[IONIC_MAX_DEVICES] = { { "net_ionic2", 2, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, { "net_ionic3", 3, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, { "net_ionic4", 4, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, + { "crypto_ionic0", 5, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, };struct
uio_name{drivers/common/ionic/ionic_common_uio.c +43
-0@@ -143,6 +146,49 @@ ionic_uio_scan_mnet_devices(void) } } +void +ionic_uio_scan_mcrypt_devices (void ) +{ +struct ionic_map_tbl *map; +char devname[IONIC_MAX_NAME_LEN ]; +struct uio_name name_cache[IONIC_MAX_DEVICES ]; +bool done; +int mdev_idx =0 ; +int uio_idx; +int i; +static bool scan_done; + +if (scan_done) +return ; + + scan_done = true; + +uio_fill_name_cache (name_cache,IONIC_MCRYPT ); + +for (i =IONIC_MAX_MNETS ; i <IONIC_MAX_DEVICES ; i++) { + done = false; + +while (!done) { +if (mdev_idx >IONIC_MAX_MDEV_SCAN ) +break ; + +/* Look for a matching mcrypt */ +snprintf (devname,IONIC_MAX_NAME_LEN , +IONIC_MCRYPT "%d" , mdev_idx); + uio_idx =uio_get_idx_for_devname (name_cache, devname); +if (uio_idx >=0 ) { + map = &ionic_mdev_map[i]; + map->uio_idx = (uint16_t )uio_idx; +strlcpy (map->mdev_name, devname, +IONIC_MAX_NAME_LEN ); + done = true; + } + + mdev_idx++; + } + } +} +static int uio_get_multi_dev_uionum (const char *name){
drivers/common/ionic/version.map +1
-0@@ -2,6 +2,7 @@ INTERNAL { global: ionic_uio_scan_mnet_devices; + ionic_uio_scan_mcrypt_devices; ionic_uio_get_rsrc; ionic_uio_rel_rsrc;drivers/crypto/ionic/ionic_crypto.h new file +92
-0@@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#ifndef _IONIC_CRYPTO_H_ +#define _IONIC_CRYPTO_H_ + +#include <stdint.h> +#include <stdbool.h> +#include <inttypes.h> + +#include <rte_common.h> +#include <rte_dev.h> +#include <rte_cryptodev.h> +#include <cryptodev_pmd.h> +#include <rte_log.h> + +#include "ionic_common.h" +#include "ionic_regs.h" + +/* Devargs */ +/* NONE */ + +extern int iocpt_logtype; +#define RTE_LOGTYPE_IOCPT iocpt_logtype + +#define IOCPT_PRINT (level, ...) \ + RTE_LOG_LINE_PREFIX(level, IOCPT, "%s(): ", __func__, __VA_ARGS__) + +#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") + +struct iocpt_dev_bars { +struct ionic_dev_bar bar[IONIC_BARS_MAX ]; +uint32_t num_bars; +}; + +#define IOCPT_DEV_F_INITED BIT(0) +#define IOCPT_DEV_F_UP BIT(1) +#define IOCPT_DEV_F_FW_RESET BIT(2) + +/* Combined dev / LIF object */ +struct iocpt_dev { +const char *name; +struct iocpt_dev_bars bars; + +const struct iocpt_dev_intf *intf; +void *bus_dev; +struct rte_cryptodev *crypto_dev; + +uint32_t max_qps; +uint32_t max_sessions; +uint16_t state; +uint8_t driver_id; +uint8_t socket_id; + +uint64_t features; +uint32_t hw_features; +}; + +struct iocpt_dev_intf { +int (*setup_bars)(struct iocpt_dev *dev); +void (*unmap_bars)(struct iocpt_dev *dev); +}; + +static inline int +iocpt_setup_bars (struct iocpt_dev *dev) +{ +if (dev->intf->setup_bars ==NULL ) +return -EINVAL ; + +return (*dev->intf->setup_bars)(dev); +} + +int iocpt_probe (void *bus_dev,struct rte_device *rte_dev, +struct iocpt_dev_bars *bars,const struct iocpt_dev_intf *intf, +uint8_t driver_id,uint8_t socket_id); +int iocpt_remove (struct rte_device *rte_dev); + +void iocpt_configure (struct iocpt_dev *dev); +void iocpt_deinit (struct iocpt_dev *dev); + +static inline bool +iocpt_is_embedded (void ) +{ +#if defined(RTE_LIBRTE_IONIC_PMD_EMBEDDED ) +return true; +#else +return false; +#endif +} + +#endif /* _IONIC_CRYPTO_H_ */ drivers/crypto/ionic/ionic_crypto_main.c new file +53
-0@@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#include <inttypes.h> + +#include <rte_common.h> +#include <rte_malloc.h> +#include <rte_bitops.h> + +#include "ionic_crypto.h" + +static int +iocpt_init (struct iocpt_dev *dev) +{ + dev->state |=IOCPT_DEV_F_INITED ; + +return 0 ; +} + +void +iocpt_configure (struct iocpt_dev *dev) +{ +RTE_SET_USED (dev); +} + +void +iocpt_deinit (struct iocpt_dev *dev) +{ +IOCPT_PRINT_CALL (); + +if (!(dev->state &IOCPT_DEV_F_INITED )) +return ; + + dev->state &= ~IOCPT_DEV_F_INITED ; +} + +static int +iocpt_devargs (struct rte_devargs *devargs,struct iocpt_dev *dev) +{ +RTE_SET_USED (devargs); +RTE_SET_USED (dev); + +return 0 ; +} + +int +iocpt_probe (void *bus_dev,struct rte_device *rte_dev, +struct iocpt_dev_bars *bars,const struct iocpt_dev_intf *intf, +uint8_t driver_id,uint8_t socket_id) +{ +struct rte_cryptodev_pmd_init_params init_params = { +"iocpt" ,
drivers/crypto/ionic/ionic_crypto_main.c line 63
Quoted 10 lines
drivers/crypto/ionic/ionic_crypto_main.c new file +10
-0+sizeof (struct iocpt_dev ), + socket_id, + RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS + }; +struct rte_cryptodev *cdev; +struct iocpt_dev *dev; +uint32_t i; +int err; + +/* Multi-process not supported */
It may be highlighted in ionic.rst under limitations.
drivers/crypto/ionic/ionic_crypto_main.c line 64
Quoted 1 line
drivers/crypto/ionic/ionic_crypto_main.c new file +1
-0+if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) {
Print missing here?
drivers/crypto/ionic/ionic_crypto_main.c line 71
Quoted 8 lines
drivers/crypto/ionic/ionic_crypto_main.c new file +5
-0+ err = -EPERM ; + goto err; + } + + cdev = rte_cryptodev_pmd_create(rte_dev->name, rte_dev,
&init_params);drivers/crypto/ionic/ionic_crypto_main.c new file +2
-0+if (cdev ==NULL ) { +IOCPT_PRINT (ERR ,"OOM" );
Better to use Out of memory.
Quoted 209 lines
drivers/crypto/ionic/ionic_crypto_main.c new file +77
-0+ err = -ENOMEM ; + goto err; + } + + dev = cdev->data->dev_private; + dev->crypto_dev = cdev; + dev->bus_dev = bus_dev; + dev->intf = intf; + dev->driver_id = driver_id; + dev->socket_id = socket_id; + +for (i =0 ; i < bars->num_bars; i++) { +struct ionic_dev_bar *bar = &bars->bar[i]; + +IOCPT_PRINT (DEBUG , +"bar[%u] = { .va = %p, .pa = %#jx, .len = %lu }" , + i, bar->vaddr, bar->bus_addr, bar->len); +if (bar->vaddr ==NULL ) { +IOCPT_PRINT (ERR ,"Null bar found, aborting" ); + err = -EFAULT ; + goto err_destroy_crypto_dev; + } + + dev->bars.bar[i].vaddr = bar->vaddr; + dev->bars.bar[i].bus_addr = bar->bus_addr; + dev->bars.bar[i].len = bar->len; + } + dev->bars.num_bars = bars->num_bars; + + err =iocpt_devargs (rte_dev->devargs, dev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Cannot parse device arguments" ); + goto err_destroy_crypto_dev; + } + + err =iocpt_setup_bars (dev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Cannot setup BARs: %d, aborting" , err); + goto err_destroy_crypto_dev; + } + + err =iocpt_init (dev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Cannot init device: %d, aborting" , err); + goto err_destroy_crypto_dev; + } + +return 0 ; + +err_destroy_crypto_dev: +rte_cryptodev_pmd_destroy (cdev); +err: +return err; +} + +int +iocpt_remove (struct rte_device *rte_dev) +{ +struct rte_cryptodev *cdev; +struct iocpt_dev *dev; + + cdev =rte_cryptodev_pmd_get_named_dev (rte_dev->name); +if (cdev ==NULL ) { +IOCPT_PRINT (DEBUG ,"Cannot find device %s" , rte_dev->name); +return -ENODEV ; + } + + dev = cdev->data->dev_private; + +iocpt_deinit (dev); + +rte_cryptodev_pmd_destroy (cdev); + +return 0 ; +} + +RTE_LOG_REGISTER_DEFAULT (iocpt_logtype,NOTICE );drivers/crypto/ionic/ionic_crypto_vdev.c new file +90
-0@@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#include <stdint.h> +#include <errno.h> + +#include <rte_errno.h> +#include <rte_common.h> +#include <rte_log.h> +#include <rte_eal.h> +#include <bus_vdev_driver.h> +#include <rte_dev.h> +#include <rte_string_fns.h> + +#include "ionic_crypto.h" + +#define IOCPT_VDEV_DEV_BAR 0 +#define IOCPT_VDEV_INTR_CTL_BAR 1 +#define IOCPT_VDEV_INTR_CFG_BAR 2 +#define IOCPT_VDEV_DB_BAR 3 +#define IOCPT_VDEV_BARS_MAX 4 + +#define IOCPT_VDEV_DEV_INFO_REGS_OFFSET 0x0000 +#define IOCPT_VDEV_DEV_CMD_REGS_OFFSET 0x0800 + +static int +iocpt_vdev_setup_bars (struct iocpt_dev *dev) +{ +IOCPT_PRINT_CALL (); + + dev->name =rte_vdev_device_name (dev->bus_dev); + +return 0 ; +} + +static void +iocpt_vdev_unmap_bars (struct iocpt_dev *dev) +{ +struct iocpt_dev_bars *bars = &dev->bars; +uint32_t i; + +for (i =0 ; i <IOCPT_VDEV_BARS_MAX ; i++) +ionic_uio_rel_rsrc (dev->name, i, &bars->bar[i]); +} + +static uint8_t iocpt_vdev_driver_id; +static const struct iocpt_dev_intf iocpt_vdev_intf = { + .setup_bars = iocpt_vdev_setup_bars, + .unmap_bars = iocpt_vdev_unmap_bars, +}; + +static int +iocpt_vdev_probe (struct rte_vdev_device *vdev) +{ +struct iocpt_dev_bars bars = {}; +const char *name =rte_vdev_device_name (vdev); +unsigned int i; + +IOCPT_PRINT (NOTICE ,"Initializing device %s%s" , name, +rte_eal_process_type () ==RTE_PROC_SECONDARY ? +" [SECONDARY]" :"" ); + +ionic_uio_scan_mcrypt_devices (); + +for (i =0 ; i <IOCPT_VDEV_BARS_MAX ; i++) +ionic_uio_get_rsrc (name, i, &bars.bar[i]); + + bars.num_bars =IOCPT_VDEV_BARS_MAX ; + +return iocpt_probe ((void *)vdev, &vdev->device, + &bars, &iocpt_vdev_intf, + iocpt_vdev_driver_id,rte_socket_id ()); +} + +static int +iocpt_vdev_remove (struct rte_vdev_device *vdev) +{ +return iocpt_remove (&vdev->device); +} + +static struct rte_vdev_driver rte_vdev_iocpt_pmd = { + .probe = iocpt_vdev_probe, + .remove = iocpt_vdev_remove, +}; + +static struct cryptodev_driver rte_vdev_iocpt_drv; + +RTE_PMD_REGISTER_VDEV (crypto_ionic, rte_vdev_iocpt_pmd); +RTE_PMD_REGISTER_CRYPTO_DRIVER(rte_vdev_iocpt_drv,rte_vdev_iocpt_pmd.driver,
drivers/crypto/ionic/ionic_crypto_vdev.c new file +1
-0+ iocpt_vdev_driver_id);drivers/crypto/ionic/meson.build new file +13
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto' + +includes += include_directories('../../common/ionic')drivers/crypto/meson.build +1
-1@@ -10,6 +10,7 @@ drivers = [ 'cnxk', 'dpaa_sec', 'dpaa2_sec', + 'ionic', 'ipsec_mb', 'mlx5', 'mvsam', --2.17.1
On May 30, 2024, at 8:02 AM, Akhil Goyal <[email protected]> wrote:
(quoted diff) +0 -0
b/drivers/common/ionic/ionic_common_uio.c
index e5c73faf96..c647b22eaf 100644
drivers/common/ionic/ionic_common_uio.c +0 -0
@@ -23,10 +23,12 @@
#define IONIC_MDEV_UNK "mdev_unknown"
#define IONIC_MNIC "cpu_mnic"
+#define IONIC_MCRYPT "cpu_mcrypt"
Any specific reason for using the word mcrypt. Can we use mcrypto everywhere?
I will address the others, but we will decline this one because it has kernel change and upgrade/downgrade implications.
-Andrew
You may skip the ones which is common between kernel and DPDK and fix the ones which are specific to DPDK.
From: Boyer, Andrew <[email protected]>
Sent: Wednesday, June 5, 2024 6:57 AM
To: Akhil Goyal <[email protected]>
Cc: Boyer, Andrew <[email protected]>; [email protected]
Subject: Re: [EXTERNAL] [PATCH v2 1/9] crypto/ionic: introduce AMD Pensando ionic crypto driver
On May 30, 2024, at 8:02 AM, Akhil Goyal <[email protected]<mailto:[email protected]>> wrote:
(quoted diff) +0 -0
b/drivers/common/ionic/ionic_common_uio.c
index e5c73faf96..c647b22eaf 100644
drivers/common/ionic/ionic_common_uio.c +0 -0
@@ -23,10 +23,12 @@
#define IONIC_MDEV_UNK "mdev_unknown"
#define IONIC_MNIC "cpu_mnic"
+#define IONIC_MCRYPT "cpu_mcrypt"
Any specific reason for using the word mcrypt. Can we use mcrypto everywhere?
I will address the others, but we will decline this one because it has kernel change and upgrade/downgrade implications.
-Andrew
v3 cover crypto/ionic: introduce AMD Pensando driver
In reply to Andrew BoyerThis patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
V2:
- Remix patches as requested by review
- Fix duplicated logtype global int
- Do some very minor whitespace touchups
V3:
- Address review comments on logging and documentation
Andrew Boyer (9):
crypto/ionic: introduce AMD Pensando driver crypto/ionic: add the firmware interface definition file crypto/ionic: add device commands
crypto/ionic: add adminq command support crypto/ionic: add capabilities and basic ops crypto/ionic: add session support
crypto/ionic: add datapath
crypto/ionic: add a watchdog operation crypto/ionic: add stats support
MAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 45 + doc/guides/rel_notes/release_24_07.rst | 4 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 361 ++++++++ drivers/crypto/ionic/ionic_crypto_caps.c | 55 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 650 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 991 +++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 606 +++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 +++ drivers/crypto/ionic/meson.build | 16 + drivers/crypto/meson.build | 1 + 17 files changed, 3976 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build
Signature · 1 line
2.17.1
PATCH v3 1/9 crypto/ionic: introduce AMD Pensando driver
Introduce a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
Add support for the cryptodevs to the common ionic library. Add the driver skeleton.
Add a skeleton features list and guide.
Hook the new PMD up to the build.
Update MAINTAINERS.
Update release notes.
--- MAINTAINERS | 7 ++ doc/guides/cryptodevs/features/ionic.ini | 32 +++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 33 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +++++++- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 92 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 148 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 91 ++++++++++++++ drivers/crypto/ionic/meson.build | 13 ++ drivers/crypto/meson.build | 1 + 13 files changed, 472 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build
MAINTAINERS +7 -0
@@ -1076,6 +1076,13 @@ F: drivers/crypto/ccp/ F: doc/guides/cryptodevs/ccp.rst F: doc/guides/cryptodevs/features/ccp.ini +AMD Pensando ionic crypto +M: Andrew Boyer <[email protected]> +F: drivers/crypto/ionic/ +F: drivers/common/ionic/ +F: doc/guides/cryptodevs/ionic.rst +F: doc/guides/cryptodevs/features/ionic.ini + ARMv8 Crypto M: Ruifeng Wang <[email protected]> F: drivers/crypto/armv8/
doc/guides/cryptodevs/features/ionic.ini new file +32 -0
@@ -0,0 +1,32 @@ +; +; Supported features of the 'ionic' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] + +; +; Supported crypto algorithms of 'ionic' crypto driver. +; +[Cipher] + +; +; Supported authentication algorithms of 'ionic' crypto driver. +; +[Auth] + +; +; Supported AEAD algorithms of 'ionic' crypto driver. +; +[AEAD] + +; +; Supported Asymmetric algorithms of the 'ionic' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'ionic' crypto driver. +; +[OS] +Linux = Y
doc/guides/cryptodevs/index.rst +1 -0
@@ -20,6 +20,7 @@ Crypto Device Drivers cnxk dpaa2_sec dpaa_sec + ionic kasumi octeontx openssl
doc/guides/cryptodevs/ionic.rst new file +33 -0
@@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2021-2024 Advanced Micro Devices, Inc. + +IONIC Crypto Driver +=================== + +The ionic crypto driver provides support for offloading cryptographic operations +to hardware cryptographic blocks on AMD Pensando server adapters. +It currently supports the below models: + +- DSC-25 dual-port 25G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKurUAG>`__ +- DSC-100 dual-port 100G Distributed Services Card `(pdf) <https://pensandoio.secure.force.com/DownloadFile?id=a0L4T000004IKuwUAG>`__ +- DSC-200 dual-port 200G Distributed Services Card `(pdf) <https://www.amd.com/system/files/documents/pensando-dsc-200-product-brief.pdf>`__ + +Please visit the AMD Pensando web site at https://www.amd.com/en/accelerators/pensando for more information. + +Device Support +-------------- + +The ionic crypto driver currently supports running directly on the device's embedded +processors. For help running the driver, please contact AMD Pensando support. + +Limitations +----------- + +- Host-side access via PCI is not yet supported +- Multiprocess applications are not yet supported + +Runtime Configuration +--------------------- + +None +
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -24,6 +24,10 @@ DPDK Release 24.07 New Features ------------ +* **Added AMD Pensando ionic crypto driver.** + + Added a new crypto driver for AMD Pensando hardware accelerators. + .. This section should contain new features added in this release. Sample format:
drivers/common/ionic/ionic_common.h +2 -0
@@ -32,6 +32,8 @@ struct ionic_dev_bar {__rte_internal void ionic_uio_scan_mnet_devices(void); +__rte_internal +void ionic_uio_scan_mcrypt_devices(void);__rte_internal void ionic_uio_get_rsrc(const char *name, int idx, struct ionic_dev_bar *bar);
drivers/common/ionic/ionic_common_uio.c +47 -1
69 lines not on this page · raw message
drivers/common/ionic/version.map +1 -0
@@ -2,6 +2,7 @@ INTERNAL { global: ionic_uio_scan_mnet_devices; + ionic_uio_scan_mcrypt_devices; ionic_uio_get_rsrc; ionic_uio_rel_rsrc;
drivers/crypto/ionic/ionic_crypto.h new file +92 -0
92 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c new file +148 -0
148 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_vdev.c new file +91 -0
91 lines not on this page · raw message
drivers/crypto/ionic/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto' + +includes += include_directories('../../common/ionic')
drivers/crypto/meson.build +1 -0
@@ -10,6 +10,7 @@ drivers = [ 'cnxk', 'dpaa_sec', 'dpaa2_sec', + 'ionic', 'ipsec_mb', 'mlx5', 'mvsam',
Signature · 1 line
2.17.1
RE: [EXTERNAL] [PATCH v3 1/9] crypto/ionic: introduce AMD Pensando driver
Quoted 7 lines
drivers/crypto/ionic/meson.build new file +1
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause
drivers/crypto/ionic/meson.build line 11
Quoted 10 lines
drivers/crypto/ionic/meson.build new file +10
-0+# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto'
Why do you explicitly add name here?
I believe driver name as ionic should be ok. All other PMDs which have common name in net/crypto do not need to add _crypto namespace.
If you don't have objections, I can fix it while merging.
Re: [EXTERNAL] [PATCH v3 1/9] crypto/ionic: introduce AMD Pensando driver
Quoted 27 lines · Akhil Goyal
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 7 lines
drivers/crypto/ionic/meson.build new file +1
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clausedrivers/crypto/ionic/meson.build line 11
Quoted 10 lines
drivers/crypto/ionic/meson.build new file +10
-0+# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto'Why do you explicitly add name here?
Quoted 6 lines
I believe driver name as ionic should be ok. All other PMDs which have common name in net/crypto do not need to add
_cryptonamespace.If you don't have objections, I can fix it while merging.
That's fine. Please fix it up.
Thank you!
Andrew
Akhil Goyal
AppliedRE: [EXTERNAL] [PATCH v3 1/9] crypto/ionic: introduce AMD Pensando driver
Quoted 25 lines
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/crypto/ionic/meson.build
Quoted 23 lines
Quoted 6 lines
new file mode 100644
index 0000000000..4114e13e53drivers/crypto/ionic/meson.build new file +1
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clausedrivers/crypto/ionic/meson.build line 11
Quoted 10 lines
drivers/crypto/ionic/meson.build new file +10
-0+# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto'Why do you explicitly add name here?
I believe driver name as ionic should be ok. All other PMDs which have common name in net/crypto do not need to add
_cryptonamespace.
Quoted 6 lines
Quoted 2 lines
If you don't have objections, I can fix it while merging.
That's fine. Please fix it up.
Series Acked-by: Akhil Goyal <[email protected]>
Applied to dpdk-next-crypto
Thanks.
PATCH v3 2/9 crypto/ionic: add the firmware interface definition file
In reply to Andrew BoyerThese definitions are shared between the PMD and firmware. Teach the device to read the FW version and check for liveness.
--- drivers/crypto/ionic/ionic_crypto.h | 53 ++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 17 +- drivers/crypto/ionic/ionic_crypto_vdev.c | 37 + 4 files changed, 1127 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h
drivers/crypto/ionic/ionic_crypto.h +53 -0
@@ -16,6 +16,7 @@#include <rte_log.h> #include "ionic_common.h" +#include "ionic_crypto_if.h" #include "ionic_regs.h" /* Devargs */
@@ -29,6 +30,51 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +static inline void iocpt_struct_size_checks (void ) +{ +RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr_status ) !=8 ); + +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_regs ) !=4096 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_info_regs ) !=2048 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_cmd_regs ) !=2048 ); + +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_comp ) !=16 ); + +/* Device commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_comp ) !=16 ); + +/* LIF commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_comp ) !=16 ); + +/* Queue commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_control_cmd ) !=64 ); + +/* Crypto */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_desc ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_sg_desc ) !=256 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_comp ) !=16 ); +} +struct iocpt_dev_bars {struct ionic_dev_bar bar[IONIC_BARS_MAX ];uint32_t num_bars;
@@ -41,12 +87,19 @@ struct iocpt_dev_bars {/* Combined dev / LIF object */ struct iocpt_dev {const char *name; +char fw_version[IOCPT_FWVERS_BUFLEN ];struct iocpt_dev_bars bars;const struct iocpt_dev_intf *intf;void *bus_dev;struct rte_cryptodev *crypto_dev; +union iocpt_dev_info_regs __iomem *dev_info; +union iocpt_dev_cmd_regs __iomem *dev_cmd; + +struct ionic_doorbell __iomem *db_pages; +struct ionic_intr __iomem *intr_ctrl; +uint32_t max_qps;uint32_t max_sessions;uint16_t state;
drivers/crypto/ionic/ionic_crypto_if.h new file +1021 -0
1,021 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +16 -1
@@ -57,9 +57,12 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, };struct rte_cryptodev *cdev;struct iocpt_dev *dev; -uint32_t i; +uint32_t i, sig;int err; +/* Check structs (trigger error at compilation time) */ +iocpt_struct_size_checks (); +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) {IOCPT_PRINT (ERR ,"Multi-process not supported" ); err = -EPERM ;
@@ -110,6 +113,18 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, goto err_destroy_crypto_dev; } + sig =ioread32 (&dev->dev_info->signature); +if (sig !=IOCPT_DEV_INFO_SIGNATURE ) { +IOCPT_PRINT (ERR ,"Incompatible firmware signature %#x" , sig); + err = -EFAULT ; + goto err_destroy_crypto_dev; + } + +for (i =0 ; i <IOCPT_FWVERS_BUFLEN ; i++) + dev->fw_version[i] =ioread8 (&dev->dev_info->fw_version[i]); + dev->fw_version[IOCPT_FWVERS_BUFLEN -1 ] ='\0' ; +IOCPT_PRINT (DEBUG ,"%s firmware: %s" , dev->name, dev->fw_version); + err =iocpt_init (dev);if (err !=0 ) {IOCPT_PRINT (ERR ,"Cannot init device: %d, aborting" , err);
drivers/crypto/ionic/ionic_crypto_vdev.c +37 -0
@@ -24,11 +24,48 @@#define IOCPT_VDEV_DEV_INFO_REGS_OFFSET 0x0000#define IOCPT_VDEV_DEV_CMD_REGS_OFFSET 0x0800 +#define IOCPT_VDEV_FW_WAIT_US 1000/* 1ms */ +#define IOCPT_VDEV_FW_WAIT_MAX 5000/* 5s */ +static int iocpt_vdev_setup_bars (struct iocpt_dev *dev) { +struct iocpt_dev_bars *bars = &dev->bars; +uint8_t *bar0_base; +uint32_t fw_waits =0 ; +uint8_t fw; +IOCPT_PRINT_CALL (); +/* BAR0: dev_cmd */ + bar0_base = bars->bar[IOCPT_VDEV_DEV_BAR ].vaddr; + dev->dev_info = (union iocpt_dev_info_regs *) + &bar0_base[IOCPT_VDEV_DEV_INFO_REGS_OFFSET ]; + dev->dev_cmd = (union iocpt_dev_cmd_regs *) + &bar0_base[IOCPT_VDEV_DEV_CMD_REGS_OFFSET ]; + +/* BAR1: interrupts */ + dev->intr_ctrl = (void *)bars->bar[IOCPT_VDEV_INTR_CTL_BAR ].vaddr; + +/* BAR3: doorbells */ + dev->db_pages = (void *)bars->bar[IOCPT_VDEV_DB_BAR ].vaddr; + +/* Wait for the FW to indicate readiness */ +while (1 ) { + fw =ioread8 (&dev->dev_info->fw_status); +if ((fw &IOCPT_FW_STS_F_RUNNING ) !=0 ) +break ; + +if (fw_waits >IOCPT_VDEV_FW_WAIT_MAX ) { +IOCPT_PRINT (ERR ,"Firmware readiness bit not set" ); +return -ETIMEDOUT ; + } + + fw_waits++; +rte_delay_us_block (IOCPT_VDEV_FW_WAIT_US ); + } +IOCPT_PRINT (DEBUG ,"Firmware ready (%u waits)" , fw_waits); + dev->name =rte_vdev_device_name (dev->bus_dev);return 0 ;
Signature · 1 line
2.17.1
PATCH v3 3/9 crypto/ionic: add device commands
In reply to Andrew BoyerThis defines the device (register-based) commands. They are used for device identification, setup, and teardown.
--- drivers/crypto/ionic/ionic_crypto.h | 24 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 348 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 89 +++++- drivers/crypto/ionic/meson.build | 1 + 4 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c
drivers/crypto/ionic/ionic_crypto.h +24 -0
@@ -80,6 +80,17 @@ struct iocpt_dev_bars {uint32_t num_bars; }; +struct iocpt_qtype_info { +uint8_t version; +uint8_t supported; +uint64_t features; +uint16_t desc_sz; +uint16_t comp_sz; +uint16_t sg_desc_sz; +uint16_t max_sg_elems; +uint16_t sg_desc_stride; +}; +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -89,6 +100,7 @@ struct iocpt_dev {const char *name;char fw_version[IOCPT_FWVERS_BUFLEN ];struct iocpt_dev_bars bars; +struct iocpt_identity ident;const struct iocpt_dev_intf *intf;void *bus_dev;
@@ -108,6 +120,14 @@ struct iocpt_dev {uint64_t features;uint32_t hw_features; + +uint32_t info_sz; +struct iocpt_lif_info *info; +rte_iova_t info_pa; +const struct rte_memzone *info_z; + +struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX ]; +uint8_t qtype_ver[IOCPT_QTYPE_MAX ]; };struct iocpt_dev_intf {
@@ -132,6 +152,10 @@ int iocpt_remove(struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev);void iocpt_deinit (struct iocpt_dev *dev); +int iocpt_dev_identify (struct iocpt_dev *dev); +int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa); +void iocpt_dev_reset (struct iocpt_dev *dev); +static inline bool iocpt_is_embedded (void ) {
drivers/crypto/ionic/ionic_crypto_cmds.c new file +348 -0
348 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +88 -1
123 lines not on this page · raw message
drivers/crypto/ionic/meson.build +1 -0
@@ -5,6 +5,7 @@ deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( + 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', 'ionic_crypto_vdev.c', )
Signature · 1 line
2.17.1
PATCH v3 4/9 crypto/ionic: add adminq command support
In reply to Andrew BoyerThis defines the adminq used for control path commands. The adminq is faster and more flexible than the device command interface.
--- drivers/crypto/ionic/ionic_crypto.h | 115 +++++++++ drivers/crypto/ionic/ionic_crypto_cmds.c | 302 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 295 +++++++++++++++++++++- 3 files changed, 711 insertions(+), 1 deletion(-)
drivers/crypto/ionic/ionic_crypto.h +115 -0
@@ -22,6 +22,10 @@/* Devargs */ /* NONE */ +#define IOCPT_MAX_RING_DESC 32768 +#define IOCPT_MIN_RING_DESC 16 +#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ +extern int iocpt_logtype;#define RTE_LOGTYPE_IOCPT iocpt_logtype
@@ -91,6 +95,63 @@ struct iocpt_qtype_info {uint16_t sg_desc_stride; }; +#define IOCPT_Q_F_INITED BIT(0) +#define IOCPT_Q_F_DEFERRED BIT(1) +#define IOCPT_Q_F_SG BIT(2) + +#define Q_NEXT_TO_POST (_q, _n) (((_q)->head_idx + (_n)) & ((_q)->size_mask)) +#define Q_NEXT_TO_SRVC (_q, _n) (((_q)->tail_idx + (_n)) & ((_q)->size_mask)) + +#define IOCPT_INFO_SZ (_q) ((_q)->num_segs * sizeof(void *)) +#define IOCPT_INFO_IDX (_q, _i) ((_i) * (_q)->num_segs) +#define IOCPT_INFO_PTR (_q, _i) (&(_q)->info[IOCPT_INFO_IDX((_q), _i)]) + +struct iocpt_queue { +uint16_t num_descs; +uint16_t num_segs; +uint16_t head_idx; +uint16_t tail_idx; +uint16_t size_mask; +uint8_t type; +uint8_t hw_type; +void *base; +void *sg_base; +struct ionic_doorbell __iomem *db; +void **info; + +uint32_t index; +uint32_t hw_index; +rte_iova_t base_pa; +rte_iova_t sg_base_pa; +}; + +struct iocpt_cq { +uint16_t tail_idx; +uint16_t num_descs; +uint16_t size_mask; +bool done_color; +void *base; +rte_iova_t base_pa; +}; + +#define IOCPT_COMMON_FIELDS \ + struct iocpt_queue q; \ + struct iocpt_cq cq; \ + struct iocpt_dev *dev; \ + const struct rte_memzone *base_z; \ + void *base; \ + rte_iova_t base_pa + +struct iocpt_common_q { +IOCPT_COMMON_FIELDS ; +}; + +struct iocpt_admin_q { +IOCPT_COMMON_FIELDS ; + +uint16_t flags; +}; +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -118,6 +179,11 @@ struct iocpt_dev {uint8_t driver_id;uint8_t socket_id; +rte_spinlock_t adminq_lock; +rte_spinlock_t adminq_service_lock; + +struct iocpt_admin_q *adminq; +uint64_t features;uint32_t hw_features;
@@ -144,6 +210,17 @@ iocpt_setup_bars(struct iocpt_dev *dev)return (*dev->intf->setup_bars)(dev); } +/** iocpt_admin_ctx - Admin command context. +* @pending_work: Flag that indicates a completion. +* @cmd: Admin command (64B) to be copied to the queue. +* @comp: Admin completion (16B) copied from the queue. +*/ +struct iocpt_admin_ctx { +bool pending_work; +union iocpt_adminq_cmd cmd; +union iocpt_adminq_comp comp; +}; +int iocpt_probe (void *bus_dev,struct rte_device *rte_dev,struct iocpt_dev_bars *bars,const struct iocpt_dev_intf *intf,uint8_t driver_id,uint8_t socket_id);
@@ -154,8 +231,46 @@ void iocpt_deinit(struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa); +int iocpt_dev_adminq_init (struct iocpt_dev *dev);void iocpt_dev_reset (struct iocpt_dev *dev); +int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); + +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev, +struct iocpt_queue *q); + +typedef bool (*iocpt_cq_cb )(struct iocpt_cq *cq,uint16_t cq_desc_index, +void *cb_arg); +uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do, +iocpt_cq_cb cb,void *cb_arg); + +static inline uint16_t +iocpt_q_space_avail (struct iocpt_queue *q) +{ +uint16_t avail = q->tail_idx; + +if (q->head_idx >= avail) + avail += q->num_descs - q->head_idx -1 ; +else + avail -= q->head_idx +1 ; + +return avail; +} + +static inline void +iocpt_q_flush (struct iocpt_queue *q) +{ +uint64_t val =IONIC_DBELL_QID (q->hw_index) | q->head_idx; + +#if defined(RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA ) +/* On some devices the standard 'dmb' barrier is insufficient */ + asmvolatile ("dsb st" : : :"memory" ); +rte_write64_relaxed (rte_cpu_to_le_64 (val), q->db); +#else +rte_write64 (rte_cpu_to_le_64 (val), q->db); +#endif +} +static inline bool iocpt_is_embedded (void ) {
drivers/crypto/ionic/ionic_crypto_cmds.c +302 -0
323 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +294 -1
343 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 5/9 crypto/ionic: add capabilities and basic ops
In reply to Andrew BoyerThis exposes the supported capabilities to the stack.
--- drivers/crypto/ionic/ionic_crypto.h | 3 ++ drivers/crypto/ionic/ionic_crypto_caps.c | 25 +++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 8 +++ drivers/crypto/ionic/ionic_crypto_ops.c | 66 ++++++++++++++++++++++++ drivers/crypto/ionic/meson.build | 2 + 5 files changed, 104 insertions(+) create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c
drivers/crypto/ionic/ionic_crypto.h +3 -0
@@ -34,6 +34,8 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +const struct rte_cryptodev_capabilities *iocpt_get_caps (uint64_t flags); +static inline void iocpt_struct_size_checks (void ) {RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 );
@@ -227,6 +229,7 @@ int iocpt_probe(void *bus_dev, struct rte_device *rte_dev,int iocpt_remove (struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev); +int iocpt_assign_ops (struct rte_cryptodev *cdev);void iocpt_deinit (struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);
drivers/crypto/ionic/ionic_crypto_caps.c new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#include <rte_cryptodev.h> + +#include "ionic_crypto.h" + +static const struct rte_cryptodev_capabilities iocpt_sym_caps[] = { +RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () +}; + +static const struct rte_cryptodev_capabilities iocpt_asym_caps[] = { +/* None */ +RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () +}; + +const struct rte_cryptodev_capabilities * +iocpt_get_caps (uint64_t flags) +{ +if (flags &RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO ) +return iocpt_asym_caps; +else +return iocpt_sym_caps; +}
drivers/crypto/ionic/ionic_crypto_main.c +8 -0
@@ -505,8 +505,16 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, goto err_free_objs; } + err =iocpt_assign_ops (cdev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Failed to configure opts" ); + goto err_deinit_dev; + } +return 0 ; +err_deinit_dev: +iocpt_deinit (dev); err_free_objs:iocpt_free_objs (dev); err_destroy_crypto_dev:
drivers/crypto/ionic/ionic_crypto_ops.c new file +66 -0
66 lines not on this page · raw message
drivers/crypto/ionic/meson.build +2 -0
@@ -5,8 +5,10 @@ deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( + 'ionic_crypto_caps.c', 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', + 'ionic_crypto_ops.c', 'ionic_crypto_vdev.c', ) name = 'ionic_crypto'
Signature · 1 line
2.17.1
PATCH v3 6/9 crypto/ionic: add session support
In reply to Andrew BoyerThis defines the session object and related commands.
--- drivers/crypto/ionic/ionic_crypto.h | 33 ++++++ drivers/crypto/ionic/ionic_crypto_main.c | 143 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 123 +++++++++++++++++++ 3 files changed, 299 insertions(+)
drivers/crypto/ionic/ionic_crypto.h +33 -0
@@ -14,6 +14,7 @@#include <rte_cryptodev.h> #include <cryptodev_pmd.h> #include <rte_log.h> +#include <rte_bitmap.h> #include "ionic_common.h" #include "ionic_crypto_if.h"
@@ -154,6 +155,32 @@ struct iocpt_admin_q {uint16_t flags; }; +#define IOCPT_S_F_INITED BIT(0) + +struct iocpt_session_priv { +struct iocpt_dev *dev; + +uint32_t index; + +uint16_t iv_offset; +uint16_t iv_length; +uint16_t digest_length; +uint16_t aad_length; + +uint8_t flags; +uint8_t op; +uint8_t type; + +uint16_t key_len; +uint8_t key[IOCPT_SESS_KEY_LEN_MAX_SYMM ]; +}; + +static inline uint32_t +iocpt_session_size (void ) +{ +return sizeof (struct iocpt_session_priv ); +} +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -186,6 +213,8 @@ struct iocpt_dev {struct iocpt_admin_q *adminq; +struct rte_bitmap *sess_bm;/* SET bit indicates index is free */ +uint64_t features;uint32_t hw_features;
@@ -239,6 +268,10 @@ void iocpt_dev_reset(struct iocpt_dev *dev);int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); +int iocpt_session_init (struct iocpt_session_priv *priv); +int iocpt_session_update (struct iocpt_session_priv *priv); +void iocpt_session_deinit (struct iocpt_session_priv *priv); +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev,struct iocpt_queue *q);
drivers/crypto/ionic/ionic_crypto_main.c +143 -0
169 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +123 -0
133 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 7/9 crypto/ionic: add datapath
In reply to Andrew BoyerThis defines the main crypto operation enqueue and dequeue handlers.
--- doc/guides/cryptodevs/features/ionic.ini | 8 + doc/guides/cryptodevs/ionic.rst | 12 + drivers/crypto/ionic/ionic_crypto.h | 17 ++ drivers/crypto/ionic/ionic_crypto_caps.c | 30 +++ drivers/crypto/ionic/ionic_crypto_main.c | 222 ++++++++++++++++- drivers/crypto/ionic/ionic_crypto_ops.c | 295 +++++++++++++++++++++++ 6 files changed, 582 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/ionic.ini +8 -0
@@ -4,6 +4,12 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Symmetric crypto = Y +HW Accelerated = Y +In Place SGL = Y +OOP SGL In LB Out = Y +OOP SGL In SGL Out = Y +OOP LB In LB Out = Y ; ; Supported crypto algorithms of 'ionic' crypto driver.
@@ -19,6 +25,8 @@ ; Supported AEAD algorithms of 'ionic' crypto driver. ; [AEAD] +AES GCM (128) = Y +AES GCM (256) = Y ; ; Supported Asymmetric algorithms of the 'ionic' crypto driver.
doc/guides/cryptodevs/ionic.rst +12 -0
@@ -25,9 +25,21 @@ Limitations - Host-side access via PCI is not yet supported - Multiprocess applications are not yet supported +- Sessionless APIs are not yet supported Runtime Configuration --------------------- None +Features +-------- + +The ionic crypto PMD has support for: + +Symmetric Crypto Algorithms +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +AEAD algorithms: + +* ``RTE_CRYPTO_AEAD_AES_GCM``
drivers/crypto/ionic/ionic_crypto.h +17 -0
@@ -27,6 +27,8 @@#define IOCPT_MIN_RING_DESC 16#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ +#define IOCPT_CRYPTOQ_WAIT 10/* 1s */ +extern int iocpt_logtype;#define RTE_LOGTYPE_IOCPT iocpt_logtype
@@ -155,6 +157,14 @@ struct iocpt_admin_q {uint16_t flags; }; +struct iocpt_crypto_q { +/* cacheline0, cacheline1 */ +IOCPT_COMMON_FIELDS ; + +/* cacheline2 */ +uint16_t flags; +}; +#define IOCPT_S_F_INITED BIT(0)struct iocpt_session_priv {
@@ -212,6 +222,7 @@ struct iocpt_dev {rte_spinlock_t adminq_service_lock;struct iocpt_admin_q *adminq; +struct iocpt_crypto_q **cryptoqs;struct rte_bitmap *sess_bm;/* SET bit indicates index is free */
@@ -259,6 +270,8 @@ int iocpt_remove(struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev);int iocpt_assign_ops (struct rte_cryptodev *cdev); +int iocpt_start (struct iocpt_dev *dev); +void iocpt_stop (struct iocpt_dev *dev);void iocpt_deinit (struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);
@@ -268,6 +281,10 @@ void iocpt_dev_reset(struct iocpt_dev *dev);int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); +int iocpt_cryptoq_alloc (struct iocpt_dev *dev,uint32_t socket_id, +uint32_t index,uint16_t ndescs); +void iocpt_cryptoq_free (struct iocpt_crypto_q *cptq); +int iocpt_session_init (struct iocpt_session_priv *priv);int iocpt_session_update (struct iocpt_session_priv *priv);void iocpt_session_deinit (struct iocpt_session_priv *priv);
drivers/crypto/ionic/ionic_crypto_caps.c +30 -0
@@ -7,6 +7,36 @@#include "ionic_crypto.h" static const struct rte_cryptodev_capabilities iocpt_sym_caps[] = { + {/* AES GCM */ + .op =RTE_CRYPTO_OP_TYPE_SYMMETRIC , + {.sym = { + .xform_type =RTE_CRYPTO_SYM_XFORM_AEAD , + {.aead = { + .algo =RTE_CRYPTO_AEAD_AES_GCM , + .block_size =16 , + .key_size = { + .min =16 , + .max =32 , + .increment =16 + }, + .digest_size = { + .min =16 , + .max =16 , + .increment =0 + }, + .aad_size = { + .min =0 , + .max =1024 , + .increment =1 + }, + .iv_size = { + .min =12 , + .max =12 , + .increment =0 + } + }, } + }, } + },RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () };
drivers/crypto/ionic/ionic_crypto_main.c +220 -2
284 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +295 -0
323 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 8/9 crypto/ionic: add a watchdog operation
In reply to Andrew BoyerIf no progress has been made within the timeout, post a dummy operation using session 0. This will restart the queue in the rare case that a doorbell is lost inside the device.
--- drivers/crypto/ionic/ionic_crypto.h | 16 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 31 ++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 97 +++++++++++++++++++++++- 3 files changed, 142 insertions(+), 2 deletions(-)
drivers/crypto/ionic/ionic_crypto.h +16 -0
@@ -89,6 +89,14 @@ struct iocpt_dev_bars {uint32_t num_bars; }; +/* Queue watchdog */ +#define IOCPT_Q_WDOG_SESS_IDX 0 +#define IOCPT_Q_WDOG_KEY_LEN 16 +#define IOCPT_Q_WDOG_IV_LEN 12 +#define IOCPT_Q_WDOG_PLD_LEN 4 +#define IOCPT_Q_WDOG_TAG_LEN 16 +#define IOCPT_Q_WDOG_OP_TYPE RTE_CRYPTO_OP_TYPE_UNDEFINED +struct iocpt_qtype_info {uint8_t version;uint8_t supported;
@@ -162,7 +170,15 @@ struct iocpt_crypto_q {IOCPT_COMMON_FIELDS ;/* cacheline2 */ +uint64_t last_wdog_cycles;uint16_t flags; + +/* cacheline3 */ +uint64_t enqueued_wdogs; +uint64_t dequeued_wdogs; +uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN ]; +uint8_t wdog_pld[IOCPT_Q_WDOG_PLD_LEN ]; +uint8_t wdog_tag[IOCPT_Q_WDOG_TAG_LEN ]; };#define IOCPT_S_F_INITED BIT(0)
drivers/crypto/ionic/ionic_crypto_main.c +31 -0
@@ -172,6 +172,22 @@ iocpt_session_write(struct iocpt_session_priv *priv,return 0 ; } +static int +iocpt_session_wdog (struct iocpt_dev *dev) +{ +struct iocpt_session_priv priv = { + .dev = dev, + .index =IOCPT_Q_WDOG_SESS_IDX , + .type =IOCPT_SESS_AEAD_AES_GCM , + .key_len =IOCPT_Q_WDOG_KEY_LEN , + }; + +/* Reserve session 0 for queue watchdog */ +rte_bitmap_clear (dev->sess_bm,IOCPT_Q_WDOG_SESS_IDX ); + +return iocpt_session_write (&priv,IOCPT_SESS_INIT ); +} +int iocpt_session_init (struct iocpt_session_priv *priv) {
@@ -491,6 +507,9 @@ iocpt_cryptoq_deinit(struct iocpt_crypto_q *cptq)IOCPT_PRINT (DEBUG ,"Deinit queue %u returned %d after %u ms" , cptq->q.index, err, sleep_cnt *100 ); +IOCPT_PRINT (DEBUG ,"Queue %u watchdog: enq %" PRIu64" deq %" PRIu64, + cptq->q.index, cptq->enqueued_wdogs, cptq->dequeued_wdogs); + cptq->flags &= ~IOCPT_Q_F_INITED ; }
@@ -659,9 +678,21 @@ iocpt_init(struct iocpt_dev *dev)if (err !=0 )return err; +/* Write the queue watchdog key */ + err =iocpt_session_wdog (dev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Cannot setup watchdog session" ); + goto err_out_adminq_deinit; + } + dev->state |=IOCPT_DEV_F_INITED ;return 0 ; + +err_out_adminq_deinit: +iocpt_adminq_deinit (dev); + +return err; }void
drivers/crypto/ionic/ionic_crypto_ops.c +95 -2
132 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 9/9 crypto/ionic: add stats support
In reply to Andrew BoyerThis defines the stats handlers and exposes them to the stack.
--- drivers/crypto/ionic/ionic_crypto.h | 8 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 48 ++++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 33 +++++++++++++++- 3 files changed, 87 insertions(+), 2 deletions(-)
drivers/crypto/ionic/ionic_crypto.h +8 -0
@@ -174,6 +174,8 @@ struct iocpt_crypto_q {uint16_t flags;/* cacheline3 */ +struct rte_cryptodev_stats stats; +uint64_t enqueued_wdogs;uint64_t dequeued_wdogs;uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN ];
@@ -252,6 +254,8 @@ struct iocpt_dev {struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX ];uint8_t qtype_ver[IOCPT_QTYPE_MAX ]; + +struct rte_cryptodev_stats stats_base; };struct iocpt_dev_intf {
@@ -313,6 +317,10 @@ typedef bool (*iocpt_cq_cb)(struct iocpt_cq *cq, uint16_t cq_desc_index,uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do,iocpt_cq_cb cb,void *cb_arg); +void iocpt_get_stats (const struct iocpt_dev *dev, +struct rte_cryptodev_stats *stats); +void iocpt_reset_stats (struct iocpt_dev *dev); +static inline uint16_t iocpt_q_space_avail (struct iocpt_queue *q) {
drivers/crypto/ionic/ionic_crypto_main.c +48 -0
60 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +31 -2
@@ -65,6 +65,23 @@ iocpt_op_info_get(struct rte_cryptodev *cdev, struct rte_cryptodev_info *info) info->min_mbuf_tailroom_req =0 ; } +static void +iocpt_op_stats_get (struct rte_cryptodev *cdev, +struct rte_cryptodev_stats *stats) +{ +struct iocpt_dev *dev = cdev->data->dev_private; + +iocpt_get_stats (dev, stats); +} + +static void +iocpt_op_stats_reset (struct rte_cryptodev *cdev) +{ +struct iocpt_dev *dev = cdev->data->dev_private; + +iocpt_reset_stats (dev); +} +static int iocpt_op_queue_release (struct rte_cryptodev *cdev,uint16_t queue_id) {
@@ -350,6 +367,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)struct iocpt_crypto_q *cptq = qp;struct rte_crypto_op *op;struct iocpt_session_priv *priv; +struct rte_cryptodev_stats *stats = &cptq->stats;uint16_t avail, count;int err;
@@ -375,6 +393,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops) err =iocpt_enq_one_aead (cptq, priv, op);if (unlikely (err !=0 )) { op->status =RTE_CRYPTO_OP_STATUS_INVALID_ARGS ; + stats->enqueue_err_count++;break ; }
@@ -386,6 +405,8 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)/* Restart timer if ops are being enqueued */ cptq->last_wdog_cycles =rte_get_timer_cycles (); + + stats->enqueued_count += count; }return count;
@@ -439,8 +460,8 @@ iocpt_enqueue_wdog(struct iocpt_crypto_q *cptq) q->info[q->head_idx] = wdog_op; q->head_idx =Q_NEXT_TO_POST (q,1 ); -IOCPT_PRINT (DEBUG ,"Queue %u wdog enq %p" , - q->index, wdog_op); +IOCPT_PRINT (DEBUG ,"Queue %u wdog enq %p ops %" PRIu64, + q->index, wdog_op, cptq->stats.enqueued_count); cptq->enqueued_wdogs++; out_flush:
@@ -456,6 +477,7 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)struct rte_crypto_op *op;struct iocpt_crypto_comp *cq_desc_base = cq->base;volatile struct iocpt_crypto_comp *cq_desc; +struct rte_cryptodev_stats *stats = &cptq->stats;uint64_t then, now, hz, delta;uint16_t count =0 ;
@@ -515,6 +537,9 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)continue ; } +if (unlikely (op->status !=RTE_CRYPTO_OP_STATUS_SUCCESS )) + stats->dequeue_err_count++; + ops[count] = op; q->info[q->tail_idx] =NULL ;
@@ -542,6 +567,8 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)/* Restart timer if the queue is making progress */ cptq->last_wdog_cycles =rte_get_timer_cycles (); + stats->dequeued_count += count; +return count; }
@@ -552,6 +579,8 @@ static struct rte_cryptodev_ops iocpt_ops = { .dev_close = iocpt_op_close, .dev_infos_get = iocpt_op_info_get, + .stats_get = iocpt_op_stats_get, + .stats_reset = iocpt_op_stats_reset, .queue_pair_setup = iocpt_op_queue_setup, .queue_pair_release = iocpt_op_queue_release,
Signature · 1 line
2.17.1
PATCH v2 2/9 crypto/ionic: add the firmware interface definition file
In reply to Andrew BoyerThese definitions are shared between the PMD and firmware. Teach the device to read the FW version and check for liveness.
--- drivers/crypto/ionic/ionic_crypto.h | 53 ++ drivers/crypto/ionic/ionic_crypto_if.h | 1021 ++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 17 +- drivers/crypto/ionic/ionic_crypto_vdev.c | 37 + 4 files changed, 1127 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_if.h
drivers/crypto/ionic/ionic_crypto.h +53 -0
@@ -16,6 +16,7 @@#include <rte_log.h> #include "ionic_common.h" +#include "ionic_crypto_if.h" #include "ionic_regs.h" /* Devargs */
@@ -29,6 +30,51 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +static inline void iocpt_struct_size_checks (void ) +{ +RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct ionic_intr_status ) !=8 ); + +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_regs ) !=4096 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_info_regs ) !=2048 ); +RTE_BUILD_BUG_ON (sizeof (union iocpt_dev_cmd_regs ) !=2048 ); + +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_admin_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_nop_comp ) !=16 ); + +/* Device commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_dev_reset_comp ) !=16 ); + +/* LIF commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_reset_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_getattr_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_lif_setattr_comp ) !=16 ); + +/* Queue commands */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_identify_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_cmd ) !=64 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_init_comp ) !=16 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_q_control_cmd ) !=64 ); + +/* Crypto */ +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_desc ) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_sg_desc ) !=256 ); +RTE_BUILD_BUG_ON (sizeof (struct iocpt_crypto_comp ) !=16 ); +} +struct iocpt_dev_bars {struct ionic_dev_bar bar[IONIC_BARS_MAX ];uint32_t num_bars;
@@ -41,12 +87,19 @@ struct iocpt_dev_bars {/* Combined dev / LIF object */ struct iocpt_dev {const char *name; +char fw_version[IOCPT_FWVERS_BUFLEN ];struct iocpt_dev_bars bars;const struct iocpt_dev_intf *intf;void *bus_dev;struct rte_cryptodev *crypto_dev; +union iocpt_dev_info_regs __iomem *dev_info; +union iocpt_dev_cmd_regs __iomem *dev_cmd; + +struct ionic_doorbell __iomem *db_pages; +struct ionic_intr __iomem *intr_ctrl; +uint32_t max_qps;uint32_t max_sessions;uint16_t state;
drivers/crypto/ionic/ionic_crypto_if.h new file +1021 -0
1,021 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +16 -1
@@ -57,9 +57,12 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, };struct rte_cryptodev *cdev;struct iocpt_dev *dev; -uint32_t i; +uint32_t i, sig;int err; +/* Check structs (trigger error at compilation time) */ +iocpt_struct_size_checks (); +/* Multi-process not supported */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { err = -EPERM ;
@@ -110,6 +113,18 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, goto err_destroy_crypto_dev; } + sig =ioread32 (&dev->dev_info->signature); +if (sig !=IOCPT_DEV_INFO_SIGNATURE ) { +IOCPT_PRINT (ERR ,"Incompatible firmware signature %#x" , sig); + err = -EFAULT ; + goto err_destroy_crypto_dev; + } + +for (i =0 ; i <IOCPT_FWVERS_BUFLEN ; i++) + dev->fw_version[i] =ioread8 (&dev->dev_info->fw_version[i]); + dev->fw_version[IOCPT_FWVERS_BUFLEN -1 ] ='\0' ; +IOCPT_PRINT (DEBUG ,"%s firmware: %s" , dev->name, dev->fw_version); + err =iocpt_init (dev);if (err !=0 ) {IOCPT_PRINT (ERR ,"Cannot init device: %d, aborting" , err);
drivers/crypto/ionic/ionic_crypto_vdev.c +37 -0
@@ -24,11 +24,48 @@#define IOCPT_VDEV_DEV_INFO_REGS_OFFSET 0x0000#define IOCPT_VDEV_DEV_CMD_REGS_OFFSET 0x0800 +#define IOCPT_VDEV_FW_WAIT_US 1000/* 1ms */ +#define IOCPT_VDEV_FW_WAIT_MAX 5000/* 5s */ +static int iocpt_vdev_setup_bars (struct iocpt_dev *dev) { +struct iocpt_dev_bars *bars = &dev->bars; +uint8_t *bar0_base; +uint32_t fw_waits =0 ; +uint8_t fw; +IOCPT_PRINT_CALL (); +/* BAR0: dev_cmd */ + bar0_base = bars->bar[IOCPT_VDEV_DEV_BAR ].vaddr; + dev->dev_info = (union iocpt_dev_info_regs *) + &bar0_base[IOCPT_VDEV_DEV_INFO_REGS_OFFSET ]; + dev->dev_cmd = (union iocpt_dev_cmd_regs *) + &bar0_base[IOCPT_VDEV_DEV_CMD_REGS_OFFSET ]; + +/* BAR1: interrupts */ + dev->intr_ctrl = (void *)bars->bar[IOCPT_VDEV_INTR_CTL_BAR ].vaddr; + +/* BAR3: doorbells */ + dev->db_pages = (void *)bars->bar[IOCPT_VDEV_DB_BAR ].vaddr; + +/* Wait for the FW to indicate readiness */ +while (1 ) { + fw =ioread8 (&dev->dev_info->fw_status); +if ((fw &IOCPT_FW_STS_F_RUNNING ) !=0 ) +break ; + +if (fw_waits >IOCPT_VDEV_FW_WAIT_MAX ) { +IOCPT_PRINT (ERR ,"Firmware readiness bit not set" ); +return -ETIMEDOUT ; + } + + fw_waits++; +rte_delay_us_block (IOCPT_VDEV_FW_WAIT_US ); + } +IOCPT_PRINT (DEBUG ,"Firmware ready (%u waits)" , fw_waits); + dev->name =rte_vdev_device_name (dev->bus_dev);return 0 ;
Signature · 1 line
2.17.1
PATCH v2 3/9 crypto/ionic: add device commands
In reply to Andrew BoyerThis defines the device (register-based) commands. They are used for device identification, setup, and teardown.
--- drivers/crypto/ionic/ionic_crypto.h | 24 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 348 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 89 +++++- drivers/crypto/ionic/meson.build | 1 + 4 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c
drivers/crypto/ionic/ionic_crypto.h +24 -0
@@ -80,6 +80,17 @@ struct iocpt_dev_bars {uint32_t num_bars; }; +struct iocpt_qtype_info { +uint8_t version; +uint8_t supported; +uint64_t features; +uint16_t desc_sz; +uint16_t comp_sz; +uint16_t sg_desc_sz; +uint16_t max_sg_elems; +uint16_t sg_desc_stride; +}; +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -89,6 +100,7 @@ struct iocpt_dev {const char *name;char fw_version[IOCPT_FWVERS_BUFLEN ];struct iocpt_dev_bars bars; +struct iocpt_identity ident;const struct iocpt_dev_intf *intf;void *bus_dev;
@@ -108,6 +120,14 @@ struct iocpt_dev {uint64_t features;uint32_t hw_features; + +uint32_t info_sz; +struct iocpt_lif_info *info; +rte_iova_t info_pa; +const struct rte_memzone *info_z; + +struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX ]; +uint8_t qtype_ver[IOCPT_QTYPE_MAX ]; };struct iocpt_dev_intf {
@@ -132,6 +152,10 @@ int iocpt_remove(struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev);void iocpt_deinit (struct iocpt_dev *dev); +int iocpt_dev_identify (struct iocpt_dev *dev); +int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa); +void iocpt_dev_reset (struct iocpt_dev *dev); +static inline bool iocpt_is_embedded (void ) {
drivers/crypto/ionic/ionic_crypto_cmds.c new file +348 -0
348 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +88 -1
123 lines not on this page · raw message
drivers/crypto/ionic/meson.build +1 -0
@@ -5,6 +5,7 @@ deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( + 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', 'ionic_crypto_vdev.c', )
Signature · 1 line
2.17.1
RE: [EXTERNAL] [PATCH v2 3/9] crypto/ionic: add device commands
Quoted 5 lines
Subject: [EXTERNAL] [PATCH v2 3/9]
crypto/ionic: add device commandsThis defines the device (register-based) commands. They are used for device identification, setup, and teardown.
Quoted 9 lines
Signed-off-by Andrew Boyer <[email protected]>--- drivers/crypto/ionic/ionic_crypto.h | 24 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 348 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 89 +++++- drivers/crypto/ionic/meson.build | 1 + 4 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_cmds.c
Fix _coding style issues_
Warning in drivers/crypto/ionic/ionic_crypto_cmds.c:
Using %l format, prefer %PRI*64 if type is [u]int64_t
Re: [EXTERNAL] [PATCH v2 3/9] crypto/ionic: add device commands
Quoted 22 lines · Akhil Goyal
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 5 lines
Subject: [EXTERNAL] [PATCH v2 3/9]
crypto/ionic: add device commandsThis defines the device (register-based) commands. They are used for device identification, setup, and teardown.
Quoted 9 lines
Signed-off-by Andrew Boyer <[email protected]>---
drivers/crypto/ionic/ionic_crypto.h | 24 ++ drivers/crypto/ionic/ionic_crypto_cmds.c | 348 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 89 +++++- drivers/crypto/ionic/meson.build | 1 + 4 files changed, 461 insertions(+), 1 deletion(-)create mode 100644
drivers/crypto/ionic/ionic_crypto_cmds.c
Quoted 6 lines
Fix
_codingstyleissues_Warning in
drivers/crypto/ionic/ionic_crypto_cmds.c:
Using %l format, prefer %PRI*64 if type is [u]int64_t
"if type is [u]int64_t"
But it isn't. It's unsigned long.
-Andrew
PATCH v2 4/9 crypto/ionic: add adminq command support
In reply to Andrew BoyerThis defines the adminq used for control path commands. The adminq is faster and more flexible than the device command interface.
--- drivers/crypto/ionic/ionic_crypto.h | 115 +++++++++ drivers/crypto/ionic/ionic_crypto_cmds.c | 302 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 295 +++++++++++++++++++++- 3 files changed, 711 insertions(+), 1 deletion(-)
drivers/crypto/ionic/ionic_crypto.h +115 -0
@@ -22,6 +22,10 @@/* Devargs */ /* NONE */ +#define IOCPT_MAX_RING_DESC 32768 +#define IOCPT_MIN_RING_DESC 16 +#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ +extern int iocpt_logtype;#define RTE_LOGTYPE_IOCPT iocpt_logtype
@@ -91,6 +95,63 @@ struct iocpt_qtype_info {uint16_t sg_desc_stride; }; +#define IOCPT_Q_F_INITED BIT(0) +#define IOCPT_Q_F_DEFERRED BIT(1) +#define IOCPT_Q_F_SG BIT(2) + +#define Q_NEXT_TO_POST (_q, _n) (((_q)->head_idx + (_n)) & ((_q)->size_mask)) +#define Q_NEXT_TO_SRVC (_q, _n) (((_q)->tail_idx + (_n)) & ((_q)->size_mask)) + +#define IOCPT_INFO_SZ (_q) ((_q)->num_segs * sizeof(void *)) +#define IOCPT_INFO_IDX (_q, _i) ((_i) * (_q)->num_segs) +#define IOCPT_INFO_PTR (_q, _i) (&(_q)->info[IOCPT_INFO_IDX((_q), _i)]) + +struct iocpt_queue { +uint16_t num_descs; +uint16_t num_segs; +uint16_t head_idx; +uint16_t tail_idx; +uint16_t size_mask; +uint8_t type; +uint8_t hw_type; +void *base; +void *sg_base; +struct ionic_doorbell __iomem *db; +void **info; + +uint32_t index; +uint32_t hw_index; +rte_iova_t base_pa; +rte_iova_t sg_base_pa; +}; + +struct iocpt_cq { +uint16_t tail_idx; +uint16_t num_descs; +uint16_t size_mask; +bool done_color; +void *base; +rte_iova_t base_pa; +}; + +#define IOCPT_COMMON_FIELDS \ + struct iocpt_queue q; \ + struct iocpt_cq cq; \ + struct iocpt_dev *dev; \ + const struct rte_memzone *base_z; \ + void *base; \ + rte_iova_t base_pa + +struct iocpt_common_q { +IOCPT_COMMON_FIELDS ; +}; + +struct iocpt_admin_q { +IOCPT_COMMON_FIELDS ; + +uint16_t flags; +}; +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -118,6 +179,11 @@ struct iocpt_dev {uint8_t driver_id;uint8_t socket_id; +rte_spinlock_t adminq_lock; +rte_spinlock_t adminq_service_lock; + +struct iocpt_admin_q *adminq; +uint64_t features;uint32_t hw_features;
@@ -144,6 +210,17 @@ iocpt_setup_bars(struct iocpt_dev *dev)return (*dev->intf->setup_bars)(dev); } +/** iocpt_admin_ctx - Admin command context. +* @pending_work: Flag that indicates a completion. +* @cmd: Admin command (64B) to be copied to the queue. +* @comp: Admin completion (16B) copied from the queue. +*/ +struct iocpt_admin_ctx { +bool pending_work; +union iocpt_adminq_cmd cmd; +union iocpt_adminq_comp comp; +}; +int iocpt_probe (void *bus_dev,struct rte_device *rte_dev,struct iocpt_dev_bars *bars,const struct iocpt_dev_intf *intf,uint8_t driver_id,uint8_t socket_id);
@@ -154,8 +231,46 @@ void iocpt_deinit(struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);int iocpt_dev_init (struct iocpt_dev *dev,rte_iova_t info_pa); +int iocpt_dev_adminq_init (struct iocpt_dev *dev);void iocpt_dev_reset (struct iocpt_dev *dev); +int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); + +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev, +struct iocpt_queue *q); + +typedef bool (*iocpt_cq_cb )(struct iocpt_cq *cq,uint16_t cq_desc_index, +void *cb_arg); +uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do, +iocpt_cq_cb cb,void *cb_arg); + +static inline uint16_t +iocpt_q_space_avail (struct iocpt_queue *q) +{ +uint16_t avail = q->tail_idx; + +if (q->head_idx >= avail) + avail += q->num_descs - q->head_idx -1 ; +else + avail -= q->head_idx +1 ; + +return avail; +} + +static inline void +iocpt_q_flush (struct iocpt_queue *q) +{ +uint64_t val =IONIC_DBELL_QID (q->hw_index) | q->head_idx; + +#if defined(RTE_LIBRTE_IONIC_PMD_BARRIER_ERRATA ) +/* On some devices the standard 'dmb' barrier is insufficient */ + asmvolatile ("dsb st" : : :"memory" ); +rte_write64_relaxed (rte_cpu_to_le_64 (val), q->db); +#else +rte_write64 (rte_cpu_to_le_64 (val), q->db); +#endif +} +static inline bool iocpt_is_embedded (void ) {
drivers/crypto/ionic/ionic_crypto_cmds.c +302 -0
323 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +294 -1
343 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/9 crypto/ionic: add capabilities and basic ops
In reply to Andrew BoyerThis exposes the supported capabilities to the stack.
--- drivers/crypto/ionic/ionic_crypto.h | 3 ++ drivers/crypto/ionic/ionic_crypto_caps.c | 25 +++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 8 +++ drivers/crypto/ionic/ionic_crypto_ops.c | 66 ++++++++++++++++++++++++ drivers/crypto/ionic/meson.build | 2 + 5 files changed, 104 insertions(+) create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c
drivers/crypto/ionic/ionic_crypto.h +3 -0
@@ -34,6 +34,8 @@ extern int iocpt_logtype;#define IOCPT_PRINT_CALL () IOCPT_PRINT(DEBUG, " >>") +const struct rte_cryptodev_capabilities *iocpt_get_caps (uint64_t flags); +static inline void iocpt_struct_size_checks (void ) {RTE_BUILD_BUG_ON (sizeof (struct ionic_doorbell ) !=8 );
@@ -227,6 +229,7 @@ int iocpt_probe(void *bus_dev, struct rte_device *rte_dev,int iocpt_remove (struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev); +int iocpt_assign_ops (struct rte_cryptodev *cdev);void iocpt_deinit (struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);
drivers/crypto/ionic/ionic_crypto_caps.c new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021-2024 Advanced Micro Devices, Inc. +*/ + +#include <rte_cryptodev.h> + +#include "ionic_crypto.h" + +static const struct rte_cryptodev_capabilities iocpt_sym_caps[] = { +RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () +}; + +static const struct rte_cryptodev_capabilities iocpt_asym_caps[] = { +/* None */ +RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () +}; + +const struct rte_cryptodev_capabilities * +iocpt_get_caps (uint64_t flags) +{ +if (flags &RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO ) +return iocpt_asym_caps; +else +return iocpt_sym_caps; +}
drivers/crypto/ionic/ionic_crypto_main.c +8 -0
@@ -505,8 +505,16 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev, goto err_free_objs; } + err =iocpt_assign_ops (cdev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Failed to configure opts" ); + goto err_deinit_dev; + } +return 0 ; +err_deinit_dev: +iocpt_deinit (dev); err_free_objs:iocpt_free_objs (dev); err_destroy_crypto_dev:
drivers/crypto/ionic/ionic_crypto_ops.c new file +66 -0
66 lines not on this page · raw message
drivers/crypto/ionic/meson.build +2 -0
@@ -5,8 +5,10 @@ deps += ['bus_vdev'] deps += ['common_ionic'] sources = files( + 'ionic_crypto_caps.c', 'ionic_crypto_cmds.c', 'ionic_crypto_main.c', + 'ionic_crypto_ops.c', 'ionic_crypto_vdev.c', ) name = 'ionic_crypto'
Signature · 1 line
2.17.1
PATCH v2 6/9 crypto/ionic: add session support
In reply to Andrew BoyerThis defines the session object and related commands.
--- drivers/crypto/ionic/ionic_crypto.h | 33 ++++++ drivers/crypto/ionic/ionic_crypto_main.c | 143 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 123 +++++++++++++++++++ 3 files changed, 299 insertions(+)
drivers/crypto/ionic/ionic_crypto.h +33 -0
@@ -14,6 +14,7 @@#include <rte_cryptodev.h> #include <cryptodev_pmd.h> #include <rte_log.h> +#include <rte_bitmap.h> #include "ionic_common.h" #include "ionic_crypto_if.h"
@@ -154,6 +155,32 @@ struct iocpt_admin_q {uint16_t flags; }; +#define IOCPT_S_F_INITED BIT(0) + +struct iocpt_session_priv { +struct iocpt_dev *dev; + +uint32_t index; + +uint16_t iv_offset; +uint16_t iv_length; +uint16_t digest_length; +uint16_t aad_length; + +uint8_t flags; +uint8_t op; +uint8_t type; + +uint16_t key_len; +uint8_t key[IOCPT_SESS_KEY_LEN_MAX_SYMM ]; +}; + +static inline uint32_t +iocpt_session_size (void ) +{ +return sizeof (struct iocpt_session_priv ); +} +#define IOCPT_DEV_F_INITED BIT(0)#define IOCPT_DEV_F_UP BIT(1)#define IOCPT_DEV_F_FW_RESET BIT(2)
@@ -186,6 +213,8 @@ struct iocpt_dev {struct iocpt_admin_q *adminq; +struct rte_bitmap *sess_bm;/* SET bit indicates index is free */ +uint64_t features;uint32_t hw_features;
@@ -239,6 +268,10 @@ void iocpt_dev_reset(struct iocpt_dev *dev);int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); +int iocpt_session_init (struct iocpt_session_priv *priv); +int iocpt_session_update (struct iocpt_session_priv *priv); +void iocpt_session_deinit (struct iocpt_session_priv *priv); +struct ionic_doorbell __iomem *iocpt_db_map (struct iocpt_dev *dev,struct iocpt_queue *q);
drivers/crypto/ionic/ionic_crypto_main.c +143 -0
169 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +123 -0
133 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 7/9 crypto/ionic: add datapath
In reply to Andrew BoyerThis defines the main crypto operation enqueue and dequeue handlers.
--- doc/guides/cryptodevs/features/ionic.ini | 8 + doc/guides/cryptodevs/ionic.rst | 11 + drivers/crypto/ionic/ionic_crypto.h | 17 ++ drivers/crypto/ionic/ionic_crypto_caps.c | 30 +++ drivers/crypto/ionic/ionic_crypto_main.c | 222 ++++++++++++++++- drivers/crypto/ionic/ionic_crypto_ops.c | 295 +++++++++++++++++++++++ 6 files changed, 581 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/ionic.ini +8 -0
@@ -4,6 +4,12 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Symmetric crypto = Y +HW Accelerated = Y +In Place SGL = Y +OOP SGL In LB Out = Y +OOP SGL In SGL Out = Y +OOP LB In LB Out = Y ; ; Supported crypto algorithms of 'ionic' crypto driver.
@@ -19,6 +25,8 @@ ; Supported AEAD algorithms of 'ionic' crypto driver. ; [AEAD] +AES GCM (128) = Y +AES GCM (256) = Y ; ; Supported Asymmetric algorithms of the 'ionic' crypto driver.
doc/guides/cryptodevs/ionic.rst +11 -0
@@ -26,3 +26,14 @@ Runtime Configuration None +Features +-------- + +The ionic crypto PMD has support for: + +Symmetric Crypto Algorithms +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +AEAD algorithms: + +* ``RTE_CRYPTO_AEAD_AES_GCM``
drivers/crypto/ionic/ionic_crypto.h +17 -0
@@ -27,6 +27,8 @@#define IOCPT_MIN_RING_DESC 16#define IOCPT_ADMINQ_LENGTH 16/* must be a power of two */ +#define IOCPT_CRYPTOQ_WAIT 10/* 1s */ +extern int iocpt_logtype;#define RTE_LOGTYPE_IOCPT iocpt_logtype
@@ -155,6 +157,14 @@ struct iocpt_admin_q {uint16_t flags; }; +struct iocpt_crypto_q { +/* cacheline0, cacheline1 */ +IOCPT_COMMON_FIELDS ; + +/* cacheline2 */ +uint16_t flags; +}; +#define IOCPT_S_F_INITED BIT(0)struct iocpt_session_priv {
@@ -212,6 +222,7 @@ struct iocpt_dev {rte_spinlock_t adminq_service_lock;struct iocpt_admin_q *adminq; +struct iocpt_crypto_q **cryptoqs;struct rte_bitmap *sess_bm;/* SET bit indicates index is free */
@@ -259,6 +270,8 @@ int iocpt_remove(struct rte_device *rte_dev);void iocpt_configure (struct iocpt_dev *dev);int iocpt_assign_ops (struct rte_cryptodev *cdev); +int iocpt_start (struct iocpt_dev *dev); +void iocpt_stop (struct iocpt_dev *dev);void iocpt_deinit (struct iocpt_dev *dev);int iocpt_dev_identify (struct iocpt_dev *dev);
@@ -268,6 +281,10 @@ void iocpt_dev_reset(struct iocpt_dev *dev);int iocpt_adminq_post_wait (struct iocpt_dev *dev,struct iocpt_admin_ctx *ctx); +int iocpt_cryptoq_alloc (struct iocpt_dev *dev,uint32_t socket_id, +uint32_t index,uint16_t ndescs); +void iocpt_cryptoq_free (struct iocpt_crypto_q *cptq); +int iocpt_session_init (struct iocpt_session_priv *priv);int iocpt_session_update (struct iocpt_session_priv *priv);void iocpt_session_deinit (struct iocpt_session_priv *priv);
drivers/crypto/ionic/ionic_crypto_caps.c +30 -0
@@ -7,6 +7,36 @@#include "ionic_crypto.h" static const struct rte_cryptodev_capabilities iocpt_sym_caps[] = { + {/* AES GCM */ + .op =RTE_CRYPTO_OP_TYPE_SYMMETRIC , + {.sym = { + .xform_type =RTE_CRYPTO_SYM_XFORM_AEAD , + {.aead = { + .algo =RTE_CRYPTO_AEAD_AES_GCM , + .block_size =16 , + .key_size = { + .min =16 , + .max =32 , + .increment =16 + }, + .digest_size = { + .min =16 , + .max =16 , + .increment =0 + }, + .aad_size = { + .min =0 , + .max =1024 , + .increment =1 + }, + .iv_size = { + .min =12 , + .max =12 , + .increment =0 + } + }, } + }, } + },RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST () };
drivers/crypto/ionic/ionic_crypto_main.c +220 -2
284 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +295 -0
323 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 8/9 crypto/ionic: add a watchdog operation
In reply to Andrew BoyerIf no progress has been made within the timeout, post a dummy operation using session 0. This will restart the queue in the rare case that a doorbell is lost inside the device.
--- drivers/crypto/ionic/ionic_crypto.h | 16 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 31 ++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 97 +++++++++++++++++++++++- 3 files changed, 142 insertions(+), 2 deletions(-)
drivers/crypto/ionic/ionic_crypto.h +16 -0
@@ -89,6 +89,14 @@ struct iocpt_dev_bars {uint32_t num_bars; }; +/* Queue watchdog */ +#define IOCPT_Q_WDOG_SESS_IDX 0 +#define IOCPT_Q_WDOG_KEY_LEN 16 +#define IOCPT_Q_WDOG_IV_LEN 12 +#define IOCPT_Q_WDOG_PLD_LEN 4 +#define IOCPT_Q_WDOG_TAG_LEN 16 +#define IOCPT_Q_WDOG_OP_TYPE RTE_CRYPTO_OP_TYPE_UNDEFINED +struct iocpt_qtype_info {uint8_t version;uint8_t supported;
@@ -162,7 +170,15 @@ struct iocpt_crypto_q {IOCPT_COMMON_FIELDS ;/* cacheline2 */ +uint64_t last_wdog_cycles;uint16_t flags; + +/* cacheline3 */ +uint64_t enqueued_wdogs; +uint64_t dequeued_wdogs; +uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN ]; +uint8_t wdog_pld[IOCPT_Q_WDOG_PLD_LEN ]; +uint8_t wdog_tag[IOCPT_Q_WDOG_TAG_LEN ]; };#define IOCPT_S_F_INITED BIT(0)
drivers/crypto/ionic/ionic_crypto_main.c +31 -0
@@ -172,6 +172,22 @@ iocpt_session_write(struct iocpt_session_priv *priv,return 0 ; } +static int +iocpt_session_wdog (struct iocpt_dev *dev) +{ +struct iocpt_session_priv priv = { + .dev = dev, + .index =IOCPT_Q_WDOG_SESS_IDX , + .type =IOCPT_SESS_AEAD_AES_GCM , + .key_len =IOCPT_Q_WDOG_KEY_LEN , + }; + +/* Reserve session 0 for queue watchdog */ +rte_bitmap_clear (dev->sess_bm,IOCPT_Q_WDOG_SESS_IDX ); + +return iocpt_session_write (&priv,IOCPT_SESS_INIT ); +} +int iocpt_session_init (struct iocpt_session_priv *priv) {
@@ -491,6 +507,9 @@ iocpt_cryptoq_deinit(struct iocpt_crypto_q *cptq)IOCPT_PRINT (DEBUG ,"Deinit queue %u returned %d after %u ms" , cptq->q.index, err, sleep_cnt *100 ); +IOCPT_PRINT (DEBUG ,"Queue %u watchdog: enq %" PRIu64" deq %" PRIu64, + cptq->q.index, cptq->enqueued_wdogs, cptq->dequeued_wdogs); + cptq->flags &= ~IOCPT_Q_F_INITED ; }
@@ -659,9 +678,21 @@ iocpt_init(struct iocpt_dev *dev)if (err !=0 )return err; +/* Write the queue watchdog key */ + err =iocpt_session_wdog (dev); +if (err !=0 ) { +IOCPT_PRINT (ERR ,"Cannot setup watchdog session" ); + goto err_out_adminq_deinit; + } + dev->state |=IOCPT_DEV_F_INITED ;return 0 ; + +err_out_adminq_deinit: +iocpt_adminq_deinit (dev); + +return err; }void
drivers/crypto/ionic/ionic_crypto_ops.c +95 -2
132 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 9/9 crypto/ionic: add stats support
In reply to Andrew BoyerThis defines the stats handlers and exposes them to the stack.
--- drivers/crypto/ionic/ionic_crypto.h | 8 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 48 ++++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_ops.c | 33 +++++++++++++++- 3 files changed, 87 insertions(+), 2 deletions(-)
drivers/crypto/ionic/ionic_crypto.h +8 -0
@@ -174,6 +174,8 @@ struct iocpt_crypto_q {uint16_t flags;/* cacheline3 */ +struct rte_cryptodev_stats stats; +uint64_t enqueued_wdogs;uint64_t dequeued_wdogs;uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN ];
@@ -252,6 +254,8 @@ struct iocpt_dev {struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX ];uint8_t qtype_ver[IOCPT_QTYPE_MAX ]; + +struct rte_cryptodev_stats stats_base; };struct iocpt_dev_intf {
@@ -313,6 +317,10 @@ typedef bool (*iocpt_cq_cb)(struct iocpt_cq *cq, uint16_t cq_desc_index,uint32_t iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do,iocpt_cq_cb cb,void *cb_arg); +void iocpt_get_stats (const struct iocpt_dev *dev, +struct rte_cryptodev_stats *stats); +void iocpt_reset_stats (struct iocpt_dev *dev); +static inline uint16_t iocpt_q_space_avail (struct iocpt_queue *q) {
drivers/crypto/ionic/ionic_crypto_main.c +48 -0
60 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_ops.c +31 -2
@@ -65,6 +65,23 @@ iocpt_op_info_get(struct rte_cryptodev *cdev, struct rte_cryptodev_info *info) info->min_mbuf_tailroom_req =0 ; } +static void +iocpt_op_stats_get (struct rte_cryptodev *cdev, +struct rte_cryptodev_stats *stats) +{ +struct iocpt_dev *dev = cdev->data->dev_private; + +iocpt_get_stats (dev, stats); +} + +static void +iocpt_op_stats_reset (struct rte_cryptodev *cdev) +{ +struct iocpt_dev *dev = cdev->data->dev_private; + +iocpt_reset_stats (dev); +} +static int iocpt_op_queue_release (struct rte_cryptodev *cdev,uint16_t queue_id) {
@@ -350,6 +367,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)struct iocpt_crypto_q *cptq = qp;struct rte_crypto_op *op;struct iocpt_session_priv *priv; +struct rte_cryptodev_stats *stats = &cptq->stats;uint16_t avail, count;int err;
@@ -375,6 +393,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops) err =iocpt_enq_one_aead (cptq, priv, op);if (unlikely (err !=0 )) { op->status =RTE_CRYPTO_OP_STATUS_INVALID_ARGS ; + stats->enqueue_err_count++;break ; }
@@ -386,6 +405,8 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)/* Restart timer if ops are being enqueued */ cptq->last_wdog_cycles =rte_get_timer_cycles (); + + stats->enqueued_count += count; }return count;
@@ -439,8 +460,8 @@ iocpt_enqueue_wdog(struct iocpt_crypto_q *cptq) q->info[q->head_idx] = wdog_op; q->head_idx =Q_NEXT_TO_POST (q,1 ); -IOCPT_PRINT (DEBUG ,"Queue %u wdog enq %p" , - q->index, wdog_op); +IOCPT_PRINT (DEBUG ,"Queue %u wdog enq %p ops %" PRIu64, + q->index, wdog_op, cptq->stats.enqueued_count); cptq->enqueued_wdogs++; out_flush:
@@ -456,6 +477,7 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)struct rte_crypto_op *op;struct iocpt_crypto_comp *cq_desc_base = cq->base;volatile struct iocpt_crypto_comp *cq_desc; +struct rte_cryptodev_stats *stats = &cptq->stats;uint64_t then, now, hz, delta;uint16_t count =0 ;
@@ -515,6 +537,9 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)continue ; } +if (unlikely (op->status !=RTE_CRYPTO_OP_STATUS_SUCCESS )) + stats->dequeue_err_count++; + ops[count] = op; q->info[q->tail_idx] =NULL ;
@@ -542,6 +567,8 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)/* Restart timer if the queue is making progress */ cptq->last_wdog_cycles =rte_get_timer_cycles (); + stats->dequeued_count += count; +return count; }
@@ -552,6 +579,8 @@ static struct rte_cryptodev_ops iocpt_ops = { .dev_close = iocpt_op_close, .dev_infos_get = iocpt_op_info_get, + .stats_get = iocpt_op_stats_get, + .stats_reset = iocpt_op_stats_reset, .queue_pair_setup = iocpt_op_queue_setup, .queue_pair_release = iocpt_op_queue_release,
Signature · 1 line
2.17.1
Quoted 12 lines · Andrew
This patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
V2:
- Remix patches as requested by review
- Fix duplicated logtype global int
- Do some very minor whitespace touchups
Hello Akhil,
I re-did the patch set as you requested. Do you have an estimate of when you might be able to review it?
Thanks,
Andrew
Quoted 17 lines · Andrew
Quoted 13 lines · Andrew
This patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
V2:
- Remix patches as requested by review
- Fix duplicated logtype global int
- Do some very minor whitespace touchups
Quoted 5 lines
Hello Akhil,
I re-did the patch set as you requested. Do you have an estimate of when you might be able to review it?Thanks,
Andrew
Ferruh pointed out that you have commented, but all of the comments were stuck in our local quarantine. I will address them.
Thank you,
Andrew
Quoted 20 lines
Quoted 6 lines · Andrew
Quoted 3 lines
On Apr 30, 2024, at 4:21 PM, Boyer, Andrew <[email protected]>
Quoted 5 lines · wrote:
Quoted 5 lines
This patchset introduces a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks.
Quoted 8 lines
Quoted 5 lines
V2:
- Remix patches as requested by review
- Fix duplicated logtype global int
- Do some very minor whitespace touchupsHello Akhil,
I re-did the patch set as you requested. Do you have an estimate of when you
Quoted 8 lines
might be able to review it?
Quoted 3 lines
Thanks,
AndrewFerruh pointed out that you have commented, but all of the comments were stuck in our local quarantine. I will address them.
Please also add release notes.