iavf: add iAVF IPsec inline crypto support
Subsystems (2)
cover iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (4):
common/iavf: add iAVF IPsec inline crypto support net/iavf: add iAVF IPsec inline crypto support net/iavf: Add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 215 +- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 53 +- drivers/net/iavf/iavf_ethdev.c | 222 +- drivers/net/iavf/iavf_generic_flow.c | 11 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1921 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 803 +++++-- drivers/net/iavf/iavf_rxtx.h | 567 ++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + 16 files changed, 4684 insertions(+), 339 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 1 line
2.25.1
PATCH 1/4 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 215 +++++++- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 775 insertions(+), 10 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +207 -8
@@ -709,11 +709,29 @@ enum iavf_rx_prog_status_desc_error_bits {#define IAVF_FOUR_BIT_MASK 0xF#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF -/* TX Descriptor */ +/* TX Data Descriptor */ struct iavf_tx_desc { -__le64 buffer_addr;/* Address of descriptor's data buf */ -__le64 cmd_type_offset_bsz; -}; +union { +struct { +__le64 buffer_addr;/* Addr of descriptor's data buf */ +__le64 cmd_type_offset_bsz; + }; +struct { +__le64 qw0;/**< data buffer address */ +__le64 qw1;/**< dtyp, cmd, offset, buf_sz and l2tag1 */ + }; +struct { +__le64 buffer_addr;/**< Data buffer address */ +__le64 type:4 ;/**< Descriptor type */ +__le64 cmd:12 ;/**< Command field */ +__le64 offset_l2len:7 ;/**< L2 header length */ +__le64 offset_l3len:7 ;/**< L3 header length */ +__le64 offset_l4len:4 ;/**< L4 header length */ +__le64 buffer_sz:14 ;/**< Data buffer size */ +__le64 l2tag1:16 ;/**< L2 Tag 1 value */ + } debug __rte_packed; + }; +} __rte_packed;#define IAVF_TXD_QW1_DTYPE_SHIFT 0#define IAVF_TXD_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
@@ -723,6 +741,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
@@ -734,7 +753,7 @@ enum iavf_tx_desc_dtype_value {#define IAVF_TXD_QW1_CMD_SHIFT 4#define IAVF_TXD_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_QW1_CMD_SHIFT) -enum iavf_tx_desc_cmd_bits { +enum iavf_tx_data_desc_cmd_bits {IAVF_TX_DESC_CMD_EOP =0x0001 ,IAVF_TX_DESC_CMD_RS =0x0002 ,IAVF_TX_DESC_CMD_ICRC =0x0004 ,
@@ -778,18 +797,79 @@ enum iavf_tx_desc_length_fields {#define IAVF_TXD_QW1_L2TAG1_SHIFT 48#define IAVF_TXD_QW1_L2TAG1_MASK (0xFFFFULL << IAVF_TXD_QW1_L2TAG1_SHIFT) +#define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0) +#define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT) + +#define IAVF_TXD_DATA_QW1_CMD_SHIFT (4) +#define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16) +#define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \ + IAVF_TXD_DATA_QW1_OFFSET_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \ + (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_MACLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_IPLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_L4LEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_FCLEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34) +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \ + (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) + +#define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48) +#define IAVF_TXD_DATA_QW1_L2TAG1_MASK \ + (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT) +/* Context descriptors */ struct iavf_tx_context_desc { +union { +struct {__le32 tunneling_params;__le16 l2tag2;__le16 rsvd;__le64 type_cmd_tso_mss; }; - -#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT 0 +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le32 tunneling; +__le16 l2tag2; +__le16 rsvd0; +__le64 type:4 ; +__le64 cmd:7 ; +__le64 ipsec:7 ; +__le64 rsvd1:12 ; +__le64 tlen_tsyn:18 ; +__le64 rsvd2:2 ; +__le64 mss_target_vsi:14 ; + } debug __rte_packed; + }; +} __rte_packed; + +#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT (0)#define IAVF_TXD_CTX_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_CTX_QW1_DTYPE_SHIFT) -#define IAVF_TXD_CTX_QW1_CMD_SHIFT 4 +#define IAVF_TXD_CTX_QW1_CMD_SHIFT (4)#define IAVF_TXD_CTX_QW1_CMD_MASK (0xFFFFUL << IAVF_TXD_CTX_QW1_CMD_SHIFT)enum iavf_tx_ctx_desc_cmd_bits {
@@ -804,6 +884,63 @@ enum iavf_tx_ctx_desc_cmd_bits {IAVF_TX_CTX_DESC_SWPE =0x40 }; +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \ + (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT) + +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \ + (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \ + (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \ + (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \ + (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_external_ip_type { +IAVF_TX_CTX_DESC_EIPT_NONE , +IAVF_TX_CTX_DESC_EIPT_IPV6 , +IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD , +IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type { +IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE , +IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP , +IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32) +#define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL) +struct iavf_nop_desc {__le64 rsvd;__le64 dtype_cmd;
@@ -911,6 +1048,68 @@ enum iavf_tx_ctx_desc_eipt_offload {#define IAVF_TXD_CTX_QW0_L4T_CS_SHIFT 23#define IAVF_TXD_CTX_QW0_L4T_CS_MASK BIT_ULL(IAVF_TXD_CTX_QW0_L4T_CS_SHIFT) + +struct iavf_tx_ipsec_desc { +union { +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le16 l4payload_length; +__le32 esn; +__le16 trailer_length; +u8 type:4 ; +u8 rsv:1 ; +u8 udp:1 ; +u8 ivlen:2 ; +u8 next_header; +__le16 ipv6_ext_hdr_length; +__le32 said; + } __rte_packed; + }; +} __rte_packed; + +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT 0 +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_MASK (0x3FFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_MASK (0xFFFFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT 48 +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_MASK (0x3FULL << \ + IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT 5 +#define IAVF_IPSEC_TX_DESC_QW1_UDP_MASK (0x1ULL << \ + IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT 6 +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_MASK (0x3ULL << \ + IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT 8 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT 32 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_MASK (0xFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) + +/* Initialization Vector Length type */ +enum iavf_ipsec_iv_len { +IAVF_IPSEC_IV_LEN_NONE ,/* No IV */ +IAVF_IPSEC_IV_LEN_DW ,/* 4B IV */ +IAVF_IPSEC_IV_LEN_DDW ,/* 8B IV */ +IAVF_IPSEC_IV_LEN_QDW ,/* 16B IV */ +}; +/* Statistics collected by each port, VSI, VEB, and S-channel */ struct iavf_eth_stats {u64 rx_bytes;/* gorc */
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -226,6 +229,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -388,7 +393,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2320,6 +2325,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/4 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 26 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 11 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1921 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 803 +++++-- drivers/net/iavf/iavf_rxtx.h | 579 ++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + 13 files changed, 3729 insertions(+), 313 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +26 -0
@@ -189,6 +189,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -216,6 +217,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -238,6 +240,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -249,11 +252,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -272,6 +278,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -340,9 +348,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
@@ -399,5 +422,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +11 -0
@@ -1709,6 +1709,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2021,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1921 -0
1,921 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +96 -0
96 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +566 -237
399 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +563 -16
579 lines not on this page · raw message
drivers/net/iavf/iavf_vchnl.c +114 -52
166 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH 3/4 net/iavf: Add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -92,6 +92,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -101,7 +120,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH 4/4 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
drivers/net/iavf/iavf.h +6 -0
@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +97 -0
121 lines not on this page · raw message
Signature · 1 line
2.25.1
v2 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (4):
common/iavf: add iAVF IPsec inline crypto support net/iavf: add iAVF IPsec inline crypto support net/iavf: Add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 215 +- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 53 +- drivers/net/iavf/iavf_ethdev.c | 222 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1918 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 729 +++++-- drivers/net/iavf/iavf_rxtx.h | 567 ++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4615 insertions(+), 339 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 3 lines
v2: small updates and fixes in the flow related section 2.25.1
PATCH v2 1/4 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 215 +++++++- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 775 insertions(+), 10 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +207 -8
@@ -709,11 +709,29 @@ enum iavf_rx_prog_status_desc_error_bits {#define IAVF_FOUR_BIT_MASK 0xF#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF -/* TX Descriptor */ +/* TX Data Descriptor */ struct iavf_tx_desc { -__le64 buffer_addr;/* Address of descriptor's data buf */ -__le64 cmd_type_offset_bsz; -}; +union { +struct { +__le64 buffer_addr;/* Addr of descriptor's data buf */ +__le64 cmd_type_offset_bsz; + }; +struct { +__le64 qw0;/**< data buffer address */ +__le64 qw1;/**< dtyp, cmd, offset, buf_sz and l2tag1 */ + }; +struct { +__le64 buffer_addr;/**< Data buffer address */ +__le64 type:4 ;/**< Descriptor type */ +__le64 cmd:12 ;/**< Command field */ +__le64 offset_l2len:7 ;/**< L2 header length */ +__le64 offset_l3len:7 ;/**< L3 header length */ +__le64 offset_l4len:4 ;/**< L4 header length */ +__le64 buffer_sz:14 ;/**< Data buffer size */ +__le64 l2tag1:16 ;/**< L2 Tag 1 value */ + } debug __rte_packed; + }; +} __rte_packed;#define IAVF_TXD_QW1_DTYPE_SHIFT 0#define IAVF_TXD_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
@@ -723,6 +741,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
@@ -734,7 +753,7 @@ enum iavf_tx_desc_dtype_value {#define IAVF_TXD_QW1_CMD_SHIFT 4#define IAVF_TXD_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_QW1_CMD_SHIFT) -enum iavf_tx_desc_cmd_bits { +enum iavf_tx_data_desc_cmd_bits {IAVF_TX_DESC_CMD_EOP =0x0001 ,IAVF_TX_DESC_CMD_RS =0x0002 ,IAVF_TX_DESC_CMD_ICRC =0x0004 ,
@@ -778,18 +797,79 @@ enum iavf_tx_desc_length_fields {#define IAVF_TXD_QW1_L2TAG1_SHIFT 48#define IAVF_TXD_QW1_L2TAG1_MASK (0xFFFFULL << IAVF_TXD_QW1_L2TAG1_SHIFT) +#define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0) +#define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT) + +#define IAVF_TXD_DATA_QW1_CMD_SHIFT (4) +#define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16) +#define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \ + IAVF_TXD_DATA_QW1_OFFSET_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \ + (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_MACLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_IPLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_L4LEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_FCLEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34) +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \ + (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) + +#define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48) +#define IAVF_TXD_DATA_QW1_L2TAG1_MASK \ + (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT) +/* Context descriptors */ struct iavf_tx_context_desc { +union { +struct {__le32 tunneling_params;__le16 l2tag2;__le16 rsvd;__le64 type_cmd_tso_mss; }; - -#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT 0 +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le32 tunneling; +__le16 l2tag2; +__le16 rsvd0; +__le64 type:4 ; +__le64 cmd:7 ; +__le64 ipsec:7 ; +__le64 rsvd1:12 ; +__le64 tlen_tsyn:18 ; +__le64 rsvd2:2 ; +__le64 mss_target_vsi:14 ; + } debug __rte_packed; + }; +} __rte_packed; + +#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT (0)#define IAVF_TXD_CTX_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_CTX_QW1_DTYPE_SHIFT) -#define IAVF_TXD_CTX_QW1_CMD_SHIFT 4 +#define IAVF_TXD_CTX_QW1_CMD_SHIFT (4)#define IAVF_TXD_CTX_QW1_CMD_MASK (0xFFFFUL << IAVF_TXD_CTX_QW1_CMD_SHIFT)enum iavf_tx_ctx_desc_cmd_bits {
@@ -804,6 +884,63 @@ enum iavf_tx_ctx_desc_cmd_bits {IAVF_TX_CTX_DESC_SWPE =0x40 }; +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \ + (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT) + +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \ + (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \ + (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \ + (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \ + (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_external_ip_type { +IAVF_TX_CTX_DESC_EIPT_NONE , +IAVF_TX_CTX_DESC_EIPT_IPV6 , +IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD , +IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type { +IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE , +IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP , +IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32) +#define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL) +struct iavf_nop_desc {__le64 rsvd;__le64 dtype_cmd;
@@ -911,6 +1048,68 @@ enum iavf_tx_ctx_desc_eipt_offload {#define IAVF_TXD_CTX_QW0_L4T_CS_SHIFT 23#define IAVF_TXD_CTX_QW0_L4T_CS_MASK BIT_ULL(IAVF_TXD_CTX_QW0_L4T_CS_SHIFT) + +struct iavf_tx_ipsec_desc { +union { +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le16 l4payload_length; +__le32 esn; +__le16 trailer_length; +u8 type:4 ; +u8 rsv:1 ; +u8 udp:1 ; +u8 ivlen:2 ; +u8 next_header; +__le16 ipv6_ext_hdr_length; +__le32 said; + } __rte_packed; + }; +} __rte_packed; + +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT 0 +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_MASK (0x3FFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_MASK (0xFFFFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT 48 +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_MASK (0x3FULL << \ + IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT 5 +#define IAVF_IPSEC_TX_DESC_QW1_UDP_MASK (0x1ULL << \ + IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT 6 +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_MASK (0x3ULL << \ + IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT 8 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT 32 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_MASK (0xFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) + +/* Initialization Vector Length type */ +enum iavf_ipsec_iv_len { +IAVF_IPSEC_IV_LEN_NONE ,/* No IV */ +IAVF_IPSEC_IV_LEN_DW ,/* 4B IV */ +IAVF_IPSEC_IV_LEN_DDW ,/* 8B IV */ +IAVF_IPSEC_IV_LEN_QDW ,/* 16B IV */ +}; +/* Statistics collected by each port, VSI, VEB, and S-channel */ struct iavf_eth_stats {u64 rx_bytes;/* gorc */
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -226,6 +229,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -388,7 +393,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2320,6 +2325,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 2/4 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 26 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1918 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 729 +++++-- drivers/net/iavf/iavf_rxtx.h | 579 ++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 14 files changed, 3660 insertions(+), 313 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +26 -0
@@ -189,6 +189,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -216,6 +217,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -238,6 +240,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -249,11 +252,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -272,6 +278,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -340,9 +348,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
@@ -399,5 +422,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1918 -0
1,918 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +96 -0
96 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +492 -237
385 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +563 -16
579 lines not on this page · raw message
drivers/net/iavf/iavf_vchnl.c +114 -52
166 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
Re: [dpdk-dev] [PATCH v2 2/4] net/iavf: add iAVF IPsec inline crypto support
In general, the patch is too big to review. Patch split would help a lot!
[...]
Quoted 6 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +6
-0+static const struct rte_cryptodev_symmetric_capability * +get_capability (struct iavf_security_ctx *iavf_sctx, +uint32_t algo,uint32_t type) +{ +const struct rte_cryptodev_capabilities *capability; +int i =0 ;
drivers/net/iavf/iavf_ipsec_crypto.c line 121
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+ + capability = &iavf_sctx->crypto_capabilities[i]; + +while (capability->op !=RTE_CRYPTO_OP_TYPE_UNDEFINED ) { +if (capability->op ==RTE_CRYPTO_OP_TYPE_SYMMETRIC && + capability->sym.xform_type == type && + capability->sym.cipher.algo == algo) +return &capability->sym; +/** try next capability */ + capability = &iavf_crypto_capabilities[i++];
Better to check i to avoid out of boundary.
[...]
Quoted 5 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +5
-0+ +static int +valid_length (uint32_t len,uint32_t min,uint32_t max,uint32_t increment) +{ +if (len < min || len > max)
drivers/net/iavf/iavf_ipsec_crypto.c line 212
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+return 0 ; + +if (increment ==0 ) +return 1 ; + +if ((len - min) % increment) +return 0 ; + +return 1 ; +}
Would it be better to use true/false instead of 1/0? And the same to following valid functions. [...]
Quoted 30 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +30
-0+static int +iavf_ipsec_crypto_session_validate_conf (struct iavf_security_ctx *iavf_sctx, +struct rte_security_session_conf *conf) +{ +/** validate security action/protocol selection */ +if (conf->action_type !=RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO || + conf->protocol !=RTE_SECURITY_PROTOCOL_IPSEC ) { +PMD_DRV_LOG (ERR ,"Unsupported action / protocol specified" ); +return -EINVAL ; + } + +/** validate IPsec protocol selection */ +if (conf->ipsec.proto !=RTE_SECURITY_IPSEC_SA_PROTO_ESP ) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec protocol specified" ); +return -EINVAL ; + } + +/** validate selected options */ +if (conf->ipsec.options.copy_dscp || + conf->ipsec.options.copy_flabel || + conf->ipsec.options.copy_df || + conf->ipsec.options.dec_ttl || + conf->ipsec.options.ecn || + conf->ipsec.options.stats) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec option specified" ); +return -EINVAL ; + } + +/** +* Validate crypto xforms parameters.
drivers/net/iavf/iavf_ipsec_crypto.c line 313
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+* +* AEAD transforms can be used for either inbound/outbound IPsec SAs, +* for non-AEAD crypto transforms we explicitly only support CIPHER/AUTH +* for outbound and AUTH/CIPHER chained transforms for inbound IPsec. +*/ +if (conf->crypto_xform->type ==RTE_CRYPTO_SYM_XFORM_AEAD ) { +if (!valid_aead_xform (iavf_sctx, &conf->crypto_xform->aead)) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec option specified" ); +return -EINVAL ; + }
Invalid parameter, but not unsupported option, right? Same to below. [...]
Quoted 5 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +5
-0+static void +sa_add_set_aead_params (struct virtchnl_ipsec_crypto_cfg_item *cfg, +struct rte_crypto_aead_xform *aead,uint32_t salt) +{ + cfg->crypto_type =VIRTCHNL_AEAD ;
drivers/net/iavf/iavf_ipsec_crypto.c line 362
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+ +switch (aead->algo) { +case RTE_CRYPTO_AEAD_AES_CCM : + cfg->algo_type =VIRTCHNL_AES_CCM ;break ; +case RTE_CRYPTO_AEAD_AES_GCM : + cfg->algo_type =VIRTCHNL_AES_GCM ;break ; +case RTE_CRYPTO_AEAD_CHACHA20_POLY1305 : + cfg->algo_type =VIRTCHNL_CHACHA20_POLY1305 ;break ; +default : +RTE_ASSERT ("we should be here" );
Assert just because invalid config? Similar comments to other valid functions.
drivers/net/iavf/iavf_ipsec_crypto.c line 371
Quoted 9 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +9
-0+ } + + cfg->key_len = aead->key.length; + cfg->iv_len = aead->iv.length; + cfg->digest_len = aead->digest_length; + cfg->salt = salt; + +RTE_ASSERT (sizeof (cfg->key_data) < cfg->key_len); +
Not only data, but length, better to valid before setting? The same to other kind params setting. [...]
Quoted 32 lines
drivers/net/iavf/iavf_rxtx.c +18
-13+static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) {
drivers/net/iavf/iavf_rxtx.c iavf_xmit_cleanup(struct iavf_tx_queue *txq) · line 2102
Quoted 10 lines
drivers/net/iavf/iavf_rxtx.c +0
-10- *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ;
PKT_TX_TCP_SEG flag implies PKT_TX_TCP_CKSUM,
so the offset cannot removed by just check cusm offload fields. [...]
Quoted 96 lines
struct
iavf_32b_rx_flex_desc_comms{drivers/net/iavf/iavf_rxtx.h +88
-0+ union { + struct { /* Qword 0 */ u8 rxdid; u8 mir_id_umb_cast;@@ -305,6 +375,101 @@ struct iavf_32b_rx_flex_desc_comms { } flex;__le32 ts_high; } flex_ts; + }; +struct { +/* Quad Word 0 */ + +u8 rxdid;/**< Descriptor builder profile ID */ + +u8 mirror_id:6 ; +u8 umbcast:2 ; + +__le16 ptype:10 ; +__le16 flexi_flags_0:6 ; + +__le16 packet_length:14 ; +__le16 rsv_0:2 ; + +__le16 hlen:11 ; +__le16 sph:1 ; +__le16 flexi_flags_1:4 ; + +/* Quad Word 1 */ +union { +__le16 status_error0; +struct { +__le16 status_error0_dd:1 ; +/* descriptor done */ +__le16 status_error0_eop:1 ; +/* end of packet */ +__le16 status_error0_hbo:1 ; +/* header buffer overflow */ +__le16 status_error0_l3l4p:1 ; +/* l3/l4 integrity check */ +__le16 status_error0_xsum:4 ; +/* checksum report */ +__le16 status_error0_lpbk:1 ; +/* loopback */ +__le16 status_error0_ipv6exadd:1 ; +/* ipv6 w/ dst options or routing hdr */ +__le16 status_error0_rxe:1 ; +/* rcv mac errors */ +__le16 status_error0_crcp:1 ; +/* ethernet crc present */ +__le16 status_error0_rsshash:1 ; +/* rss hash valid */ +__le16 status_error0_l2tag1p:1 ; +/* l2 tag 1 present */ +__le16 status_error0_flexi_md0:1 ; +/* flexi md field 0 valid */ +__le16 status_error0_flexi_md1:1 ; +/* flexi md field 1 valid */ + }; + }; +__le16 l2tag1; +__le16 flex_meta0;/**< flexi metadata field 0 */ +__le16 flex_meta1;/**< flexi metadata field 1 */ + +/* Quad Word 2 */ +union { +__le16 status_error1; +struct { +__le16 status_error1_cpm:4 ; +/* Inline IPsec Crypto Status */ +__le16 status_error1_udp_tunnel:1 ; +/* UDP tunnelled packet NAT-T/UDP-NAT */ +__le16 status_error1_crypto:1 ; +/* Inline IPsec Crypto Offload */ +__le16 status_error1_rsv:5 ; +/* Reserved */ +__le16 status_error1_l2tag2p:1 ; +/* l2 tag 2 present */ +__le16 status_error1_flexi_md2:1 ; +/* flexi md field 2 valid */ +__le16 status_error1_flexi_md3:1 ; +/* flexi md field 3 valid */ +__le16 status_error1_flexi_md4:1 ; +/* flexi md field 4 valid */ +__le16 status_error1_flexi_md5:1 ; +/* flexi md field 5 valid */ + }; + }; + +u8 flex_flags2; +u8 time_stamp_low; + +__le16 l2tag2_1st;/**< L2TAG */ +__le16 l2tag2_2nd;/**< L2TAG */ +
drivers/net/iavf/iavf_rxtx.h struct iavf_32b_rx_flex_desc_comms { · line 473
Quoted 10 lines
drivers/net/iavf/iavf_rxtx.h +9
-0+/* Quad Word 3 */ + +__le16 flex_meta2;/**< flexi metadata field 2 */ +__le16 flex_meta3;/**< flexi metadata field 3 */ +__le16 flex_meta4;/**< flexi metadata field 4 */ +__le16 flex_meta5;/**< flexi metadata field 5 */ + + } debug; + }; };
If you check the description of this struct, you will find it is for RxDID Profile ID 16-21. I think you need define a new struct for ipsec. And for debug, also prefer a new struct or some func instead of adding union and fields in defined formatted descriptor. [....]
drivers/net/iavf/iavf_rxtx.h void iavf_dump_rx_descriptor(struct iavf_rx_queue *rxq, · line 959
Quoted 3 lines
drivers/net/iavf/iavf_rxtx.h +3
-0+ +#include <netinet/in.h> +
Put this inline at the beginning of file?
[...]
Quoted 27 lines
drivers/net/iavf/iavf_vchnl.c +19
-2@@ -330,18 +339,40 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)case iavf_aqc_opc_send_msg_to_vf:if (msg_opc ==VIRTCHNL_OP_EVENT ) {iavf_handle_pf_event_msg (dev, info.msg_buf, - info.msg_len); + info.msg_len); }else { +/* check for inline IPsec events */ +struct inline_ipsec_msg *imsg = + (struct inline_ipsec_msg *)info.msg_buf; +struct rte_eth_event_ipsec_desc desc; +if (msg_opc ==VIRTCHNL_OP_INLINE_IPSEC_CRYPTO + && imsg->ipsec_opcode == +INLINE_IPSEC_OP_EVENT ) { +struct virtchnl_ipsec_event *ev = + imsg->ipsec_data.event; + desc.subtype = +RTE_ETH_EVENT_IPSEC_UNKNOWN ; + desc.metadata = ev->ipsec_event_data; +rte_eth_dev_callback_process (dev, +RTE_ETH_EVENT_IPSEC , + &desc); +return ; + } +/* read message and it's expected one */ -if (msg_opc == vf->pend_cmd)
drivers/net/iavf/iavf_vchnl.c iavf_handle_virtchnl_msg(struct rte_eth_dev *dev) · line 367
Quoted 10 lines
drivers/net/iavf/iavf_vchnl.c +5
-5-_notify_cmd (vf, msg_ret); - else - PMD_DRV_LOG(ERR, "command mismatch," -"expect %u, get %u" , - vf->pend_cmd, msg_opc); +if (msg_opc == vf->pend_cmd) { +rte_atomic32_dec (&vf->pend_cmd_count); +if (rte_atomic32_read ( + &vf->pend_cmd_count) ==0 ) +_notify_cmd (vf, msg_ret);
Only dec the count, does the async mean only the second message carries response info?
[...]
Re: [dpdk-dev] [PATCH v2 2/4] net/iavf: add iAVF IPsec inline crypto support
Hi Jingjing, thanks for reviewing!
Quoted 1 line · Jingjing
In general, the patch is too big to review. Patch split would help a lot!
I will do my best to split in in the next revision.
Quoted 11 lines
[...]
Quoted 9 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +9
-0+static const struct rte_cryptodev_symmetric_capability * +get_capability (struct iavf_security_ctx *iavf_sctx, +uint32_t algo,uint32_t type) +{ +const struct rte_cryptodev_capabilities *capability; +int i =0 ; + + capability = &iavf_sctx->crypto_capabilities[i]; +
Quoted 8 lines
drivers/net/iavf/iavf_ipsec_crypto.c line 121
Quoted 7 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +7
-0+while (capability->op !=RTE_CRYPTO_OP_TYPE_UNDEFINED ) { +if (capability->op ==RTE_CRYPTO_OP_TYPE_SYMMETRIC && + capability->sym.xform_type == type && + capability->sym.cipher.algo == algo) +return &capability->sym; +/** try next capability */ + capability = &iavf_crypto_capabilities[i++];Better to check i to avoid out of boundary.
The condition in the while statement plus the last element in the array set as RTE_CRYPTO_OP_TYPE_UNDEFINED prevents the loop from going out of bounds.
Quoted 18 lines
[...]
Quoted 5 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +5
-0+ +static int +valid_length (uint32_t len,uint32_t min,uint32_t max,uint32_t increment) +{ +if (len < min || len > max)drivers/net/iavf/iavf_ipsec_crypto.c line 212
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+return 0 ; + +if (increment ==0 ) +return 1 ; + +if ((len - min) % increment) +return 0 ; + +return 1 ; +}Would it be better to use true/false instead of 1/0? And the same to following valid functions.
Will do.
Quoted 35 lines
[...]
Quoted 33 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +33
-0+static int +iavf_ipsec_crypto_session_validate_conf (struct iavf_security_ctx *iavf_sctx, +struct rte_security_session_conf *conf) +{ +/** validate security action/protocol selection */ +if (conf->action_type !=RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO || + conf->protocol !=RTE_SECURITY_PROTOCOL_IPSEC ) { +PMD_DRV_LOG (ERR ,"Unsupported action / protocol specified" ); +return -EINVAL ; + } + +/** validate IPsec protocol selection */ +if (conf->ipsec.proto !=RTE_SECURITY_IPSEC_SA_PROTO_ESP ) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec protocol specified" ); +return -EINVAL ; + } + +/** validate selected options */ +if (conf->ipsec.options.copy_dscp || + conf->ipsec.options.copy_flabel || + conf->ipsec.options.copy_df || + conf->ipsec.options.dec_ttl || + conf->ipsec.options.ecn || + conf->ipsec.options.stats) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec option specified" ); +return -EINVAL ; + } + +/** +* Validate crypto xforms parameters. +* +* AEAD transforms can be used for either inbound/outbound IPsec SAs, +* for non-AEAD crypto transforms we explicitly only support CIPHER/AUTH
Quoted 8 lines
drivers/net/iavf/iavf_ipsec_crypto.c line 313
Quoted 7 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +7
-0+* for outbound and AUTH/CIPHER chained transforms for inbound IPsec. +*/ +if (conf->crypto_xform->type ==RTE_CRYPTO_SYM_XFORM_AEAD ) { +if (!valid_aead_xform (iavf_sctx, &conf->crypto_xform->aead)) { +PMD_DRV_LOG (ERR ,"Unsupported IPsec option specified" ); +return -EINVAL ; + }Invalid parameter, but not unsupported option, right? Same to below.
I reworked the messages to be consistent
Quoted 18 lines
[...]
Quoted 5 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +5
-0+static void +sa_add_set_aead_params (struct virtchnl_ipsec_crypto_cfg_item *cfg, +struct rte_crypto_aead_xform *aead,uint32_t salt) +{ + cfg->crypto_type =VIRTCHNL_AEAD ;drivers/net/iavf/iavf_ipsec_crypto.c line 362
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +10
-0+ +switch (aead->algo) { +case RTE_CRYPTO_AEAD_AES_CCM : + cfg->algo_type =VIRTCHNL_AES_CCM ;break ; +case RTE_CRYPTO_AEAD_AES_GCM : + cfg->algo_type =VIRTCHNL_AES_GCM ;break ; +case RTE_CRYPTO_AEAD_CHACHA20_POLY1305 : + cfg->algo_type =VIRTCHNL_CHACHA20_POLY1305 ;break ; +default : +RTE_ASSERT ("we should be here" );Assert just because invalid config? Similar comments to other valid functions.
Removed
Quoted 11 lines
drivers/net/iavf/iavf_ipsec_crypto.c line 371
Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.c new file +9
-0+ } + + cfg->key_len = aead->key.length; + cfg->iv_len = aead->iv.length; + cfg->digest_len = aead->digest_length; + cfg->salt = salt; + +RTE_ASSERT (sizeof (cfg->key_data) < cfg->key_len); +Not only data, but length, better to valid before setting? The same to other kind params setting.
The length here is checked to fit into the array, it can still be valid; I moved this check in the valid_length function that can actually return an error.
Quoted 39 lines
[...]
Quoted 36 lines
drivers/net/iavf/iavf_rxtx.c +18
-17+static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }
Quoted 8 lines
drivers/net/iavf/iavf_rxtx.c iavf_xmit_cleanup(struct iavf_tx_queue *txq) · line 2102
Quoted 6 lines
drivers/net/iavf/iavf_rxtx.c +0
-6- -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ;
PKT_TX_TCP_SEGflag impliesPKT_TX_TCP_CKSUM,
so the offset cannot removed by just check cusm offload fields.
I added this back, most likely it was a rebase mistake.
Quoted 104 lines
[...]
Quoted 101 lines
struct iavf_32b_rx_flex_desc_comms {drivers/net/iavf/iavf_rxtx.h +93
-0+ union { + struct { /* Qword 0 */ u8 rxdid; u8 mir_id_umb_cast;@@ -305,6 +375,101 @@ struct iavf_32b_rx_flex_desc_comms { } flex;__le32 ts_high; } flex_ts; + }; +struct { +/* Quad Word 0 */ + +u8 rxdid;/**< Descriptor builder profile ID */ + +u8 mirror_id:6 ; +u8 umbcast:2 ; + +__le16 ptype:10 ; +__le16 flexi_flags_0:6 ; + +__le16 packet_length:14 ; +__le16 rsv_0:2 ; + +__le16 hlen:11 ; +__le16 sph:1 ; +__le16 flexi_flags_1:4 ; + +/* Quad Word 1 */ +union { +__le16 status_error0; +struct { +__le16 status_error0_dd:1 ; +/* descriptor done */ +__le16 status_error0_eop:1 ; +/* end of packet */ +__le16 status_error0_hbo:1 ; +/* header buffer overflow */ +__le16 status_error0_l3l4p:1 ; +/* l3/l4 integrity check */ +__le16 status_error0_xsum:4 ; +/* checksum report */ +__le16 status_error0_lpbk:1 ; +/* loopback */ +__le16 status_error0_ipv6exadd:1 ; +/* ipv6 w/ dst options or routing hdr */ +__le16 status_error0_rxe:1 ; +/* rcv mac errors */ +__le16 status_error0_crcp:1 ; +/* ethernet crc present */ +__le16 status_error0_rsshash:1 ; +/* rss hash valid */ +__le16 status_error0_l2tag1p:1 ; +/* l2 tag 1 present */ +__le16 status_error0_flexi_md0:1 ; +/* flexi md field 0 valid */ +__le16 status_error0_flexi_md1:1 ; +/* flexi md field 1 valid */ + }; + }; +__le16 l2tag1; +__le16 flex_meta0;/**< flexi metadata field 0 */ +__le16 flex_meta1;/**< flexi metadata field 1 */ + +/* Quad Word 2 */ +union { +__le16 status_error1; +struct { +__le16 status_error1_cpm:4 ; +/* Inline IPsec Crypto Status */ +__le16 status_error1_udp_tunnel:1 ; +/* UDP tunnelled packet NAT-T/UDP-NAT */ +__le16 status_error1_crypto:1 ; +/* Inline IPsec Crypto Offload */ +__le16 status_error1_rsv:5 ; +/* Reserved */ +__le16 status_error1_l2tag2p:1 ; +/* l2 tag 2 present */ +__le16 status_error1_flexi_md2:1 ; +/* flexi md field 2 valid */ +__le16 status_error1_flexi_md3:1 ; +/* flexi md field 3 valid */ +__le16 status_error1_flexi_md4:1 ; +/* flexi md field 4 valid */ +__le16 status_error1_flexi_md5:1 ; +/* flexi md field 5 valid */ + }; + }; + +u8 flex_flags2; +u8 time_stamp_low; + +__le16 l2tag2_1st;/**< L2TAG */ +__le16 l2tag2_2nd;/**< L2TAG */ + +/* Quad Word 3 */ + +__le16 flex_meta2;/**< flexi metadata field 2 */ +__le16 flex_meta3;/**< flexi metadata field 3 */ +__le16 flex_meta4;/**< flexi metadata field 4 */
Quoted 8 lines
drivers/net/iavf/iavf_rxtx.h struct iavf_32b_rx_flex_desc_comms { · line 473
Quoted 5 lines
drivers/net/iavf/iavf_rxtx.h +4
-0+__le16 flex_meta5;/**< flexi metadata field 5 */ + + } debug; + }; };If you check the description of this struct, you will find it is for RxDID Profile ID 16-21. I think you need define a new struct for ipsec. And for debug, also prefer a new struct or some func instead of adding union and fields in defined formatted descriptor.
I removed this altogether as it has no functional purpose.
Quoted 7 lines
[....]
drivers/net/iavf/iavf_rxtx.h void iavf_dump_rx_descriptor(struct iavf_rx_queue *rxq, · line 959
Quoted 3 lines
drivers/net/iavf/iavf_rxtx.h +3
-0+ +#include <netinet/in.h> +Put this inline at the beginning of file?
I removed this section
Quoted 32 lines
[...]
Quoted 30 lines
drivers/net/iavf/iavf_vchnl.c +19
-5@@ -330,18 +339,40 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)case iavf_aqc_opc_send_msg_to_vf:if (msg_opc ==VIRTCHNL_OP_EVENT ) {iavf_handle_pf_event_msg (dev, info.msg_buf, - info.msg_len); + info.msg_len); }else { +/* check for inline IPsec events */ +struct inline_ipsec_msg *imsg = + (struct inline_ipsec_msg *)info.msg_buf; +struct rte_eth_event_ipsec_desc desc; +if (msg_opc ==VIRTCHNL_OP_INLINE_IPSEC_CRYPTO + && imsg->ipsec_opcode == +INLINE_IPSEC_OP_EVENT ) { +struct virtchnl_ipsec_event *ev = + imsg->ipsec_data.event; + desc.subtype = +RTE_ETH_EVENT_IPSEC_UNKNOWN ; + desc.metadata = ev->ipsec_event_data; +rte_eth_dev_callback_process (dev, +RTE_ETH_EVENT_IPSEC , + &desc); +return ; + } +/* read message and it's expected one */ -if (msg_opc == vf->pend_cmd) -_notify_cmd (vf, msg_ret); -else - PMD_DRV_LOG(ERR, "command mismatch,"
Quoted 8 lines
drivers/net/iavf/iavf_vchnl.c iavf_handle_virtchnl_msg(struct rte_eth_dev *dev) · line 367
Quoted 7 lines
drivers/net/iavf/iavf_vchnl.c +5
-2-"expect %u, get %u" , - vf->pend_cmd, msg_opc); +if (msg_opc == vf->pend_cmd) { +rte_atomic32_dec (&vf->pend_cmd_count); +if (rte_atomic32_read ( + &vf->pend_cmd_count) ==0 ) +_notify_cmd (vf, msg_ret);Only dec the count, does the async mean only the second message carries response info?
Yes, from my understanding the 1st message is the confirmation of the request and the second is the reply.
Quoted 2 lines
[...]
PATCH v2 3/4 net/iavf: Add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -92,6 +92,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -101,7 +120,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v2 4/4 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
drivers/net/iavf/iavf.h +6 -0
@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +97 -0
121 lines not on this page · raw message
Signature · 1 line
2.25.1
v3 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (6):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 215 +- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 53 +- drivers/net/iavf/iavf_ethdev.c | 222 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1918 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 709 ++++-- drivers/net/iavf/iavf_rxtx.h | 91 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4137 insertions(+), 321 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 4 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback 2.25.1
PATCH v3 1/6 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 215 +++++++- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 775 insertions(+), 10 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +207 -8
@@ -709,11 +709,29 @@ enum iavf_rx_prog_status_desc_error_bits {#define IAVF_FOUR_BIT_MASK 0xF#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF -/* TX Descriptor */ +/* TX Data Descriptor */ struct iavf_tx_desc { -__le64 buffer_addr;/* Address of descriptor's data buf */ -__le64 cmd_type_offset_bsz; -}; +union { +struct { +__le64 buffer_addr;/* Addr of descriptor's data buf */ +__le64 cmd_type_offset_bsz; + }; +struct { +__le64 qw0;/**< data buffer address */ +__le64 qw1;/**< dtyp, cmd, offset, buf_sz and l2tag1 */ + }; +struct { +__le64 buffer_addr;/**< Data buffer address */ +__le64 type:4 ;/**< Descriptor type */ +__le64 cmd:12 ;/**< Command field */ +__le64 offset_l2len:7 ;/**< L2 header length */ +__le64 offset_l3len:7 ;/**< L3 header length */ +__le64 offset_l4len:4 ;/**< L4 header length */ +__le64 buffer_sz:14 ;/**< Data buffer size */ +__le64 l2tag1:16 ;/**< L2 Tag 1 value */ + } debug __rte_packed; + }; +} __rte_packed;#define IAVF_TXD_QW1_DTYPE_SHIFT 0#define IAVF_TXD_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
@@ -723,6 +741,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
@@ -734,7 +753,7 @@ enum iavf_tx_desc_dtype_value {#define IAVF_TXD_QW1_CMD_SHIFT 4#define IAVF_TXD_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_QW1_CMD_SHIFT) -enum iavf_tx_desc_cmd_bits { +enum iavf_tx_data_desc_cmd_bits {IAVF_TX_DESC_CMD_EOP =0x0001 ,IAVF_TX_DESC_CMD_RS =0x0002 ,IAVF_TX_DESC_CMD_ICRC =0x0004 ,
@@ -778,18 +797,79 @@ enum iavf_tx_desc_length_fields {#define IAVF_TXD_QW1_L2TAG1_SHIFT 48#define IAVF_TXD_QW1_L2TAG1_MASK (0xFFFFULL << IAVF_TXD_QW1_L2TAG1_SHIFT) +#define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0) +#define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT) + +#define IAVF_TXD_DATA_QW1_CMD_SHIFT (4) +#define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16) +#define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \ + IAVF_TXD_DATA_QW1_OFFSET_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \ + (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_MACLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_IPLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_L4LEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_FCLEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34) +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \ + (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) + +#define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48) +#define IAVF_TXD_DATA_QW1_L2TAG1_MASK \ + (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT) +/* Context descriptors */ struct iavf_tx_context_desc { +union { +struct {__le32 tunneling_params;__le16 l2tag2;__le16 rsvd;__le64 type_cmd_tso_mss; }; - -#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT 0 +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le32 tunneling; +__le16 l2tag2; +__le16 rsvd0; +__le64 type:4 ; +__le64 cmd:7 ; +__le64 ipsec:7 ; +__le64 rsvd1:12 ; +__le64 tlen_tsyn:18 ; +__le64 rsvd2:2 ; +__le64 mss_target_vsi:14 ; + } debug __rte_packed; + }; +} __rte_packed; + +#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT (0)#define IAVF_TXD_CTX_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_CTX_QW1_DTYPE_SHIFT) -#define IAVF_TXD_CTX_QW1_CMD_SHIFT 4 +#define IAVF_TXD_CTX_QW1_CMD_SHIFT (4)#define IAVF_TXD_CTX_QW1_CMD_MASK (0xFFFFUL << IAVF_TXD_CTX_QW1_CMD_SHIFT)enum iavf_tx_ctx_desc_cmd_bits {
@@ -804,6 +884,63 @@ enum iavf_tx_ctx_desc_cmd_bits {IAVF_TX_CTX_DESC_SWPE =0x40 }; +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \ + (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT) + +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \ + (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \ + (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \ + (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \ + (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_external_ip_type { +IAVF_TX_CTX_DESC_EIPT_NONE , +IAVF_TX_CTX_DESC_EIPT_IPV6 , +IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD , +IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type { +IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE , +IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP , +IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32) +#define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL) +struct iavf_nop_desc {__le64 rsvd;__le64 dtype_cmd;
@@ -911,6 +1048,68 @@ enum iavf_tx_ctx_desc_eipt_offload {#define IAVF_TXD_CTX_QW0_L4T_CS_SHIFT 23#define IAVF_TXD_CTX_QW0_L4T_CS_MASK BIT_ULL(IAVF_TXD_CTX_QW0_L4T_CS_SHIFT) + +struct iavf_tx_ipsec_desc { +union { +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le16 l4payload_length; +__le32 esn; +__le16 trailer_length; +u8 type:4 ; +u8 rsv:1 ; +u8 udp:1 ; +u8 ivlen:2 ; +u8 next_header; +__le16 ipv6_ext_hdr_length; +__le32 said; + } __rte_packed; + }; +} __rte_packed; + +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT 0 +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_MASK (0x3FFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_MASK (0xFFFFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT 48 +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_MASK (0x3FULL << \ + IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT 5 +#define IAVF_IPSEC_TX_DESC_QW1_UDP_MASK (0x1ULL << \ + IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT 6 +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_MASK (0x3ULL << \ + IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT 8 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT 32 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_MASK (0xFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) + +/* Initialization Vector Length type */ +enum iavf_ipsec_iv_len { +IAVF_IPSEC_IV_LEN_NONE ,/* No IV */ +IAVF_IPSEC_IV_LEN_DW ,/* 4B IV */ +IAVF_IPSEC_IV_LEN_DDW ,/* 8B IV */ +IAVF_IPSEC_IV_LEN_QDW ,/* 16B IV */ +}; +/* Statistics collected by each port, VSI, VEB, and S-channel */ struct iavf_eth_stats {u64 rx_bytes;/* gorc */
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2290,6 +2295,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 2/6 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 536 +++++++++++++++------------ drivers/net/iavf/iavf_rxtx.h | 9 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 319 insertions(+), 236 deletions(-)
drivers/net/iavf/iavf_rxtx.c +309 -227
@@ -1048,27 +1048,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1388,7 +1392,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1530,7 +1534,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1768,7 +1772,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2038,7 +2042,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) desc_to_clean_to = (uint16_t )(desc_to_clean_to - nb_tx_desc); desc_to_clean_to = sw_ring[desc_to_clean_to].last_id; -if ((txd[desc_to_clean_to].cmd_type_offset_bsz & +if ((txd[desc_to_clean_to].qw1 &rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )) !=rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE )) { PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
@@ -2054,7 +2058,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) nb_tx_to_clean = (uint16_t )(desc_to_clean_to - last_desc_cleaned); - txd[desc_to_clean_to].cmd_type_offset_bsz =0 ; + txd[desc_to_clean_to].qw1 =0 ; txq->last_desc_cleaned = desc_to_clean_to; txq->nb_free = (uint16_t )(txq->nb_free + nb_tx_to_clean);
@@ -2062,190 +2066,296 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; +} + +static inline void +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) +{ +/* fill descriptor type field */ + desc->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc->qw0, m); +else + desc->qw0 =0 ; + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) { +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; + +/* fill data descriptor qw1 from template */ + desc->qw1 = desc_template; + +/* set data buffer address */ + desc->qw0 =rte_mbuf_data_iova (m); + +/* calculate data buffer size less set header lengths */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + hdrlen += m->outer_l3_len; + +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; -return ctx_desc; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; } -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* set data buffer size */ + desc->qw1 |= (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; - tx_pkt = *tx_pkts++; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; +RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2253,122 +2363,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } + + mb_seg = mb; - m_seg = tx_pkt;do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->qw1 |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
@@ -2869,7 +2951,7 @@ iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset) desc -= txq->nb_tx_desc; } - status = &txq->tx_ring[desc].cmd_type_offset_bsz; + status = &txq->tx_ring[desc].qw1; mask =rte_le_to_cpu_64 (IAVF_TXD_QW1_DTYPE_MASK ); expect =rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE <<IAVF_TXD_QW1_DTYPE_SHIFT );
drivers/net/iavf/iavf_rxtx.h +4 -5
@@ -555,9 +555,9 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq,const volatile struct iavf_tx_desc *tx_desc = desc;enum iavf_tx_desc_dtype_value type; - type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 ( - tx_desc->cmd_type_offset_bsz & -rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )); + + type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 (tx_desc->qw1 & +rte_cpu_to_le_64 (IAVF_TXD_DATA_QW1_DTYPE_MASK ));switch (type) {case IAVF_TX_DESC_DTYPE_DATA : name ="Tx_data_desc" ;
@@ -571,8 +571,7 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq, }printf ("Queue %d %s %d: QW0: 0x%016" PRIx64" QW1: 0x%016" PRIx64"\n" , - txq->queue_id, name, tx_id, tx_desc->buffer_addr, - tx_desc->cmd_type_offset_bsz); + txq->queue_id, name, tx_id, tx_desc->qw0, tx_desc->qw1); }#define FDIR_PROC_ENABLE_PER_QUEUE (ad, on) do { \
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v3 3/6 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 137 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 52 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -189,6 +189,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -340,9 +341,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -52
395 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 4/6 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1918 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 203 +- drivers/net/iavf/iavf_rxtx.h | 94 +- drivers/net/iavf/iavf_vchnl.c | 29 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2777 insertions(+), 22 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -217,6 +217,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -239,6 +240,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -250,11 +252,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -273,6 +278,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -415,5 +422,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1918 -0
1,918 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +96 -0
96 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -12
346 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +88 -6
70 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v3 5/6 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -92,6 +92,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -101,7 +120,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v3 6/6 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
drivers/net/iavf/iavf.h +6 -0
@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +97 -0
121 lines not on this page · raw message
Signature · 1 line
2.25.1
v4 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (6):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 215 +- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 53 +- drivers/net/iavf/iavf_ethdev.c | 222 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 709 ++++-- drivers/net/iavf/iavf_rxtx.h | 91 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4123 insertions(+), 321 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 5 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes 2.25.1
PATCH v4 1/6 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 215 +++++++- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 775 insertions(+), 10 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +207 -8
@@ -709,11 +709,29 @@ enum iavf_rx_prog_status_desc_error_bits {#define IAVF_FOUR_BIT_MASK 0xF#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF -/* TX Descriptor */ +/* TX Data Descriptor */ struct iavf_tx_desc { -__le64 buffer_addr;/* Address of descriptor's data buf */ -__le64 cmd_type_offset_bsz; -}; +union { +struct { +__le64 buffer_addr;/* Addr of descriptor's data buf */ +__le64 cmd_type_offset_bsz; + }; +struct { +__le64 qw0;/**< data buffer address */ +__le64 qw1;/**< dtyp, cmd, offset, buf_sz and l2tag1 */ + }; +struct { +__le64 buffer_addr;/**< Data buffer address */ +__le64 type:4 ;/**< Descriptor type */ +__le64 cmd:12 ;/**< Command field */ +__le64 offset_l2len:7 ;/**< L2 header length */ +__le64 offset_l3len:7 ;/**< L3 header length */ +__le64 offset_l4len:4 ;/**< L4 header length */ +__le64 buffer_sz:14 ;/**< Data buffer size */ +__le64 l2tag1:16 ;/**< L2 Tag 1 value */ + } debug __rte_packed; + }; +} __rte_packed;#define IAVF_TXD_QW1_DTYPE_SHIFT 0#define IAVF_TXD_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
@@ -723,6 +741,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
@@ -734,7 +753,7 @@ enum iavf_tx_desc_dtype_value {#define IAVF_TXD_QW1_CMD_SHIFT 4#define IAVF_TXD_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_QW1_CMD_SHIFT) -enum iavf_tx_desc_cmd_bits { +enum iavf_tx_data_desc_cmd_bits {IAVF_TX_DESC_CMD_EOP =0x0001 ,IAVF_TX_DESC_CMD_RS =0x0002 ,IAVF_TX_DESC_CMD_ICRC =0x0004 ,
@@ -778,18 +797,79 @@ enum iavf_tx_desc_length_fields {#define IAVF_TXD_QW1_L2TAG1_SHIFT 48#define IAVF_TXD_QW1_L2TAG1_MASK (0xFFFFULL << IAVF_TXD_QW1_L2TAG1_SHIFT) +#define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0) +#define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT) + +#define IAVF_TXD_DATA_QW1_CMD_SHIFT (4) +#define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16) +#define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \ + IAVF_TXD_DATA_QW1_OFFSET_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \ + (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_MACLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_IPLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_L4LEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_FCLEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34) +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \ + (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) + +#define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48) +#define IAVF_TXD_DATA_QW1_L2TAG1_MASK \ + (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT) +/* Context descriptors */ struct iavf_tx_context_desc { +union { +struct {__le32 tunneling_params;__le16 l2tag2;__le16 rsvd;__le64 type_cmd_tso_mss; }; - -#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT 0 +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le32 tunneling; +__le16 l2tag2; +__le16 rsvd0; +__le64 type:4 ; +__le64 cmd:7 ; +__le64 ipsec:7 ; +__le64 rsvd1:12 ; +__le64 tlen_tsyn:18 ; +__le64 rsvd2:2 ; +__le64 mss_target_vsi:14 ; + } debug __rte_packed; + }; +} __rte_packed; + +#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT (0)#define IAVF_TXD_CTX_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_CTX_QW1_DTYPE_SHIFT) -#define IAVF_TXD_CTX_QW1_CMD_SHIFT 4 +#define IAVF_TXD_CTX_QW1_CMD_SHIFT (4)#define IAVF_TXD_CTX_QW1_CMD_MASK (0xFFFFUL << IAVF_TXD_CTX_QW1_CMD_SHIFT)enum iavf_tx_ctx_desc_cmd_bits {
@@ -804,6 +884,63 @@ enum iavf_tx_ctx_desc_cmd_bits {IAVF_TX_CTX_DESC_SWPE =0x40 }; +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \ + (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT) + +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \ + (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \ + (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \ + (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \ + (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_external_ip_type { +IAVF_TX_CTX_DESC_EIPT_NONE , +IAVF_TX_CTX_DESC_EIPT_IPV6 , +IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD , +IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type { +IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE , +IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP , +IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32) +#define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL) +struct iavf_nop_desc {__le64 rsvd;__le64 dtype_cmd;
@@ -911,6 +1048,68 @@ enum iavf_tx_ctx_desc_eipt_offload {#define IAVF_TXD_CTX_QW0_L4T_CS_SHIFT 23#define IAVF_TXD_CTX_QW0_L4T_CS_MASK BIT_ULL(IAVF_TXD_CTX_QW0_L4T_CS_SHIFT) + +struct iavf_tx_ipsec_desc { +union { +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le16 l4payload_length; +__le32 esn; +__le16 trailer_length; +u8 type:4 ; +u8 rsv:1 ; +u8 udp:1 ; +u8 ivlen:2 ; +u8 next_header; +__le16 ipv6_ext_hdr_length; +__le32 said; + } __rte_packed; + }; +} __rte_packed; + +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT 0 +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_MASK (0x3FFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_MASK (0xFFFFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT 48 +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_MASK (0x3FULL << \ + IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT 5 +#define IAVF_IPSEC_TX_DESC_QW1_UDP_MASK (0x1ULL << \ + IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT 6 +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_MASK (0x3ULL << \ + IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT 8 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT 32 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_MASK (0xFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) + +/* Initialization Vector Length type */ +enum iavf_ipsec_iv_len { +IAVF_IPSEC_IV_LEN_NONE ,/* No IV */ +IAVF_IPSEC_IV_LEN_DW ,/* 4B IV */ +IAVF_IPSEC_IV_LEN_DDW ,/* 8B IV */ +IAVF_IPSEC_IV_LEN_QDW ,/* 16B IV */ +}; +/* Statistics collected by each port, VSI, VEB, and S-channel */ struct iavf_eth_stats {u64 rx_bytes;/* gorc */
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2290,6 +2295,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 2/6 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 536 +++++++++++++++------------ drivers/net/iavf/iavf_rxtx.h | 9 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 319 insertions(+), 236 deletions(-)
drivers/net/iavf/iavf_rxtx.c +309 -227
@@ -1048,27 +1048,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1388,7 +1392,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1530,7 +1534,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1768,7 +1772,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2038,7 +2042,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) desc_to_clean_to = (uint16_t )(desc_to_clean_to - nb_tx_desc); desc_to_clean_to = sw_ring[desc_to_clean_to].last_id; -if ((txd[desc_to_clean_to].cmd_type_offset_bsz & +if ((txd[desc_to_clean_to].qw1 &rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )) !=rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE )) { PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
@@ -2054,7 +2058,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) nb_tx_to_clean = (uint16_t )(desc_to_clean_to - last_desc_cleaned); - txd[desc_to_clean_to].cmd_type_offset_bsz =0 ; + txd[desc_to_clean_to].qw1 =0 ; txq->last_desc_cleaned = desc_to_clean_to; txq->nb_free = (uint16_t )(txq->nb_free + nb_tx_to_clean);
@@ -2062,190 +2066,296 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; +} + +static inline void +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) +{ +/* fill descriptor type field */ + desc->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc->qw0, m); +else + desc->qw0 =0 ; + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) { +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; + +/* fill data descriptor qw1 from template */ + desc->qw1 = desc_template; + +/* set data buffer address */ + desc->qw0 =rte_mbuf_data_iova (m); + +/* calculate data buffer size less set header lengths */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + hdrlen += m->outer_l3_len; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; + +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; -return ctx_desc; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; } -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* set data buffer size */ + desc->qw1 |= (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2253,122 +2363,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->qw1 |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
@@ -2869,7 +2951,7 @@ iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset) desc -= txq->nb_tx_desc; } - status = &txq->tx_ring[desc].cmd_type_offset_bsz; + status = &txq->tx_ring[desc].qw1; mask =rte_le_to_cpu_64 (IAVF_TXD_QW1_DTYPE_MASK ); expect =rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE <<IAVF_TXD_QW1_DTYPE_SHIFT );
drivers/net/iavf/iavf_rxtx.h +4 -5
@@ -555,9 +555,9 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq,const volatile struct iavf_tx_desc *tx_desc = desc;enum iavf_tx_desc_dtype_value type; - type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 ( - tx_desc->cmd_type_offset_bsz & -rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )); + + type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 (tx_desc->qw1 & +rte_cpu_to_le_64 (IAVF_TXD_DATA_QW1_DTYPE_MASK ));switch (type) {case IAVF_TX_DESC_DTYPE_DATA : name ="Tx_data_desc" ;
@@ -571,8 +571,7 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq, }printf ("Queue %d %s %d: QW0: 0x%016" PRIx64" QW1: 0x%016" PRIx64"\n" , - txq->queue_id, name, tx_id, tx_desc->buffer_addr, - tx_desc->cmd_type_offset_bsz); + txq->queue_id, name, tx_id, tx_desc->qw0, tx_desc->qw1); }#define FDIR_PROC_ENABLE_PER_QUEUE (ad, on) do { \
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v4 2/6] net/iavf: rework tx path
Quoted 16 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:51 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 2/6] net/iavf: rework tx pathRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
Quoted 8 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Abhijit Sinha <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- drivers/net/iavf/iavf_rxtx.c | 536 +++++++++++++++------------ drivers/net/iavf/iavf_rxtx.h | 9 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 319 insertions(+), 236 deletions(-)
PATCH v4 3/6 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 137 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 52 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -189,6 +189,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -340,9 +341,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -52
395 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v4 3/6] net/iavf: add support for asynchronous virt channel messages
Quoted 15 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:51 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 3/6] net/iavf: add support for asynchronous virt channel messagesAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
Quoted 7 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Abhijit Sinha <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 137 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 52 deletions(-)
PATCH v4 4/6 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 201 +- drivers/net/iavf/iavf_rxtx.h | 94 +- drivers/net/iavf/iavf_vchnl.c | 29 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2762 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -217,6 +217,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -239,6 +240,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -250,11 +252,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -273,6 +278,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -415,5 +422,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1904 -0
1,904 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +96 -0
96 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +190 -11
344 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +88 -6
86 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
Re: [dpdk-dev] [PATCH v4 4/6] net/iavf: add iAVF IPsec inline crypto support
Quoted 27 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:51 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 4/6] net/iavf: add iAVF IPsec inline crypto supportAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for
rte_securitypacket metadataAdd definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Quoted 7 lines
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Abhijit Sinha <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
PATCH v4 5/6 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -92,6 +92,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -101,7 +120,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v4 5/6] net/iavf: add xstats support for inline IPsec crypto
Quoted 12 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:51 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 5/6] net/iavf: add xstats support for inline IPsec crypto
Quoted 7 lines
Add per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the
rte_security_session_stats_get()with more detailed errors through therte_ethdevxstats.Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
PATCH v4 6/6 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
drivers/net/iavf/iavf.h +6 -0
@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +97 -0
121 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v4 6/6] net/iavf: add watchdog for VFLR
Quoted 149 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:52 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 6/6] net/iavf: add watchdog for VFLRAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)drivers/net/iavf/iavf.h +6
-0@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;drivers/net/iavf/iavf_ethdev.c +89
-0@@ -24,6 +24,7 @@#include <rte_malloc.h> #include <rte_memzone.h> #include <rte_dev.h> +#include <rte_alarm.h> #include "iavf.h" #include "iavf_rxtx.h" @@ -239,6 +240,94 @@ iavf_tm_ops_get(struct rte_eth_dev *dev __rte_unused,return 0 ; } + +static int +iavf_vfr_inprogress (struct iavf_hw *hw) +{ +int inprogress =0 ; + +if ((IAVF_READ_REG (hw,IAVF_VFGEN_RSTAT ) & +IAVF_VFGEN_RSTAT_VFR_STATE_MASK ) == +VIRTCHNL_VFR_INPROGRESS ) + inprogress =1 ; + +if (inprogress) +PMD_DRV_LOG (INFO ,"Watchdog detected VFR in progress" ); + +return inprogress; +} + +static void +iavf_dev_watchdog (void *cb_arg) +{ +struct iavf_adapter *adapter = cb_arg; +struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (adapter); +int vfr_inprogress =0 , rc =0 ; + +/* check if watchdog has been disabled since last call */ +if (!adapter->vf.watchdog.enabled) +return ; + +/* If in reset then poll vfr_inprogress register for completion */ +if (adapter->vf.vf_reset) { + vfr_inprogress =iavf_vfr_inprogress (hw); + +if (!vfr_inprogress) { +PMD_DRV_LOG (INFO ,"VF \"%s\" reset has completed" , + adapter->eth_dev->data->name); + adapter->vf.vf_reset = false; + } +/* If not in reset then poll vfr_inprogress register for VFLR event */ + }else { + vfr_inprogress =iavf_vfr_inprogress (hw); + +if (vfr_inprogress) { +PMD_DRV_LOG (INFO , +"VF \"%s\" reset event has been detected by watchdog" , + adapter->eth_dev->data->name); + +/* enter reset state with VFLR event */ + adapter->vf.vf_reset = true; + +rte_eth_dev_callback_process (adapter->eth_dev, +RTE_ETH_EVENT_INTR_RESET ,NULL ); + } + } + +/* re-alarm watchdog */ + rc =rte_eal_alarm_set (adapter->vf.watchdog.period_us, + &iavf_dev_watchdog, cb_arg); + +if (rc) +PMD_DRV_LOG (ERR ,"Failed \"%s\" to reset device watchdog alarm" , + adapter->eth_dev->data->name); +} + +static void +iavf_dev_watchdog_enable (struct iavf_adapter *adapter,uint64_t period_us) +{ +int rc; + +PMD_DRV_LOG (INFO ,"Enabling device watchdog" ); + + adapter->vf.watchdog.enabled =1 ; + adapter->vf.watchdog.period_us = period_us; + + rc =rte_eal_alarm_set (adapter->vf.watchdog.period_us, + &iavf_dev_watchdog, (void *)adapter); +if (rc) +PMD_DRV_LOG (ERR ,"Failed to enabled device watchdog" ); +} + +static void +iavf_dev_watchdog_disable (struct iavf_adapter *adapter) +{ +PMD_DRV_LOG (INFO ,"Disabling device watchdog" ); + + adapter->vf.watchdog.enabled =0 ; + adapter->vf.watchdog.period_us =0 ; +} + static int iavf_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addrs,
drivers/net/iavf/iavf_ethdev.c iavf_dev_init(struct rte_eth_dev *eth_dev) · line 2543
Quoted 7 lines
drivers/net/iavf/iavf_ethdev.c +4
-0@@ -2448,6 +2537,11 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)iavf_default_rss_disable (adapter); + +/* Start device watchdog, set polling period to 500us */ +iavf_dev_watchdog_enable (adapter,500 ); +
Besides checking VFGEN_RSTAT, there is a process to handle VIRTCHNL_OP_EVENT from PF. What is the change for? Any scenario which VIRTCHNL_OP_EVENT doesn't cover? And how is the 500us been determined?
Re: [dpdk-dev] [PATCH v4 6/6] net/iavf: add watchdog for VFLR
Quoted 149 lines · Jingjing
Quoted 149 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:52 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 6/6] net/iavf: add watchdog for VFLRAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- drivers/net/iavf/iavf.h | 6 +++ drivers/net/iavf/iavf_ethdev.c | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)drivers/net/iavf/iavf.h +6
-0@@ -212,6 +212,12 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +struct { +uint8_t enabled:1 ; +uint64_t period_us; + } watchdog; +/** iAVF watchdog configuration */ +/* Event from pf */ bool dev_closed;bool link_up;drivers/net/iavf/iavf_ethdev.c +89
-0@@ -24,6 +24,7 @@#include <rte_malloc.h> #include <rte_memzone.h> #include <rte_dev.h> +#include <rte_alarm.h> #include "iavf.h" #include "iavf_rxtx.h" @@ -239,6 +240,94 @@ iavf_tm_ops_get(struct rte_eth_dev *dev __rte_unused,return 0 ; } + +static int +iavf_vfr_inprogress (struct iavf_hw *hw) +{ +int inprogress =0 ; + +if ((IAVF_READ_REG (hw,IAVF_VFGEN_RSTAT ) & +IAVF_VFGEN_RSTAT_VFR_STATE_MASK ) == +VIRTCHNL_VFR_INPROGRESS ) + inprogress =1 ; + +if (inprogress) +PMD_DRV_LOG (INFO ,"Watchdog detected VFR in progress" ); + +return inprogress; +} + +static void +iavf_dev_watchdog (void *cb_arg) +{ +struct iavf_adapter *adapter = cb_arg; +struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (adapter); +int vfr_inprogress =0 , rc =0 ; + +/* check if watchdog has been disabled since last call */ +if (!adapter->vf.watchdog.enabled) +return ; + +/* If in reset then poll vfr_inprogress register for completion */ +if (adapter->vf.vf_reset) { + vfr_inprogress =iavf_vfr_inprogress (hw); + +if (!vfr_inprogress) { +PMD_DRV_LOG (INFO ,"VF \"%s\" reset has completed" , + adapter->eth_dev->data->name); + adapter->vf.vf_reset = false; + } +/* If not in reset then poll vfr_inprogress register for VFLR event */ + }else { + vfr_inprogress =iavf_vfr_inprogress (hw); + +if (vfr_inprogress) { +PMD_DRV_LOG (INFO , +"VF \"%s\" reset event has been detected by watchdog" , + adapter->eth_dev->data->name); + +/* enter reset state with VFLR event */ + adapter->vf.vf_reset = true; + +rte_eth_dev_callback_process (adapter->eth_dev, +RTE_ETH_EVENT_INTR_RESET ,NULL ); + } + } + +/* re-alarm watchdog */ + rc =rte_eal_alarm_set (adapter->vf.watchdog.period_us, + &iavf_dev_watchdog, cb_arg); + +if (rc) +PMD_DRV_LOG (ERR ,"Failed \"%s\" to reset device watchdog alarm" , + adapter->eth_dev->data->name); +} + +static void +iavf_dev_watchdog_enable (struct iavf_adapter *adapter,uint64_t period_us) +{ +int rc; + +PMD_DRV_LOG (INFO ,"Enabling device watchdog" ); + + adapter->vf.watchdog.enabled =1 ; + adapter->vf.watchdog.period_us = period_us; + + rc =rte_eal_alarm_set (adapter->vf.watchdog.period_us, + &iavf_dev_watchdog, (void *)adapter); +if (rc) +PMD_DRV_LOG (ERR ,"Failed to enabled device watchdog" ); +} + +static void +iavf_dev_watchdog_disable (struct iavf_adapter *adapter) +{ +PMD_DRV_LOG (INFO ,"Disabling device watchdog" ); + + adapter->vf.watchdog.enabled =0 ; + adapter->vf.watchdog.period_us =0 ; +} + static int iavf_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addrs,@@ -2448,6 +2537,11 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
Quoted 8 lines
drivers/net/iavf/iavf_ethdev.c iavf_dev_init(struct rte_eth_dev *eth_dev) · line 2543
Quoted 6 lines
drivers/net/iavf/iavf_ethdev.c +4
-0iavf_default_rss_disable (adapter); + +/* Start device watchdog, set polling period to 500us */ +iavf_dev_watchdog_enable (adapter,500 ); +Besides checking
VFGEN_RSTAT, there is a process to handleVIRTCHNL_OP_EVENTfrom PF. What is the change for? Any scenario whichVIRTCHNL_OP_EVENTdoesn't cover? And how is the 500us been determined?
Hi Jingjing, thanks for reviewing, I think this can be handled with the VIRTCHNL_OP_EVENT with no need for a watchdog alarm, I will rework the patch.
Re: [dpdk-dev] [PATCH v4 6/6] net/iavf: add watchdog for VFLR
Quoted 26 lines · Radu
Quoted 24 lines · Jingjing
Quoted 24 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 1, 2021 5:52 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v4 6/6] net/iavf: add watchdog for VFLRAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
drivers/net/iavf/iavf.h | 6 +++
drivers/net/iavf/iavf_ethdev.c| 97
++++++++++++++++++++++++++++++++++2 files changed, 103 insertions(+)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
...
Besides checking
VFGEN_RSTAT, there is a process to handle VIRTCHNL_OP_EVENT from PF. What is the change for? Any scenario which VIRTCHNL_OP_EVENT doesn't cover? And how is the 500us been determined?Hi Jingjing, thanks for reviewing, I think this can be handled with the VIRTCHNL_OP_EVENT with no need for a watchdog alarm, I will rework the patch.
Hi Jingjing I went over this with Declan, the reason it was added is that we can actually have a hardware initiated reset that may not trigger an event; and also the kernel driver is implementing a similar mechanism. The 500us seems indeed excessive I will update the patch to use a configurable value with the default of 5ms, as the kernel driver does.
Re: [dpdk-dev] [PATCH v4 6/6] net/iavf: add watchdog for VFLR
In reply to Nicolau, RaduQuoted 9 lines
Quoted 1 line
Besides checking
VFGEN_RSTAT, there is a process to handle
VIRTCHNL_OP_EVENTfrom PF. What is the change for? Any scenario whichVIRTCHNL_OP_EVENTdoesn't cover?Quoted 1 line
And how is the 500us been determined?
Hi Jingjing, thanks for reviewing, I think this can be handled with the VIRTCHNL_OP_EVENT with no need for a watchdog alarm, I will rework the patch.
Hi, Radu, I saw the patch is reworked, but looks like watchdog is still there. So what is the scenario VIRTCHNL_OP_EVENT doesn't cover?
Re: [dpdk-dev] [PATCH v4 6/6] net/iavf: add watchdog for VFLR
Quoted 10 lines · Jingjing
Quoted 8 lines
Quoted 1 line
Besides checking
VFGEN_RSTAT, there is a process to handle
VIRTCHNL_OP_EVENTfrom PF. What is the change for? Any scenario whichVIRTCHNL_OP_EVENTdoesn't cover?Quoted 1 line
And how is the 500us been determined?
Hi Jingjing, thanks for reviewing, I think this can be handled with the VIRTCHNL_OP_EVENT with no need for a watchdog alarm, I will rework the patch.
Hi, Radu, I saw the patch is reworked, but looks like watchdog is still there. So what is the scenario
VIRTCHNL_OP_EVENTdoesn't cover?
Hi Jingjing I went over this with Declan, the reason it was added is that we can actually have a hardware initiated reset that may not trigger an event; and also the kernel driver is implementing a similar mechanism.
Would it be more acceptable to have it disabled by default?
v5 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (6):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 215 +- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 218 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 709 ++++-- drivers/net/iavf/iavf_rxtx.h | 91 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 166 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4118 insertions(+), 321 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 8 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch 2.25.1
PATCH v5 1/6 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 215 +++++++- drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 775 insertions(+), 10 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +207 -8
@@ -709,11 +709,29 @@ enum iavf_rx_prog_status_desc_error_bits {#define IAVF_FOUR_BIT_MASK 0xF#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF -/* TX Descriptor */ +/* TX Data Descriptor */ struct iavf_tx_desc { -__le64 buffer_addr;/* Address of descriptor's data buf */ -__le64 cmd_type_offset_bsz; -}; +union { +struct { +__le64 buffer_addr;/* Addr of descriptor's data buf */ +__le64 cmd_type_offset_bsz; + }; +struct { +__le64 qw0;/**< data buffer address */ +__le64 qw1;/**< dtyp, cmd, offset, buf_sz and l2tag1 */ + }; +struct { +__le64 buffer_addr;/**< Data buffer address */ +__le64 type:4 ;/**< Descriptor type */ +__le64 cmd:12 ;/**< Command field */ +__le64 offset_l2len:7 ;/**< L2 header length */ +__le64 offset_l3len:7 ;/**< L3 header length */ +__le64 offset_l4len:4 ;/**< L4 header length */ +__le64 buffer_sz:14 ;/**< Data buffer size */ +__le64 l2tag1:16 ;/**< L2 Tag 1 value */ + } debug __rte_packed; + }; +} __rte_packed;#define IAVF_TXD_QW1_DTYPE_SHIFT 0#define IAVF_TXD_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
@@ -723,6 +741,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
@@ -734,7 +753,7 @@ enum iavf_tx_desc_dtype_value {#define IAVF_TXD_QW1_CMD_SHIFT 4#define IAVF_TXD_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_QW1_CMD_SHIFT) -enum iavf_tx_desc_cmd_bits { +enum iavf_tx_data_desc_cmd_bits {IAVF_TX_DESC_CMD_EOP =0x0001 ,IAVF_TX_DESC_CMD_RS =0x0002 ,IAVF_TX_DESC_CMD_ICRC =0x0004 ,
@@ -778,18 +797,79 @@ enum iavf_tx_desc_length_fields {#define IAVF_TXD_QW1_L2TAG1_SHIFT 48#define IAVF_TXD_QW1_L2TAG1_MASK (0xFFFFULL << IAVF_TXD_QW1_L2TAG1_SHIFT) +#define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0) +#define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT) + +#define IAVF_TXD_DATA_QW1_CMD_SHIFT (4) +#define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16) +#define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \ + IAVF_TXD_DATA_QW1_OFFSET_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \ + (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \ + (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \ + (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_MACLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_IPLEN_MASK \ + (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT) +#define IAVF_TXD_DATA_QW1_L4LEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) +#define IAVF_TXD_DATA_QW1_FCLEN_MASK \ + (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT) + +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34) +#define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \ + (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) + +#define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48) +#define IAVF_TXD_DATA_QW1_L2TAG1_MASK \ + (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT) +/* Context descriptors */ struct iavf_tx_context_desc { +union { +struct {__le32 tunneling_params;__le16 l2tag2;__le16 rsvd;__le64 type_cmd_tso_mss; }; - -#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT 0 +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le32 tunneling; +__le16 l2tag2; +__le16 rsvd0; +__le64 type:4 ; +__le64 cmd:7 ; +__le64 ipsec:7 ; +__le64 rsvd1:12 ; +__le64 tlen_tsyn:18 ; +__le64 rsvd2:2 ; +__le64 mss_target_vsi:14 ; + } debug __rte_packed; + }; +} __rte_packed; + +#define IAVF_TXD_CTX_QW1_DTYPE_SHIFT (0)#define IAVF_TXD_CTX_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_CTX_QW1_DTYPE_SHIFT) -#define IAVF_TXD_CTX_QW1_CMD_SHIFT 4 +#define IAVF_TXD_CTX_QW1_CMD_SHIFT (4)#define IAVF_TXD_CTX_QW1_CMD_MASK (0xFFFFUL << IAVF_TXD_CTX_QW1_CMD_SHIFT)enum iavf_tx_ctx_desc_cmd_bits {
@@ -804,6 +884,63 @@ enum iavf_tx_ctx_desc_cmd_bits {IAVF_TX_CTX_DESC_SWPE =0x40 }; +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \ + (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT) + +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14) +#define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \ + (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \ + (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30) +#define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \ + (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT) + +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50) +#define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \ + (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_external_ip_type { +IAVF_TX_CTX_DESC_EIPT_NONE , +IAVF_TX_CTX_DESC_EIPT_IPV6 , +IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD , +IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL) + +enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type { +IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE , +IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP , +IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE +}; + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL) + +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23) +#define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL) + +#define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32) +#define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL) +struct iavf_nop_desc {__le64 rsvd;__le64 dtype_cmd;
@@ -911,6 +1048,68 @@ enum iavf_tx_ctx_desc_eipt_offload {#define IAVF_TXD_CTX_QW0_L4T_CS_SHIFT 23#define IAVF_TXD_CTX_QW0_L4T_CS_MASK BIT_ULL(IAVF_TXD_CTX_QW0_L4T_CS_SHIFT) + +struct iavf_tx_ipsec_desc { +union { +struct { +__le64 qw0; +__le64 qw1; + }; +struct { +__le16 l4payload_length; +__le32 esn; +__le16 trailer_length; +u8 type:4 ; +u8 rsv:1 ; +u8 udp:1 ; +u8 ivlen:2 ; +u8 next_header; +__le16 ipv6_ext_hdr_length; +__le32 said; + } __rte_packed; + }; +} __rte_packed; + +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT 0 +#define IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_MASK (0x3FFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW0_IPSECESN_MASK (0xFFFFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT 48 +#define IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_MASK (0x3FULL << \ + IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT 5 +#define IAVF_IPSEC_TX_DESC_QW1_UDP_MASK (0x1ULL << \ + IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT 6 +#define IAVF_IPSEC_TX_DESC_QW1_IVLEN_MASK (0x3ULL << \ + IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT 8 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECNH_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT 16 +#define IAVF_IPSEC_TX_DESC_QW1_EXTLEN_MASK (0xFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_EXTLEN_SHIFT) + +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT 32 +#define IAVF_IPSEC_TX_DESC_QW1_IPSECSA_MASK (0xFFFFFULL << \ + IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) + +/* Initialization Vector Length type */ +enum iavf_ipsec_iv_len { +IAVF_IPSEC_IV_LEN_NONE ,/* No IV */ +IAVF_IPSEC_IV_LEN_DW ,/* 4B IV */ +IAVF_IPSEC_IV_LEN_DDW ,/* 8B IV */ +IAVF_IPSEC_IV_LEN_QDW ,/* 16B IV */ +}; +/* Statistics collected by each port, VSI, VEB, and S-channel */ struct iavf_eth_stats {u64 rx_bytes;/* gorc */
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2290,6 +2295,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 2/6 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 536 +++++++++++++++------------ drivers/net/iavf/iavf_rxtx.h | 9 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 319 insertions(+), 236 deletions(-)
drivers/net/iavf/iavf_rxtx.c +309 -227
@@ -1048,27 +1048,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1388,7 +1392,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1530,7 +1534,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1768,7 +1772,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2038,7 +2042,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) desc_to_clean_to = (uint16_t )(desc_to_clean_to - nb_tx_desc); desc_to_clean_to = sw_ring[desc_to_clean_to].last_id; -if ((txd[desc_to_clean_to].cmd_type_offset_bsz & +if ((txd[desc_to_clean_to].qw1 &rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )) !=rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE )) { PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
@@ -2054,7 +2058,7 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq) nb_tx_to_clean = (uint16_t )(desc_to_clean_to - last_desc_cleaned); - txd[desc_to_clean_to].cmd_type_offset_bsz =0 ; + txd[desc_to_clean_to].qw1 =0 ; txq->last_desc_cleaned = desc_to_clean_to; txq->nb_free = (uint16_t )(txq->nb_free + nb_tx_to_clean);
@@ -2062,190 +2066,296 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; +} + +static inline void +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) +{ +/* fill descriptor type field */ + desc->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc->qw0, m); +else + desc->qw0 =0 ; + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) { +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; + +/* fill data descriptor qw1 from template */ + desc->qw1 = desc_template; + +/* set data buffer address */ + desc->qw0 =rte_mbuf_data_iova (m); + +/* calculate data buffer size less set header lengths */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + hdrlen += m->outer_l3_len; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; + +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; -return ctx_desc; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; } -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* set data buffer size */ + desc->qw1 |= (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->qw0 =rte_cpu_to_le_64 (desc->qw0); + desc->qw1 =rte_cpu_to_le_64 (desc->qw1); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2253,122 +2363,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->qw1 |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
@@ -2869,7 +2951,7 @@ iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset) desc -= txq->nb_tx_desc; } - status = &txq->tx_ring[desc].cmd_type_offset_bsz; + status = &txq->tx_ring[desc].qw1; mask =rte_le_to_cpu_64 (IAVF_TXD_QW1_DTYPE_MASK ); expect =rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DESC_DONE <<IAVF_TXD_QW1_DTYPE_SHIFT );
drivers/net/iavf/iavf_rxtx.h +4 -5
@@ -555,9 +555,9 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq,const volatile struct iavf_tx_desc *tx_desc = desc;enum iavf_tx_desc_dtype_value type; - type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 ( - tx_desc->cmd_type_offset_bsz & -rte_cpu_to_le_64 (IAVF_TXD_QW1_DTYPE_MASK )); + + type = (enum iavf_tx_desc_dtype_value )rte_le_to_cpu_64 (tx_desc->qw1 & +rte_cpu_to_le_64 (IAVF_TXD_DATA_QW1_DTYPE_MASK ));switch (type) {case IAVF_TX_DESC_DTYPE_DATA : name ="Tx_data_desc" ;
@@ -571,8 +571,7 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq, }printf ("Queue %d %s %d: QW0: 0x%016" PRIx64" QW1: 0x%016" PRIx64"\n" , - txq->queue_id, name, tx_id, tx_desc->buffer_addr, - tx_desc->cmd_type_offset_bsz); + txq->queue_id, name, tx_id, tx_desc->qw0, tx_desc->qw1); }#define FDIR_PROC_ENABLE_PER_QUEUE (ad, on) do { \
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v5 3/6 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 137 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 52 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -189,6 +189,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -340,9 +341,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -52
395 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 4/6 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 96 + .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 201 +- drivers/net/iavf/iavf_rxtx.h | 94 +- drivers/net/iavf/iavf_vchnl.c | 29 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2762 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -217,6 +217,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -239,6 +240,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -250,11 +252,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -273,6 +278,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -415,5 +422,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1904 -0
1,904 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +96 -0
96 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +190 -11
344 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +88 -6
86 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v5 5/6 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -92,6 +92,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -101,7 +120,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v5 6/6 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 93 ++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -29,6 +29,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 5000 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -212,6 +214,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +93 -0
117 lines not on this page · raw message
Signature · 1 line
2.25.1
v6 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Depends on series "new features for ipsec and security libraries"
https://patchwork.dpdk.org/project/dpdk/list/?series=19320
Radu Nicolau (6):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 218 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 713 ++++-- drivers/net/iavf/iavf_rxtx.h | 198 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 168 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4091 insertions(+), 311 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 7 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch v6: rebased and updated the common section 2.25.1
PATCH v6 1/6 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 569 insertions(+), 2 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +1 -0
@@ -723,6 +723,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2291,6 +2296,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 2/6 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 539 ++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 117 +++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 433 insertions(+), 233 deletions(-)
drivers/net/iavf/iavf_rxtx.c +315 -224
@@ -1054,27 +1054,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1394,7 +1398,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1536,7 +1540,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1774,7 +1778,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2068,190 +2072,305 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; } + +struct iavf_tx_context_desc_qws { +__le64 qw0; +__le64 qw1; +}; +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) { +volatile struct iavf_tx_context_desc_qws *desc_qws = + (volatile struct iavf_tx_context_desc_qws *) desc; +/* fill descriptor type field */ + desc_qws->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc_qws->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc_qws->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc_qws->qw0, m); +else + desc_qws->qw0 =0 ; + + desc_qws->qw0 =rte_cpu_to_le_64 (desc_qws->qw0); + desc_qws->qw1 =rte_cpu_to_le_64 (desc_qws->qw1); +} + + +static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; + +/* fill data descriptor qw1 from template */ + desc->cmd_type_offset_bsz = desc_template; + +/* set data buffer address */ + desc->buffer_addr =rte_mbuf_data_iova (m); + +/* calculate data buffer size less set header lengths */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + hdrlen += m->outer_l3_len; + +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; -return ctx_desc; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; } -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* set data buffer size */ + desc->cmd_type_offset_bsz |= + (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->buffer_addr =rte_cpu_to_le_64 (desc->buffer_addr); + desc->cmd_type_offset_bsz =rte_cpu_to_le_64 (desc->cmd_type_offset_bsz); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2259,122 +2378,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->cmd_type_offset_bsz |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
drivers/net/iavf/iavf_rxtx.h +112 -5
135 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v6 3/6 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 138 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 53 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -193,6 +193,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -345,9 +346,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -53
396 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 4/6 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 202 +- drivers/net/iavf/iavf_rxtx.h | 93 +- drivers/net/iavf/iavf_vchnl.c | 30 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2827 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -221,6 +221,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -243,6 +244,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -254,11 +256,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -277,6 +282,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -421,5 +428,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1904 -0
1,904 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +160 -0
160 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -11
345 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +87 -6
21 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v6 5/6 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -96,6 +96,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -105,7 +124,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v6 6/6 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
The watchdog is disabled by default, to enable it set IAVF_DEV_WATCHDOG_PERIOD to a non zero value (microseconds)
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 93 ++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -31,6 +31,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -216,6 +218,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +93 -0
117 lines not on this page · raw message
Signature · 1 line
2.25.1
v7 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Depends on series "new features for ipsec and security libraries"
https://patchwork.dpdk.org/project/dpdk/list/?series=19593
Radu Nicolau (6):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 219 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 710 ++++-- drivers/net/iavf/iavf_rxtx.h | 198 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 168 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 17 files changed, 4089 insertions(+), 311 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 8 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch v6: rebased and updated the common section v7: fixed TSO issue and disabled watchdod by default 2.25.1
PATCH v7 1/6 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 569 insertions(+), 2 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +1 -0
@@ -723,6 +723,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2291,6 +2296,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 2/6 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 538 ++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 117 +++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 431 insertions(+), 234 deletions(-)
drivers/net/iavf/iavf_rxtx.c +313 -225
@@ -1054,27 +1054,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1394,7 +1398,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1536,7 +1540,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1774,7 +1778,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2068,190 +2072,302 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; } + +struct iavf_tx_context_desc_qws { +__le64 qw0; +__le64 qw1; +}; +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) { +volatile struct iavf_tx_context_desc_qws *desc_qws = + (volatile struct iavf_tx_context_desc_qws *) desc; +/* fill descriptor type field */ + desc_qws->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc_qws->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc_qws->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc_qws->qw0, m); +else + desc_qws->qw0 =0 ; + + desc_qws->qw0 =rte_cpu_to_le_64 (desc_qws->qw0); + desc_qws->qw1 =rte_cpu_to_le_64 (desc_qws->qw1); +} + + +static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +/* fill data descriptor qw1 from template */ + desc->cmd_type_offset_bsz = desc_template; -return ctx_desc; -} +/* set data buffer address */ + desc->buffer_addr =rte_mbuf_data_iova (m); -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* calculate data buffer size less set header lengths */ +if ((m->ol_flags &PKT_TX_TUNNEL_MASK ) && + (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG ))) { + hdrlen += m->outer_l3_len; +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; + } + +/* set data buffer size */ + desc->cmd_type_offset_bsz |= + (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->buffer_addr =rte_cpu_to_le_64 (desc->buffer_addr); + desc->cmd_type_offset_bsz =rte_cpu_to_le_64 (desc->cmd_type_offset_bsz); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2259,122 +2375,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->cmd_type_offset_bsz |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
drivers/net/iavf/iavf_rxtx.h +112 -5
135 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v7 3/6 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 138 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 53 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -193,6 +193,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -345,9 +346,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -53
396 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 4/6 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 16 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1904 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 202 +- drivers/net/iavf/iavf_rxtx.h | 93 +- drivers/net/iavf/iavf_vchnl.c | 30 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2827 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -221,6 +221,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -243,6 +244,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -254,11 +256,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev *eth_dev;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -277,6 +282,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -421,5 +428,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +16 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,14 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ; +if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2076,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1904 -0
1,904 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +160 -0
160 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -11
345 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +87 -6
21 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v7 5/6 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -96,6 +96,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -105,7 +124,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v7 6/6 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
The watchdog is disabled by default, to enable it set IAVF_DEV_WATCHDOG_PERIOD to a non zero value (microseconds)
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -31,6 +31,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -216,6 +218,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.25.1
v8 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Depends on series "new features for ipsec and security libraries"
https://patchwork.dpdk.org/project/dpdk/list/?series=19658
Radu Nicolau (7):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
net/iavf: update doc with inline crypto support
doc/guides/nics/features/iavf.ini | 2 + doc/guides/nics/intel_vf.rst | 10 + doc/guides/rel_notes/release_21_11.rst | 1 + drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 219 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1891 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 710 +++++-- drivers/net/iavf/iavf_rxtx.h | 198 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 168 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 20 files changed, 4088 insertions(+), 311 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 9 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch v6: rebased and updated the common section v7: fixed TSO issue and disabled watchdog by default v8: rebased to next-net-intel and added doc updates 2.25.1
PATCH v8 1/7 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 569 insertions(+), 2 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +1 -0
@@ -723,6 +723,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2291,6 +2296,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 2/7 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 538 ++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 117 +++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 431 insertions(+), 234 deletions(-)
drivers/net/iavf/iavf_rxtx.c +313 -225
@@ -1054,27 +1054,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1394,7 +1398,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1536,7 +1540,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1774,7 +1778,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2068,190 +2072,302 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; } + +struct iavf_tx_context_desc_qws { +__le64 qw0; +__le64 qw1; +}; +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) { +volatile struct iavf_tx_context_desc_qws *desc_qws = + (volatile struct iavf_tx_context_desc_qws *)desc; +/* fill descriptor type field */ + desc_qws->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc_qws->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc_qws->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc_qws->qw0, m); +else + desc_qws->qw0 =0 ; + + desc_qws->qw0 =rte_cpu_to_le_64 (desc_qws->qw0); + desc_qws->qw1 =rte_cpu_to_le_64 (desc_qws->qw1); +} + + +static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +/* fill data descriptor qw1 from template */ + desc->cmd_type_offset_bsz = desc_template; -return ctx_desc; -} +/* set data buffer address */ + desc->buffer_addr =rte_mbuf_data_iova (m); -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* calculate data buffer size less set header lengths */ +if ((m->ol_flags &PKT_TX_TUNNEL_MASK ) && + (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG ))) { + hdrlen += m->outer_l3_len; +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; + } + +/* set data buffer size */ + desc->cmd_type_offset_bsz |= + (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->buffer_addr =rte_cpu_to_le_64 (desc->buffer_addr); + desc->cmd_type_offset_bsz =rte_cpu_to_le_64 (desc->cmd_type_offset_bsz); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2259,122 +2375,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->cmd_type_offset_bsz |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
drivers/net/iavf/iavf_rxtx.h +112 -5
135 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v8 3/7 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 138 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 53 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -193,6 +193,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -345,9 +346,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -53
396 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 4/7 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1891 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 202 +- drivers/net/iavf/iavf_rxtx.h | 93 +- drivers/net/iavf/iavf_vchnl.c | 30 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2813 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -221,6 +221,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -245,6 +246,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -256,11 +258,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev_data *dev_data;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -279,6 +284,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -421,5 +428,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +15 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,13 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ;if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2075,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1891 -0
1,891 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +160 -0
160 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -11
345 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +87 -6
35 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v8 5/7 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -96,6 +96,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -105,7 +124,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v8 6/7 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
The watchdog is disabled by default, to enable it set IAVF_DEV_WATCHDOG_PERIOD to a non zero value (microseconds)
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -31,6 +31,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -216,6 +218,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v8 6/7] net/iavf: add watchdog for VFLR
Quoted 17 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, October 15, 2021 6:15 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Sinha, Abhijit <[email protected]>; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [PATCH v8 6/7] net/iavf: add watchdog for VFLRAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
Quoted 5 lines
The watchdog is disabled by default, to enable it set
IAVF_DEV_WATCHDOG_PERIODto a non zero value (microseconds)Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
PATCH v8 7/7 net/iavf: update doc with inline crypto support
In reply to Radu NicolauUpdate the PMD doc, feature matrix and release notes with the new inline crypto feature.
--- doc/guides/nics/features/iavf.ini | 2 ++ doc/guides/nics/intel_vf.rst | 10 ++++++++++ doc/guides/rel_notes/release_21_11.rst | 1 + 3 files changed, 13 insertions(+)
doc/guides/nics/features/iavf.ini +2 -0
@@ -28,6 +28,7 @@ L4 checksum offload = P Packet type parsing = Y Rx descriptor status = Y Tx descriptor status = Y +Inline crypto = Y Basic stats = Y Multiprocess aware = Y FreeBSD = Y
@@ -64,3 +65,4 @@ mark = Y passthru = Y queue = Y rss = Y +security = Y
doc/guides/nics/intel_vf.rst +10 -0
@@ -633,3 +633,13 @@ Windows Support * To load NetUIO driver, follow the steps mentioned in `dpdk-kmods repository <https://git.dpdk.org/dpdk-kmods/tree/windows/netuio/README.rst>`_. + + +Inline IPsec Support +-------------------- + +* IAVF PMD supports inline crypto processing depending on the underlying + hardware crypto capabilities. IPsec Security Gateway Sample Application + supports inline IPsec processing for IAVF PMD. For more details see the + IPsec Security Gateway Sample Application and Security library + documentation.
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -95,6 +95,7 @@ New Features * Added Intel iavf support on Windows. * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow. + * Added Intel iavf inline crypto support. * **Updated Intel ice driver.**
Signature · 1 line
2.25.1
v9 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Depends on series "new features for ipsec and security libraries"
https://patchwork.dpdk.org/project/dpdk/list/?series=19593
Radu Nicolau (4):
common/iavf: add iAVF IPsec inline crypto support net/iavf: add iAVF IPsec inline crypto support net/iavf: Add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
doc/guides/nics/features/iavf.ini | 2 + doc/guides/nics/intel_vf.rst | 10 + doc/guides/rel_notes/release_21_11.rst | 1 + drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 219 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1895 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 710 ++++-- drivers/net/iavf/iavf_rxtx.h | 198 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 168 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 20 files changed, 4092 insertions(+), 311 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 10 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch v6: rebased and updated the common section v7: fixed TSO issue and disabled watchdog by default v8: rebased to next-net-intel and added doc updates v9: fixed IV len for AEAD and GMAC 2.25.1
PATCH v9 1/7 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 569 insertions(+), 2 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +1 -0
@@ -723,6 +723,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2291,6 +2296,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 2/7 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 538 ++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 117 +++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 431 insertions(+), 234 deletions(-)
drivers/net/iavf/iavf_rxtx.c +313 -225
@@ -1054,27 +1054,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1394,7 +1398,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1536,7 +1540,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1774,7 +1778,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2068,190 +2072,302 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; } + +struct iavf_tx_context_desc_qws { +__le64 qw0; +__le64 qw1; +}; +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) { +volatile struct iavf_tx_context_desc_qws *desc_qws = + (volatile struct iavf_tx_context_desc_qws *)desc; +/* fill descriptor type field */ + desc_qws->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc_qws->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc_qws->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc_qws->qw0, m); +else + desc_qws->qw0 =0 ; + + desc_qws->qw0 =rte_cpu_to_le_64 (desc_qws->qw0); + desc_qws->qw1 =rte_cpu_to_le_64 (desc_qws->qw1); +} + + +static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +/* fill data descriptor qw1 from template */ + desc->cmd_type_offset_bsz = desc_template; -return ctx_desc; -} +/* set data buffer address */ + desc->buffer_addr =rte_mbuf_data_iova (m); -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* calculate data buffer size less set header lengths */ +if ((m->ol_flags &PKT_TX_TUNNEL_MASK ) && + (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG ))) { + hdrlen += m->outer_l3_len; +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; + } + +/* set data buffer size */ + desc->cmd_type_offset_bsz |= + (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->buffer_addr =rte_cpu_to_le_64 (desc->buffer_addr); + desc->cmd_type_offset_bsz =rte_cpu_to_le_64 (desc->cmd_type_offset_bsz); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2259,122 +2375,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->cmd_type_offset_bsz |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
drivers/net/iavf/iavf_rxtx.h +112 -5
135 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v9 3/7 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 138 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 53 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -193,6 +193,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -345,9 +346,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -53
396 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 4/7 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgement from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1895 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 202 +- drivers/net/iavf/iavf_rxtx.h | 93 +- drivers/net/iavf/iavf_vchnl.c | 30 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2817 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -221,6 +221,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -245,6 +246,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -256,11 +258,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev_data *dev_data;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -279,6 +284,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -421,5 +428,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +15 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,13 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ;if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2075,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1895 -0
1,895 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +160 -0
160 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -11
345 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +87 -6
31 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v9 5/7 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -96,6 +96,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -105,7 +124,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v9 6/7 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
The watchdog is disabled by default, to enable it set IAVF_DEV_WATCHDOG_PERIOD to a non zero value (microseconds)
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -31,6 +31,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -216,6 +218,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 7/7 net/iavf: update doc with inline crypto support
In reply to Radu NicolauUpdate the PMD doc, feature matrix and release notes with the new inline crypto feature.
--- doc/guides/nics/features/iavf.ini | 2 ++ doc/guides/nics/intel_vf.rst | 10 ++++++++++ doc/guides/rel_notes/release_21_11.rst | 1 + 3 files changed, 13 insertions(+)
doc/guides/nics/features/iavf.ini +2 -0
@@ -28,6 +28,7 @@ L4 checksum offload = P Packet type parsing = Y Rx descriptor status = Y Tx descriptor status = Y +Inline crypto = Y Basic stats = Y Multiprocess aware = Y FreeBSD = Y
@@ -64,3 +65,4 @@ mark = Y passthru = Y queue = Y rss = Y +security = Y
doc/guides/nics/intel_vf.rst +10 -0
@@ -633,3 +633,13 @@ Windows Support * To load NetUIO driver, follow the steps mentioned in `dpdk-kmods repository <https://git.dpdk.org/dpdk-kmods/tree/windows/netuio/README.rst>`_. + + +Inline IPsec Support +-------------------- + +* IAVF PMD supports inline crypto processing depending on the underlying + hardware crypto capabilities. IPsec Security Gateway Sample Application + supports inline IPsec processing for IAVF PMD. For more details see the + IPsec Security Gateway Sample Application and Security library + documentation.
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -112,6 +112,7 @@ New Features * Added Intel iavf support on Windows. * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow. + * Added Intel iavf inline crypto support. * **Updated Intel ice driver.**
Signature · 1 line
2.25.1
v10 cover iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows.
Radu Nicolau (7):
common/iavf: add iAVF IPsec inline crypto support net/iavf: rework tx path
net/iavf: add support for asynchronous virt channel messages net/iavf: add iAVF IPsec inline crypto support net/iavf: add xstats support for inline IPsec crypto net/iavf: add watchdog for VFLR
net/iavf: update doc with inline crypto support
doc/guides/nics/features/iavf.ini | 2 + doc/guides/nics/intel_vf.rst | 10 + doc/guides/rel_notes/release_21_11.rst | 1 + drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 +++++ drivers/net/iavf/iavf.h | 52 +- drivers/net/iavf/iavf_ethdev.c | 219 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1894 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 710 ++++-- drivers/net/iavf/iavf_rxtx.h | 198 +- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- drivers/net/iavf/iavf_vchnl.c | 167 +- drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 20 files changed, 4090 insertions(+), 311 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
Signature · 11 lines
v2: small updates and fixes in the flow related section v3: split the huge patch and address feedback v4: small changes due to dependencies changes v5: updated the watchdow patch v6: rebased and updated the common section v7: fixed TSO issue and disabled watchdog by default v8: rebased to next-net-intel and added doc updates v9: fixed IV len for AEAD and GMAC v10: removed blank lines at EOF 2.25.1
PATCH v10 1/7 common/iavf: add iAVF IPsec inline crypto support
Add support for inline crypto for IPsec.
--- drivers/common/iavf/iavf_type.h | 1 + drivers/common/iavf/virtchnl.h | 17 +- drivers/common/iavf/virtchnl_inline_ipsec.h | 553 ++++++++++++++++++++ 3 files changed, 569 insertions(+), 2 deletions(-) create mode 100644 drivers/common/iavf/virtchnl_inline_ipsec.h
drivers/common/iavf/iavf_type.h +1 -0
@@ -723,6 +723,7 @@ enum iavf_tx_desc_dtype_value {IAVF_TX_DESC_DTYPE_NOP =0x1 ,/* same as Context desc */ IAVF_TX_DESC_DTYPE_CONTEXT =0x1 ,IAVF_TX_DESC_DTYPE_FCOE_CTX =0x2 , +IAVF_TX_DESC_DTYPE_IPSEC =0x3 ,IAVF_TX_DESC_DTYPE_FILTER_PROG =0x8 ,IAVF_TX_DESC_DTYPE_DDP_CTX =0x9 , IAVF_TX_DESC_DTYPE_FLEX_DATA = 0xB,
drivers/common/iavf/virtchnl.h +15 -2
@@ -38,6 +38,8 @@* value in current and future projects */ +#include "virtchnl_inline_ipsec.h" +/* Error Codes */ enum virtchnl_status_code {VIRTCHNL_STATUS_SUCCESS =0 ,
@@ -133,7 +135,8 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcodes 34, 35, 36, and 37 are reserved */ +VIRTCHNL_OP_INLINE_IPSEC_CRYPTO =34 , +/* opcodes 35 and 36 are reserved */ VIRTCHNL_OP_DCF_CONFIG_BW =37 ,VIRTCHNL_OP_DCF_VLAN_OFFLOAD =38 , VIRTCHNL_OP_DCF_CMD_DESC = 39,
@@ -225,6 +228,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)return "VIRTCHNL_OP_ADD_CLOUD_FILTER" ;case VIRTCHNL_OP_DEL_CLOUD_FILTER :return "VIRTCHNL_OP_DEL_CLOUD_FILTER" ; +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : +return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO" ;case VIRTCHNL_OP_DCF_CMD_DESC :return "VIRTCHNL_OP_DCF_CMD_DESC" ;case VIRTCHNL_OP_DCF_CMD_BUFF :
@@ -385,7 +390,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)/* used to negotiate communicating link speeds in Mbps */ #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) -/* BIT(8) is reserved */ +#define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
@@ -2291,6 +2296,14 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,sizeof (struct virtchnl_queue_vector ); }break ; + +case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO : + { +struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg; + valid_len = +virtchnl_inline_ipsec_val_msg_len (iim->ipsec_opcode); +break ; + }/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
drivers/common/iavf/virtchnl_inline_ipsec.h new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v10 2/7 net/iavf: rework tx path
In reply to Radu NicolauRework the TX path and TX descriptor usage in order to allow for better use of oflload flags and to facilitate enabling of inline crypto offload feature.
--- drivers/net/iavf/iavf_rxtx.c | 538 ++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 117 +++++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 10 +- 3 files changed, 431 insertions(+), 234 deletions(-)
drivers/net/iavf/iavf_rxtx.c +313 -225
@@ -1054,27 +1054,31 @@ iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)static inline void iavf_flex_rxd_to_vlan_tci (struct rte_mbuf *mb, -volatile union iavf_rx_flex_desc *rxdp, -uint8_t rx_flags) +volatile union iavf_rx_flex_desc *rxdp) { -uint16_t vlan_tci =0 ; - -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1 && -rte_le_to_cpu_64 (rxdp->wb.status_error0) & - (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag1); +if (rte_le_to_cpu_64 (rxdp->wb.status_error0) & + (1 <<IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) { + mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; + mb->vlan_tci = +rte_le_to_cpu_16 (rxdp->wb.l2tag1); + }else { + mb->vlan_tci =0 ; + }#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC -if (rx_flags &IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2 && -rte_le_to_cpu_16 (rxdp->wb.status_error1) & - (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) - vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); -#endif - -if (vlan_tci) { - mb->ol_flags |=PKT_RX_VLAN |PKT_RX_VLAN_STRIPPED ; - mb->vlan_tci = vlan_tci; +if (rte_le_to_cpu_16 (rxdp->wb.status_error1) & + (1 <<IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) { + mb->ol_flags |=PKT_RX_QINQ_STRIPPED |PKT_RX_QINQ | +PKT_RX_VLAN_STRIPPED |PKT_RX_VLAN ; + mb->vlan_tci_outer = mb->vlan_tci; + mb->vlan_tci =rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd); +PMD_RX_LOG (DEBUG ,"Descriptor l2tag2_1: %u, l2tag2_2: %u" , +rte_le_to_cpu_16 (rxdp->wb.l2tag2_1st), +rte_le_to_cpu_16 (rxdp->wb.l2tag2_2nd)); + }else { + mb->vlan_tci_outer =0 ; } +#endif }/* Translate the rx descriptor status and error fields to pkt flags */
@@ -1394,7 +1398,7 @@ iavf_recv_pkts_flex_rxd(void *rx_queue, rxm->ol_flags =0 ; rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (rxm, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (rxm, &rxd); rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0); rxm->ol_flags |= pkt_flags;
@@ -1536,7 +1540,7 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->ol_flags =0 ; first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (first_seg, &rxd, rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (first_seg, &rxd); rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (rx_stat_err0);
@@ -1774,7 +1778,7 @@ iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq) mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)]; -iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j], rxq->rx_flags); +iavf_flex_rxd_to_vlan_tci (mb, &rxdp[j]); rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); stat_err0 =rte_le_to_cpu_16 (rxdp[j].wb.status_error0); pkt_flags =iavf_flex_rxd_error_to_pkt_flags (stat_err0);
@@ -2068,190 +2072,302 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)return 0 ; } -/* Check if the context descriptor is needed for TX offloading */ + + +static inline void +iavf_fill_ctx_desc_cmd_field (volatile uint64_t *field,struct rte_mbuf *m) +{ +uint64_t cmd =0 ; + +/* TSO enabled */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) + cmd =IAVF_TX_CTX_DESC_TSO <<IAVF_TXD_DATA_QW1_CMD_SHIFT ; + +/* Time Sync - Currently not supported */ + +/* Outer L2 TAG 2 Insertion - Currently not supported */ +/* Inner L2 TAG 2 Insertion - Currently not supported */ + + *field |= cmd; +} + +static inline void +iavf_fill_ctx_desc_tunnelling_field (volatile uint64_t *qw0, +const struct rte_mbuf *m) +{ +uint64_t eip_typ =IAVF_TX_CTX_DESC_EIPT_NONE ; +uint64_t eip_len =0 ; +uint64_t eip_noinc =0 ; +/* Default - IP_ID is increment in each segment of LSO */ + +switch (m->ol_flags & (PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IPV6 | +PKT_TX_OUTER_IP_CKSUM )) { +case PKT_TX_OUTER_IPV4 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV4 |PKT_TX_OUTER_IP_CKSUM : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD ; + eip_len = m->outer_l3_len >>2 ; +break ; +case PKT_TX_OUTER_IPV6 : + eip_typ =IAVF_TX_CTX_DESC_EIPT_IPV6 ; + eip_len = m->outer_l3_len >>2 ; +break ; + } + + *qw0 = eip_typ <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT | + eip_len <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT | + eip_noinc <<IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT ; +} +static inline uint16_t -iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) +iavf_fill_ctx_desc_segmentation_field (volatile uint64_t *field, +struct rte_mbuf *m) { -if (flags &PKT_TX_TCP_SEG ) -return 1 ; -if (flags &PKT_TX_VLAN_PKT && - vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) -return 1 ; -return 0 ; +uint64_t segmentation_field =0 ; +uint64_t total_length =0 ; + + total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len); + +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) + total_length -= m->outer_l3_len; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +if (!m->l4_len || !m->tso_segsz) +PMD_TX_LOG (DEBUG ,"L4 length %d, LSO Segment size %d" , + m->l4_len, m->tso_segsz); +if (m->tso_segsz <88 ) +PMD_TX_LOG (DEBUG ,"LSO Segment size %d is less than minimum %d" , + m->tso_segsz,88 ); +#endif + segmentation_field = + (((uint64_t )total_length <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) & +IAVF_TXD_CTX_QW1_TSO_LEN_MASK ) | + (((uint64_t )m->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ) & +IAVF_TXD_CTX_QW1_MSS_MASK ); + + *field |= segmentation_field; + +return total_length; } + +struct iavf_tx_context_desc_qws { +__le64 qw0; +__le64 qw1; +}; +static inline void -iavf_txd_enable_checksum (uint64_t ol_flags, -uint32_t *td_cmd, -uint32_t *td_offset, -union iavf_tx_offload tx_offload) +iavf_fill_context_desc (volatile struct iavf_tx_context_desc *desc, +struct rte_mbuf *m,uint16_t *tlen) { +volatile struct iavf_tx_context_desc_qws *desc_qws = + (volatile struct iavf_tx_context_desc_qws *)desc; +/* fill descriptor type field */ + desc_qws->qw1 =IAVF_TX_DESC_DTYPE_CONTEXT ; + +/* fill command field */ +iavf_fill_ctx_desc_cmd_field (&desc_qws->qw1, m); + +/* fill segmentation field */ +if (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG )) { + *tlen =iavf_fill_ctx_desc_segmentation_field (&desc_qws->qw1, + m); + } + +/* fill tunnelling field */ +if (m->ol_flags &PKT_TX_TUNNEL_MASK ) +iavf_fill_ctx_desc_tunnelling_field (&desc_qws->qw0, m); +else + desc_qws->qw0 =0 ; + + desc_qws->qw0 =rte_cpu_to_le_64 (desc_qws->qw0); + desc_qws->qw1 =rte_cpu_to_le_64 (desc_qws->qw1); +} + + +static inline void +iavf_build_data_desc_cmd_offset_fields (volatile uint64_t *qw1, +struct rte_mbuf *m) +{ +uint64_t command =0 ; +uint64_t offset =0 ; +uint64_t l2tag1 =0 ; + + *qw1 =IAVF_TX_DESC_DTYPE_DATA ; + + command = (uint64_t )IAVF_TX_DESC_CMD_ICRC ; + +/* Descriptor based VLAN insertion */ +if (m->ol_flags &PKT_TX_VLAN_PKT ) { + command |= (uint64_t )IAVF_TX_DESC_CMD_IL2TAG1 ; + l2tag1 |= m->vlan_tci; + } +/* Set MACLEN */ - *td_offset |= (tx_offload.l2_len >>1 ) << -IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; - -/* Enable L3 checksum offloads */ -if (ol_flags &PKT_TX_IP_CKSUM ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV4 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - }else if (ol_flags &PKT_TX_IPV6 ) { - *td_cmd |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; - *td_offset |= (tx_offload.l3_len >>2 ) << -IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; - } - -if (ol_flags &PKT_TX_TCP_SEG ) { - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (tx_offload.l4_len >>2 ) << + offset |= (m->l2_len >>1 ) <<IAVF_TX_DESC_LENGTH_MACLEN_SHIFT ; + +/* Enable L3 checksum offloading inner */ +if (m->ol_flags & (PKT_TX_IP_CKSUM |PKT_TX_IPV4 )) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV4 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV4 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + }else if (m->ol_flags &PKT_TX_IPV6 ) { + command |=IAVF_TX_DESC_CMD_IIPT_IPV6 ; + offset |= (m->l3_len >>2 ) <<IAVF_TX_DESC_LENGTH_IPLEN_SHIFT ; + } + +if (m->ol_flags &PKT_TX_TCP_SEG ) { + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (m->l4_len >>2 ) <<IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -return ; }/* Enable L4 checksum offloads */ -switch (ol_flags &PKT_TX_L4_MASK ) { +switch (m->ol_flags &PKT_TX_L4_MASK ) {case PKT_TX_TCP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; - *td_offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_TCP ; + offset |= (sizeof (struct rte_tcp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_SCTP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; - *td_offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; + command |=IAVF_TX_DESC_CMD_L4T_EOFT_SCTP ; + offset |= (sizeof (struct rte_sctp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ;case PKT_TX_UDP_CKSUM : - *td_cmd |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; - *td_offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << -IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ; -break ; -default : + command |=IAVF_TX_DESC_CMD_L4T_EOFT_UDP ; + offset |= (sizeof (struct rte_udp_hdr ) >>2 ) << +IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT ;break ; } + + *qw1 =rte_cpu_to_le_64 ((((uint64_t )command << +IAVF_TXD_DATA_QW1_CMD_SHIFT ) &IAVF_TXD_DATA_QW1_CMD_MASK ) | + (((uint64_t )offset <<IAVF_TXD_DATA_QW1_OFFSET_SHIFT ) & +IAVF_TXD_DATA_QW1_OFFSET_MASK ) | + ((uint64_t )l2tag1 <<IAVF_TXD_DATA_QW1_L2TAG1_SHIFT )); } -/* set TSO context descriptor -* support IP -> L4 and IP -> IP -> L4 -*/ -static inline uint64_t -iavf_set_tso_ctx (struct rte_mbuf *mbuf,union iavf_tx_offload tx_offload) +static inline void +iavf_fill_data_desc_buffer_sz_field (volatile uint64_t *field,uint16_t value) { -uint64_t ctx_desc =0 ; -uint32_t cd_cmd, hdr_len, cd_tso_len; - -if (!tx_offload.l4_len) { -PMD_TX_LOG (DEBUG ,"L4 length set to 0" ); -return ctx_desc; + *field |= (((uint64_t )value <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); } - hdr_len = tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; +static inline void +iavf_fill_data_desc (volatile struct iavf_tx_desc *desc, +struct rte_mbuf *m,uint64_t desc_template, +uint16_t tlen,uint16_t ipseclen) +{ +uint32_t hdrlen = m->l2_len; +uint32_t bufsz =0 ; - cd_cmd =IAVF_TX_CTX_DESC_TSO ; - cd_tso_len = mbuf->pkt_len - hdr_len; - ctx_desc |= ((uint64_t )cd_cmd <<IAVF_TXD_CTX_QW1_CMD_SHIFT ) | - ((uint64_t )cd_tso_len <<IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT ) | - ((uint64_t )mbuf->tso_segsz <<IAVF_TXD_CTX_QW1_MSS_SHIFT ); +/* fill data descriptor qw1 from template */ + desc->cmd_type_offset_bsz = desc_template; -return ctx_desc; -} +/* set data buffer address */ + desc->buffer_addr =rte_mbuf_data_iova (m); -/* Construct the tx flags */ -static inline uint64_t -iavf_build_ctob (uint32_t td_cmd,uint32_t td_offset,unsigned int size, -uint32_t td_tag) -{ -return rte_cpu_to_le_64 (IAVF_TX_DESC_DTYPE_DATA | - ((uint64_t )td_cmd <<IAVF_TXD_QW1_CMD_SHIFT ) | - ((uint64_t )td_offset << -IAVF_TXD_QW1_OFFSET_SHIFT ) | - ((uint64_t )size << -IAVF_TXD_QW1_TX_BUF_SZ_SHIFT ) | - ((uint64_t )td_tag << -IAVF_TXD_QW1_L2TAG1_SHIFT )); +/* calculate data buffer size less set header lengths */ +if ((m->ol_flags &PKT_TX_TUNNEL_MASK ) && + (m->ol_flags & (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG ))) { + hdrlen += m->outer_l3_len; +if (m->ol_flags &PKT_TX_L4_MASK ) + hdrlen += m->l3_len + m->l4_len; +else + hdrlen += m->l3_len; +if (m->ol_flags &PKT_TX_SEC_OFFLOAD ) + hdrlen += ipseclen; + bufsz = hdrlen + tlen; + }else { + bufsz = m->data_len; + } + +/* set data buffer size */ + desc->cmd_type_offset_bsz |= + (((uint64_t )bufsz <<IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT ) & +IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK ); + + desc->buffer_addr =rte_cpu_to_le_64 (desc->buffer_addr); + desc->cmd_type_offset_bsz =rte_cpu_to_le_64 (desc->cmd_type_offset_bsz); } +/* TX function */ uint16_t iavf_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -volatile struct iavf_tx_desc *txd; -volatile struct iavf_tx_desc *txr; -struct iavf_tx_queue *txq; -struct iavf_tx_entry *sw_ring; +struct iavf_tx_queue *txq = tx_queue; +volatile struct iavf_tx_desc *txr = txq->tx_ring; +struct iavf_tx_entry *txe_ring = txq->sw_ring;struct iavf_tx_entry *txe, *txn; -struct rte_mbuf *tx_pkt; -struct rte_mbuf *m_seg; -uint16_t tx_id; -uint16_t nb_tx; -uint32_t td_cmd; -uint32_t td_offset; -uint32_t td_tag; -uint64_t ol_flags; -uint16_t nb_used; -uint16_t nb_ctx; -uint16_t tx_last; -uint16_t slen; -uint64_t buf_dma_addr; -uint16_t cd_l2tag2 =0 ; -union iavf_tx_offload tx_offload = {0 }; - - txq = tx_queue; - sw_ring = txq->sw_ring; - txr = txq->tx_ring; - tx_id = txq->tx_tail; - txe = &sw_ring[tx_id]; +struct rte_mbuf *mb, *mb_seg; +uint16_t desc_idx, desc_idx_last; +uint16_t idx; +/* Check if the descriptor ring needs to be cleaned. */ if (txq->nb_free < txq->free_thresh) - (void )iavf_xmit_cleanup (txq); +iavf_xmit_cleanup (txq); + + desc_idx = txq->tx_tail; + txe = &txe_ring[desc_idx]; + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_DESC_RING +iavf_dump_tx_entry_ring (txq); +iavf_dump_tx_desc_ring (txq); +#endif + -for (nb_tx =0 ; nb_tx < nb_pkts; nb_tx++) { - td_cmd =0 ; - td_tag =0 ; - td_offset =0 ; +for (idx =0 ; idx < nb_pkts; idx++) { +volatile struct iavf_tx_desc *ddesc; +uint16_t nb_desc_ctx; +uint16_t nb_desc_data, nb_desc_required; +uint16_t tlen =0 , ipseclen =0 ; +uint64_t ddesc_template =0 ; +uint64_t ddesc_cmd =0 ; + + mb = tx_pkts[idx]; - tx_pkt = *tx_pkts++;RTE_MBUF_PREFETCH_TO_FREE (txe->mbuf); - ol_flags = tx_pkt->ol_flags; - tx_offload.l2_len = tx_pkt->l2_len; - tx_offload.l3_len = tx_pkt->l3_len; - tx_offload.l4_len = tx_pkt->l4_len; - tx_offload.tso_segsz = tx_pkt->tso_segsz; -/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag); + nb_desc_data = mb->nb_segs; + nb_desc_ctx = !!(mb->ol_flags & + (PKT_TX_TCP_SEG |PKT_TX_UDP_SEG |PKT_TX_TUNNEL_MASK )); -/* The number of descriptors that must be allocated for +/** +* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that -* packet plus 1 context descriptor if needed. +* packet plus the context and ipsec descriptors if needed. */ - nb_used = (uint16_t )(tx_pkt->nb_segs + nb_ctx); - tx_last = (uint16_t )(tx_id + nb_used -1 ); + nb_desc_required = nb_desc_data + nb_desc_ctx; + + desc_idx_last = (uint16_t )(desc_idx + nb_desc_required -1 ); -/* Circular ring */ -if (tx_last >= txq->nb_tx_desc) - tx_last = (uint16_t )(tx_last - txq->nb_tx_desc); +/* wrap descriptor ring */ +if (desc_idx_last >= txq->nb_tx_desc) + desc_idx_last = + (uint16_t )(desc_idx_last - txq->nb_tx_desc); -PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u" -" tx_first=%u tx_last=%u" , - txq->port_id, txq->queue_id, tx_id, tx_last); +PMD_TX_LOG (DEBUG , +"port_id=%u queue_id=%u tx_first=%u tx_last=%u" , + txq->port_id, txq->queue_id, desc_idx, desc_idx_last); -if (nb_used > txq->nb_free) { +if (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; } -if (unlikely (nb_used > txq->rs_thresh)) { -while (nb_used > txq->nb_free) { +if (unlikely (nb_desc_required > txq->rs_thresh)) { +while (nb_desc_required > txq->nb_free) {if (iavf_xmit_cleanup (txq)) { -if (nb_tx ==0 ) +if (idx ==0 )return 0 ; goto end_of_tx; }
@@ -2259,122 +2375,94 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } } -/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { - td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; - td_tag = tx_pkt->vlan_tci; - } - -/* According to datasheet, the bit2 is reserved and must be -* set to 1. -*/ - td_cmd |=0x04 ; - -/* Enable checksum offloading */ -if (ol_flags &IAVF_TX_CKSUM_OFFLOAD_MASK ) -iavf_txd_enable_checksum (ol_flags, &td_cmd, - &td_offset, tx_offload); +iavf_build_data_desc_cmd_offset_fields (&ddesc_template, mb); -if (nb_ctx) {/* Setup TX context descriptor if required */ -uint64_t cd_type_cmd_tso_mss = -IAVF_TX_DESC_DTYPE_CONTEXT ; -volatile struct iavf_tx_context_desc *ctx_txd = +if (nb_desc_ctx) { +volatile struct iavf_tx_context_desc *ctx_desc = (volatile struct iavf_tx_context_desc *) - &txr[tx_id]; + &txr[desc_idx];/* clear QW0 or the previous writeback value * may impact next write */ - *(volatile uint64_t *)ctx_txd =0 ; + *(volatile uint64_t *)ctx_desc =0 ; - txn = &sw_ring[txe->next_id]; + txn = &txe_ring[txe->next_id];RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf); +if (txe->mbuf) {rte_pktmbuf_free_seg (txe->mbuf); txe->mbuf =NULL ; } -/* TSO enabled */ -if (ol_flags &PKT_TX_TCP_SEG ) - cd_type_cmd_tso_mss |= -iavf_set_tso_ctx (tx_pkt, tx_offload); +iavf_fill_context_desc (ctx_desc, mb, &tlen); +IAVF_DUMP_TX_DESC (txq, ctx_desc, desc_idx); -if (ol_flags &PKT_TX_VLAN_PKT && - txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { - cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 - <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; - cd_l2tag2 = tx_pkt->vlan_tci; + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; + txe = txn; } - ctx_txd->type_cmd_tso_mss = -rte_cpu_to_le_64 (cd_type_cmd_tso_mss); - ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2); -IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; - txe = txn; - } - m_seg = tx_pkt; + mb_seg = mb; +do { - txd = &txr[tx_id]; - txn = &sw_ring[txe->next_id]; + ddesc = (volatile struct iavf_tx_desc *) + &txr[desc_idx]; + + txn = &txe_ring[txe->next_id]; +RTE_MBUF_PREFETCH_TO_FREE (txn->mbuf);if (txe->mbuf)rte_pktmbuf_free_seg (txe->mbuf); - txe->mbuf = m_seg; - -/* Setup TX Descriptor */ - slen = m_seg->data_len; - buf_dma_addr =rte_mbuf_data_iova (m_seg); - txd->buffer_addr =rte_cpu_to_le_64 (buf_dma_addr); - txd->cmd_type_offset_bsz =iavf_build_ctob (td_cmd, - td_offset, - slen, - td_tag); - -IAVF_DUMP_TX_DESC (txq, txd, tx_id); - txe->last_id = tx_last; - tx_id = txe->next_id; + + txe->mbuf = mb_seg; +iavf_fill_data_desc (ddesc, mb_seg, + ddesc_template, tlen, ipseclen); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx); + + txe->last_id = desc_idx_last; + desc_idx = txe->next_id; txe = txn; - m_seg = m_seg->next; - }while (m_seg); + mb_seg = mb_seg->next; + }while (mb_seg);/* The last packet data descriptor needs End Of Packet (EOP) */ - td_cmd |=IAVF_TX_DESC_CMD_EOP ; - txq->nb_used = (uint16_t )(txq->nb_used + nb_used); - txq->nb_free = (uint16_t )(txq->nb_free - nb_used); + ddesc_cmd =IAVF_TX_DESC_CMD_EOP ; + + txq->nb_used = (uint16_t )(txq->nb_used + nb_desc_required); + txq->nb_free = (uint16_t )(txq->nb_free - nb_desc_required);if (txq->nb_used >= txq->rs_thresh) {PMD_TX_LOG (DEBUG ,"Setting RS bit on TXD id=" "%4u (port=%d queue=%d)" , - tx_last, txq->port_id, txq->queue_id); + desc_idx_last, txq->port_id, txq->queue_id); - td_cmd |=IAVF_TX_DESC_CMD_RS ; + ddesc_cmd |=IAVF_TX_DESC_CMD_RS ;/* Update txq RS bit counters */ txq->nb_used =0 ; } - txd->cmd_type_offset_bsz |= -rte_cpu_to_le_64 (((uint64_t )td_cmd) << -IAVF_TXD_QW1_CMD_SHIFT ); -IAVF_DUMP_TX_DESC (txq, txd, tx_id); + ddesc->cmd_type_offset_bsz |=rte_cpu_to_le_64 (ddesc_cmd << +IAVF_TXD_DATA_QW1_CMD_SHIFT ); + +IAVF_DUMP_TX_DESC (txq, ddesc, desc_idx -1 ); } end_of_tx:rte_wmb ();PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , - txq->port_id, txq->queue_id, tx_id, nb_tx); + txq->port_id, txq->queue_id, desc_idx, idx); -IAVF_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); - txq->tx_tail = tx_id; +IAVF_PCI_REG_WRITE_RELAXED (txq->qtx_tail, desc_idx); + txq->tx_tail = desc_idx; -return nb_tx; +return idx; }/* Check if the packet with vlan user priority is transmitted in the
drivers/net/iavf/iavf_rxtx.h +112 -5
135 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_sse.c +6 -4
@@ -363,10 +363,12 @@ static inline void flex_desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts, const uint32_t *type_table) { - const __m128i ptype_mask = _mm_set_epi16(0, IAVF_RX_FLEX_DESC_PTYPE_M, -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M , -0 ,IAVF_RX_FLEX_DESC_PTYPE_M ); + const __m128i ptype_mask = _mm_set_epi16( +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 , +IAVF_RX_FLEX_DESC_PTYPE_M ,0x0 ); +__m128i ptype_01 =_mm_unpacklo_epi32 (descs[0 ], descs[1 ]);__m128i ptype_23 =_mm_unpacklo_epi32 (descs[2 ], descs[3 ]);__m128i ptype_all =_mm_unpacklo_epi64 (ptype_01, ptype_23);
Signature · 1 line
2.25.1
PATCH v10 3/7 net/iavf: add support for asynchronous virt channel messages
In reply to Radu NicolauAdd support for asynchronous virtual channel messages, specifically for inline IPsec messages.
--- drivers/net/iavf/iavf.h | 16 ++++ drivers/net/iavf/iavf_vchnl.c | 138 +++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 53 deletions(-)
drivers/net/iavf/iavf.h +16 -0
@@ -193,6 +193,7 @@ struct iavf_info {uint64_t supported_rxdid;uint8_t *proto_xtr;/* proto xtr type for all queues */ volatile enum virtchnl_ops pend_cmd;/* pending command not finished */ +rte_atomic32_t pend_cmd_count;int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */
@@ -345,9 +346,24 @@ _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)if (!ret)PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); +rte_atomic32_set (&vf->pend_cmd_count,1 ); +return !ret; } +/* Check there is pending cmd in execution. If none, set new command. */ +static inline int +_atomic_set_async_response_cmd (struct iavf_info *vf,enum virtchnl_ops ops) +{ +int ret =rte_atomic32_cmpset (&vf->pend_cmd,VIRTCHNL_OP_UNKNOWN , ops); + +if (!ret) +PMD_DRV_LOG (ERR ,"There is incomplete cmd %d" , vf->pend_cmd); + +rte_atomic32_set (&vf->pend_cmd_count,2 ); + +return !ret; +}int iavf_check_api_version (struct iavf_adapter *adapter);int iavf_get_vf_resource (struct iavf_adapter *adapter);void iavf_handle_virtchnl_msg (struct rte_eth_dev *dev);
drivers/net/iavf/iavf_vchnl.c +85 -53
396 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v10 4/7 net/iavf: add iAVF IPsec inline crypto support
In reply to Radu NicolauAdd support for inline crypto for IPsec, for ESP transport and tunnel over IPv4 and IPv6, as well as supporting the offload for ESP over UDP, and inconjunction with TSO for UDP and TCP flows. Implement support for rte_security packet metadata
Add definition for IPsec descriptors, extend support for offload in data and context descriptor to support
Add support to virtual channel mailbox for IPsec Crypto request operations. IPsec Crypto requests receive an initial acknowledgment from phsyical function driver of receipt of request and then an asynchronous response with success/failure of request including any response data.
Add enhanced descriptor debugging
Refactor of scalar tx burst function to support integration of offload
--- drivers/net/iavf/iavf.h | 10 + drivers/net/iavf/iavf_ethdev.c | 41 +- drivers/net/iavf/iavf_generic_flow.c | 15 + drivers/net/iavf/iavf_generic_flow.h | 2 + drivers/net/iavf/iavf_ipsec_crypto.c | 1894 +++++++++++++++++ drivers/net/iavf/iavf_ipsec_crypto.h | 160 ++ .../net/iavf/iavf_ipsec_crypto_capabilities.h | 383 ++++ drivers/net/iavf/iavf_rxtx.c | 202 +- drivers/net/iavf/iavf_rxtx.h | 93 +- drivers/net/iavf/iavf_vchnl.c | 29 + drivers/net/iavf/meson.build | 3 +- drivers/net/iavf/rte_pmd_iavf.h | 1 + drivers/net/iavf/version.map | 3 + 13 files changed, 2815 insertions(+), 21 deletions(-) create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.c create mode 100644 drivers/net/iavf/iavf_ipsec_crypto.h create mode 100644 drivers/net/iavf/iavf_ipsec_crypto_capabilities.h
drivers/net/iavf/iavf.h +10 -0
@@ -221,6 +221,7 @@ struct iavf_info {rte_spinlock_t flow_ops_lock;struct iavf_parser_list rss_parser_list;struct iavf_parser_list dist_parser_list; +struct iavf_parser_list ipsec_crypto_parser_list;struct iavf_fdir_info fdir;/* flow director info */ /* indicate large VF support enabled or not */
@@ -245,6 +246,7 @@ enum iavf_proto_xtr_type {IAVF_PROTO_XTR_IPV6_FLOW ,IAVF_PROTO_XTR_TCP ,IAVF_PROTO_XTR_IP_OFFSET , +IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID , IAVF_PROTO_XTR_MAX, };
@@ -256,11 +258,14 @@ struct iavf_devargs {uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM ]; }; +struct iavf_security_ctx ; +/* Structure to store private data for each VF instance. */ struct iavf_adapter {struct iavf_hw hw;struct rte_eth_dev_data *dev_data;struct iavf_info vf; +struct iavf_security_ctx *security_ctx;bool rx_bulk_alloc_allowed;/* For vector PMD */
@@ -279,6 +284,8 @@ struct iavf_adapter { (&((struct iavf_adapter *)adapter)->vf)#define IAVF_DEV_PRIVATE_TO_HW (adapter) \ (&((struct iavf_adapter *)adapter)->hw) +#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX (adapter) \ + (((struct iavf_adapter *)adapter)->security_ctx)/* IAVF_VSI_TO */ #define IAVF_VSI_TO_HW (vsi) \
@@ -421,5 +428,8 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, uint16_t size);void iavf_tm_conf_init (struct rte_eth_dev *dev);void iavf_tm_conf_uninit (struct rte_eth_dev *dev); +int iavf_ipsec_crypto_request (struct iavf_adapter *adapter, +uint8_t *msg,size_t msg_len, +uint8_t *resp_msg,size_t resp_msg_len);extern const struct rte_tm_ops iavf_tm_ops;#endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +38 -3
89 lines not on this page · raw message
drivers/net/iavf/iavf_generic_flow.c +15 -0
@@ -1635,6 +1635,7 @@ iavf_flow_init(struct iavf_adapter *ad)TAILQ_INIT (&vf->flow_list);TAILQ_INIT (&vf->rss_parser_list);TAILQ_INIT (&vf->dist_parser_list); +TAILQ_INIT (&vf->ipsec_crypto_parser_list);rte_spinlock_init (&vf->flow_ops_lock); RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
@@ -1709,6 +1710,9 @@ iavf_register_parser(struct iavf_flow_parser *parser, }else if (parser->engine->type ==IAVF_FLOW_ENGINE_FDIR ) { list = &vf->dist_parser_list;TAILQ_INSERT_HEAD (list, parser_node, node); + }else if (parser->engine->type ==IAVF_FLOW_ENGINE_IPSEC_CRYPTO ) { + list = &vf->ipsec_crypto_parser_list; +TAILQ_INSERT_HEAD (list, parser_node, node); }else {return -EINVAL ; }
@@ -2018,6 +2022,13 @@ iavf_flow_process_filter(struct rte_eth_dev *dev, *engine =iavf_parse_engine (ad, flow, &vf->dist_parser_list, pattern, actions, error); +if (*engine) +return 0 ; + + *engine =iavf_parse_engine (ad, flow, &vf->ipsec_crypto_parser_list, + pattern, actions, error); +if (*engine) +return 0 ;if (!*engine) { rte_flow_error_set(error, EINVAL,
@@ -2064,6 +2075,10 @@ iavf_flow_create(struct rte_eth_dev *dev,return flow; } +/* Special case for inline crypto egress flows */ +if (attr->egress && actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY ) + goto free_flow; + ret =iavf_flow_process_filter (dev, flow, attr, pattern, actions, &engine, iavf_parse_engine_create, error);if (ret <0 ) {
drivers/net/iavf/iavf_generic_flow.h +2 -0
@@ -449,6 +449,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,/* engine types. */ enum iavf_flow_engine_type {IAVF_FLOW_ENGINE_NONE =0 , +IAVF_FLOW_ENGINE_IPSEC_CRYPTO ,IAVF_FLOW_ENGINE_FDIR ,IAVF_FLOW_ENGINE_HASH ,IAVF_FLOW_ENGINE_MAX ,
@@ -462,6 +463,7 @@ enum iavf_flow_engine_type {*/ enum iavf_flow_classification_stage {IAVF_FLOW_STAGE_NONE =0 , +IAVF_FLOW_STAGE_IPSEC_CRYPTO ,IAVF_FLOW_STAGE_RSS ,IAVF_FLOW_STAGE_DISTRIBUTOR ,IAVF_FLOW_STAGE_MAX ,
drivers/net/iavf/iavf_ipsec_crypto.c new file +1894 -0
1,894 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto.h new file +160 -0
160 lines not on this page · raw message
drivers/net/iavf/iavf_ipsec_crypto_capabilities.h new file +383 -0
383 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.c +191 -11
345 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +87 -6
32 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v10 5/7 net/iavf: add xstats support for inline IPsec crypto
In reply to Radu NicolauAdd per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats.
--- drivers/net/iavf/iavf.h | 21 ++++++++- drivers/net/iavf/iavf_ethdev.c | 84 ++++++++++++++++++++++++++++------ drivers/net/iavf/iavf_rxtx.h | 12 ----- 3 files changed, 89 insertions(+), 28 deletions(-)
drivers/net/iavf/iavf.h +20 -1
@@ -96,6 +96,25 @@ struct iavf_adapter;struct iavf_rx_queue ;struct iavf_tx_queue ; + +struct iavf_ipsec_crypto_stats { +uint64_t icount; +uint64_t ibytes; +struct { +uint64_t count; +uint64_t sad_miss; +uint64_t not_processed; +uint64_t icv_check; +uint64_t ipsec_length; +uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { +struct virtchnl_eth_stats eth_stats; +struct iavf_ipsec_crypto_stats ips_stats; +}; +/* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi {struct iavf_adapter *adapter;/* Backreference to associated adapter */
@@ -105,7 +124,7 @@ struct iavf_vsi {uint16_t max_macaddrs;/* Maximum number of MAC addresses */ uint16_t base_vector;uint16_t msix_intr;/* The MSIX interrupt binds to VSI */ -struct virtchnl_eth_stats eth_stats_offset; +struct iavf_eth_xstats eth_stats_offset; };struct rte_flow ;
drivers/net/iavf/iavf_ethdev.c +69 -15
140 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx.h +0 -12
@@ -165,18 +165,6 @@ struct iavf_txq_ops {void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { -uint64_t icount; -uint64_t ibytes; -struct { -uint64_t count; -uint64_t sad_miss; -uint64_t not_processed; -uint64_t icv_check; -uint64_t ipsec_length; -uint64_t misc; - } ierrors; -};struct iavf_rx_queue_stats {uint64_t reserved;
Signature · 1 line
2.25.1
PATCH v10 6/7 net/iavf: add watchdog for VFLR
In reply to Radu NicolauAdd watchdog to iAVF PMD which support monitoring the VFLR register. If the device is not already in reset then if a VF reset in progress is detected then notfiy user through callback and set into reset state. If the device is already in reset then poll for completion of reset.
The watchdog is disabled by default, to enable it set IAVF_DEV_WATCHDOG_PERIOD to a non zero value (microseconds)
--- drivers/net/iavf/iavf.h | 5 ++ drivers/net/iavf/iavf_ethdev.c | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
drivers/net/iavf/iavf.h +5 -0
@@ -31,6 +31,8 @@#define IAVF_NUM_MACADDR_MAX 64 +#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEFAULT_RX_PTHRESH 8#define IAVF_DEFAULT_RX_HTHRESH 8#define IAVF_DEFAULT_RX_WTHRESH 0
@@ -216,6 +218,9 @@ struct iavf_info {int cmd_retval;/* return value of the cmd response from PF */ uint8_t *aq_resp;/* buffer to store the adminq response from PF */ +/** iAVF watchdog enable */ +bool watchdog_enabled; +/* Event from pf */ bool dev_closed;bool link_up;
drivers/net/iavf/iavf_ethdev.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.25.1