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.
Depends-on: series-31157 ("net/ionic, common/ionic: add vdev support")
Andrew Boyer (5):
crypto/ionic: introduce AMD Pensando ionic crypto driver crypto/ionic: add device and admin command handlers crypto/ionic: add device object and vdev support crypto/ionic: add datapath and capabilities support crypto/ionic: add documentation
MAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + 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 | 360 ++++++++ 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 | 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 + 15 files changed, 3965 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
RFC 1/5 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
RFC 2/5 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 | 209 ++++++++ drivers/crypto/ionic/ionic_crypto_cmds.c | 651 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 40 ++ drivers/crypto/ionic/meson.build | 12 + drivers/crypto/meson.build | 1 + 5 files changed, 913 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 +209 -0
@@ -0,0 +1,209 @@ +/* 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 IOCPT_PRINT(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + iocpt_logtype, "%s(): " fmt "\n", __func__, ##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 +40 -0
@@ -0,0 +1,40 @@ +/* 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; + +uint32_t +iocpt_cq_service (struct iocpt_cq *cq,uint32_t work_to_do, +iocpt_cq_cb cb,void *cb_arg) +{ +uint32_t work_done =0 ; + +if (work_to_do ==0 ) +return 0 ; + +while (cb (cq, cq->tail_idx, cb_arg)) { + cq->tail_idx =Q_NEXT_TO_SRVC (cq,1 ); +if (cq->tail_idx ==0 ) + cq->done_color = !cq->done_color; + +if (++work_done == work_to_do) +break ; + } + +return work_done; +} + +struct ionic_doorbell * +iocpt_db_map (struct iocpt_dev *dev,struct iocpt_queue *q) +{ +return dev->db_pages + q->hw_type; +}
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')
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
RFC 3/5 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/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 | 89 ++++ drivers/crypto/ionic/ionic_crypto_main.c | 538 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 128 ++++++ drivers/crypto/ionic/meson.build | 2 + 7 files changed, 807 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c
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 +89 -0
127 lines not on this page · raw message
drivers/crypto/ionic/ionic_crypto_main.c +538 -0
552 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
RFC 4/5 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
@@ -36,6 +36,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 );
@@ -162,6 +164,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)
@@ -193,6 +239,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 */
@@ -241,6 +288,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);
@@ -250,6 +300,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);
@@ -258,6 +316,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
RFC 5/5 crypto/ionic: add documentation
In reply to Andrew BoyerAdd a features list and (basic) guide for the ionic crypto PMD.
--- MAINTAINERS | 7 +++++ doc/guides/cryptodevs/features/ionic.ini | 40 ++++++++++++++++++++++++ doc/guides/cryptodevs/ionic.rst | 39 +++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst
MAINTAINERS +7 -0
@@ -1067,6 +1067,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/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``
Signature · 1 line
2.17.1
Quoted 33 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.
Depends-on: series-31157 ("net/ionic, common/ionic: add vdev support")
Andrew Boyer (5):
crypto/ionic: introduce AMD Pensando ionic crypto drivercrypto/ionic: add device and admin command handlerscrypto/ionic: add device object and vdev supportcrypto/ionic: add datapath and capabilities supportcrypto/ionic: add documentationMAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + 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 | 360 ++++++++ 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 | 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 + 15 files changed, 3965 insertions(+), 1 deletion(-)
Quoted 14 lines
create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644
doc/guides/cryptodevs/ionic.rstcreate mode 100644drivers/crypto/ionic/ionic_crypto.hcreate mode 100644drivers/crypto/ionic/ionic_crypto_caps.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_cmds.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_if.hcreate mode 100644drivers/crypto/ionic/ionic_crypto_main.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_ops.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_vdev.ccreate mode 100644drivers/crypto/ionic/meson.buildSignature · 1 line
2.17.1
Akhil,
Are you deferring this out of the upcoming release?
-Andrew
Quoted 58 lines
-----Original Message-----
From: Boyer, Andrew <[email protected]>
Sent: Friday, March 1, 2024 6:54 PM
To: Akhil Goyal <[email protected]>
Cc: [email protected]
Subject: [EXTERNAL] Re: [RFC 0/5]crypto/ionic: introduce AMD Pensando ionic crypto driverPrioritize security for external emails: Confirm sender and content safety before clicking links or opening attachments
----------------------------------------------------------------------
Quoted 42 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.
Depends-on: series-31157 ("net/ionic, common/ionic: add vdev support")
Andrew Boyer (5):
crypto/ionic: introduce AMD Pensando ionic crypto drivercrypto/ionic: add device and admin command handlerscrypto/ionic: add device object and vdev supportcrypto/ionic: add datapath and capabilities supportcrypto/ionic: add documentationMAINTAINERS | 7 + doc/guides/cryptodevs/features/ionic.ini | 40 + 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 | 360 ++++++++ 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 | 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 + 15 files changed, 3965 insertions(+), 1 deletion(-)create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644
doc/guides/cryptodevs/ionic.rstcreate mode 100644drivers/crypto/ionic/ionic_crypto.hcreate mode 100644drivers/crypto/ionic/ionic_crypto_caps.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_cmds.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_if.hcreate mode 100644drivers/crypto/ionic/ionic_crypto_main.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_ops.ccreate mode 100644drivers/crypto/ionic/ionic_crypto_vdev.ccreate mode 100644drivers/crypto/ionic/meson.build
Quoted 7 lines
Quoted 3 lines
--
2.17.1Akhil,
Are you deferring this out of the upcoming release?
Yes. RFC came last week only and it is late for 24.03. Last date to merge PMD is RC2 which is coming Monday.
-Akhil