mlx5 updates 2020-10-12
Subsystems (6)
Saeed Mahameed
maintainerHi Jakub,
This small series add xfrm IPSec TX offload support to mlx5 driver.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit 547848af58e3eb5a0d8b0a5e6433042f111788e2:
Merge branch 'bnxt_en-Updates-for-net-next' (2020-10-12 14:42:55 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2020-10-12
for you to fetch changes up to 5be019040cb7bab4caf152cacadffee91a78b506:
net/mlx5e: IPsec: Add Connect-X IPsec Tx data path offload (2020-10-12 15:37:45 -0700)
----------------------------------------------------------------
mlx5-updates-2020-10-12
Updates to mlx5 driver:
- Cleanup fix of uininitialized pointer read
- xfrm IPSec TX offload
----------------------------------------------------------------
Colin Ian King (1):
net/mlx5: Fix uininitialized pointer read on pointer attr
Huy Nguyen (2):
net/mlx5: Add NIC TX domain namespace net/mlx5e: IPsec: Add TX steering rule per IPsec state
Raed Salem (1):
net/mlx5e: IPsec: Add Connect-X IPsec Tx data path offload
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h | 1 + .../mellanox/mlx5/core/en_accel/en_accel.h | 46 +++++- .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 + .../ethernet/mellanox/mlx5/core/en_accel/ipsec.h | 2 + .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 178 ++++++++++++++++++++- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 110 +++++++++++-- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 29 +++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 43 ++++- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 3 + drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 19 ++- include/linux/mlx5/fs.h | 1 + include/linux/mlx5/qp.h | 6 +- 13 files changed, 406 insertions(+), 36 deletions(-)
Saeed Mahameed
maintainerPATCH 1/4 net/mlx5: Fix uininitialized pointer read on pointer attr
From: Colin Ian King <[email protected]>
Currently the error exit path err_free kfree's attr. In the case where flow and parse_attr failed to be allocated this return path will free the uninitialized pointer attr, which is not correct. In the other case where attr fails to allocate attr does not need to be freed. So in both error exits via err_free attr should not be freed, so remove it.
Addresses-Coverity: ("Uninitialized pointer read")
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -1
@@ -4569,7 +4569,6 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size, err_free:kfree (flow);kvfree (parse_attr); -kfree (attr);return err; }
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH 2/4 net/mlx5: Add NIC TX domain namespace
In reply to Saeed MahameedFrom: Huy Nguyen <[email protected]>
Add new namespace that represents the NIC TX domain.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 1 + .../net/ethernet/mellanox/mlx5/core/fs_cmd.c | 3 +++ .../net/ethernet/mellanox/mlx5/core/fs_core.c | 19 ++++++++++++++++++- include/linux/mlx5/fs.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +1 -0
@@ -236,6 +236,7 @@ struct mlx5e_accel_fs_tcp;struct mlx5e_flow_steering {struct mlx5_flow_namespace *ns; +struct mlx5_flow_namespace *egress_ns;#ifdef CONFIG_MLX5_EN_RXNFC struct mlx5e_ethtool_steering ethtool;#endif
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +3 -0
@@ -776,6 +776,9 @@ static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns, table_type =FS_FT_NIC_RX ;break ;case MLX5_FLOW_NAMESPACE_EGRESS : +#ifdef CONFIG_MLX5_IPSEC +case MLX5_FLOW_NAMESPACE_EGRESS_KERNEL : +#endif max_actions =MLX5_CAP_FLOWTABLE_NIC_TX (dev, max_modify_header_actions); table_type =FS_FT_NIC_TX ;break ;
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +18 -1
@@ -126,6 +126,10 @@#define LAG_NUM_PRIOS 1#define LAG_MIN_LEVEL (OFFLOADS_MIN_LEVEL + 1) +#define KERNEL_TX_IPSEC_NUM_PRIOS 1 +#define KERNEL_TX_IPSEC_NUM_LEVELS 1 +#define KERNEL_TX_MIN_LEVEL (KERNEL_TX_IPSEC_NUM_LEVELS) +struct node_caps {size_t arr_sz;long *caps;
@@ -180,13 +184,24 @@ static struct init_tree_node {static struct init_tree_node egress_root_fs = { .type =FS_TYPE_NAMESPACE , +#ifdef CONFIG_MLX5_IPSEC + .ar_size =2 , +#else .ar_size =1 , +#endif .children = (struct init_tree_node []) {ADD_PRIO (0 ,MLX5_BY_PASS_NUM_PRIOS ,0 ,FS_CHAINING_CAPS_EGRESS ,ADD_NS (MLX5_FLOW_TABLE_MISS_ACTION_DEF ,ADD_MULTIPLE_PRIO (MLX5_BY_PASS_NUM_PRIOS ,BY_PASS_PRIO_NUM_LEVELS ))), +#ifdef CONFIG_MLX5_IPSEC +ADD_PRIO (0 ,KERNEL_TX_MIN_LEVEL ,0 , +FS_CHAINING_CAPS_EGRESS , +ADD_NS (MLX5_FLOW_TABLE_MISS_ACTION_DEF , +ADD_MULTIPLE_PRIO (KERNEL_TX_IPSEC_NUM_PRIOS , +KERNEL_TX_IPSEC_NUM_LEVELS ))), +#endif } };
@@ -2165,8 +2180,10 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,break ; } -if (type ==MLX5_FLOW_NAMESPACE_EGRESS ) { +if (type ==MLX5_FLOW_NAMESPACE_EGRESS || + type ==MLX5_FLOW_NAMESPACE_EGRESS_KERNEL ) { root_ns = steering->egress_root_ns; + prio = type -MLX5_FLOW_NAMESPACE_EGRESS ; }else if (type ==MLX5_FLOW_NAMESPACE_RDMA_RX ) { root_ns = steering->rdma_rx_root_ns; prio =RDMA_RX_BYPASS_PRIO ;
include/linux/mlx5/fs.h +1 -0
@@ -76,6 +76,7 @@ enum mlx5_flow_namespace_type {MLX5_FLOW_NAMESPACE_SNIFFER_RX ,MLX5_FLOW_NAMESPACE_SNIFFER_TX ,MLX5_FLOW_NAMESPACE_EGRESS , +MLX5_FLOW_NAMESPACE_EGRESS_KERNEL ,MLX5_FLOW_NAMESPACE_RDMA_RX ,MLX5_FLOW_NAMESPACE_RDMA_RX_KERNEL , MLX5_FLOW_NAMESPACE_RDMA_TX,
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH 3/4 net/mlx5e: IPsec: Add TX steering rule per IPsec state
In reply to Saeed MahameedFrom: Huy Nguyen <[email protected]>
Add new FTE in TX IPsec FT per IPsec state. It has the same matching criteria as the RX steering rule.
The IPsec FT is created/destroyed when the first/last rule is added/deleted respectively.
--- .../mellanox/mlx5/core/en_accel/ipsec.h | 2 + .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 178 +++++++++++++++++- include/linux/mlx5/qp.h | 6 +- 3 files changed, 181 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h +2 -0
@@ -76,6 +76,7 @@ struct mlx5e_ipsec_stats { };struct mlx5e_accel_fs_esp ; +struct mlx5e_ipsec_tx ;struct mlx5e_ipsec {struct mlx5e_priv *en_priv;
@@ -87,6 +88,7 @@ struct mlx5e_ipsec {struct mlx5e_ipsec_stats stats;struct workqueue_struct *wq;struct mlx5e_accel_fs_esp *rx_fs; +struct mlx5e_ipsec_tx *tx_fs; };struct mlx5e_ipsec_esn_state {
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +174 -4
233 lines not on this page · raw message
include/linux/mlx5/qp.h +5 -1
@@ -245,6 +245,10 @@ enum { MLX5_ETH_WQE_SWP_OUTER_L4_UDP = 1 << 5, }; +enum { +MLX5_ETH_WQE_FT_META_IPSEC =BIT (0 ), +}; +struct mlx5_wqe_eth_seg {u8 swp_outer_l4_offset;u8 swp_outer_l3_offset;
@@ -253,7 +257,7 @@ struct mlx5_wqe_eth_seg {u8 cs_flags;u8 swp_flags;__be16 mss; -__be32 rsvd2; +__be32 flow_table_metadata; union { struct { __be16 sz;
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH 4/4 net/mlx5e: IPsec: Add Connect-X IPsec Tx data path offload
In reply to Saeed MahameedFrom: Raed Salem <[email protected]>
In the TX data path, spot packets with xfrm stack IPsec offload indication.
Fill Software-Parser segment in TX descriptor so that the hardware may parse the ESP protocol, and perform TX checksum offload on the inner payload.
Support GSO, by providing the trailer data and ICV placeholder so HW can fill it post encryption operation.
Padding alignment cannot be performed in HW (ConnectX-6Dx) due to a bug. Software can overcome this limitation by adding NETIF_F_HW_ESP to the gso_partial_features field in netdev so the packets being aligned by the stack.
l4_inner_checksum cannot be offloaded by HW for IPsec tunnel type packet.
Note that for GSO SKBs, the stack does not include an ESP trailer, unlike the non-GSO case.
Below is the iperf3 performance report on two server of 24 cores Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz with ConnectX6-DX. All the bandwidth test uses iperf3 TCP traffic with packet size 128KB. Each tunnel uses one iperf3 stream with one thread (option -P1). TX crypto offload shows improvements on both bandwidth
and CPU utilization.
----------------------------------------------------------------------
Mode | Num tunnel | BW | Send CPU util | Recv CPU util
| | (Gbps) | (Average %) | (Average %)
----------------------------------------------------------------------
Cryto offload | | | |
(RX only) | 1 | 4.7 | 4.2 | 3.5
----------------------------------------------------------------------
Cryto offload | | | |
(RX only) | 24 | 15.6 | 20 | 10----------------------------------------------------------------------
Non-offload | 1 | 4.6 | 4 | 5
----------------------------------------------------------------------
Non-offload | 24 | 11.9 | 16 | 12
----------------------------------------------------------------------
Cryto offload | | | | (TX & RX) | 1 | 11.9 | 2.1 | 5.9 ---------------------------------------------------------------------- Cryto offload | | | | (TX & RX) | 24 | 38 | 9.5 | 27.5 ---------------------------------------------------------------------- Cryto offload | | | | (TX only) | 1 | 4.7 | 0.7 | 5 ---------------------------------------------------------------------- Cryto offload | | | | (TX only) | 24 | 14.5 | 6 | 20
Regression tests show no degradation on non-ipsec and non-offload-ipsec traffics. The packet rate test uses pktgen UDP to transmit on single CPU, the instructions and cycles are measured on the transmit CPU.
before:
----------------------------------------------------------------------
Non-offload | 1 | 4.7 | 4.2 | 5.1
----------------------------------------------------------------------
Non-offload | 24 | 11.2 | 14 | 15
----------------------------------------------------------------------
Non-ipsec | 1 | 28 | 4 | 5.7
----------------------------------------------------------------------
Non-ipsec | 24 | 68.3 | 17.8 | 39.7
----------------------------------------------------------------------
Non-ipsec packet rate(BURST=1000 BC=5 NCPUS=1 SIZE=60) 13.56Mpps, 456 instructions/pkt, 191 cycles/pkt
after:
----------------------------------------------------------------------
Non-offload | 1 | 4.69 | 4.2 | 5
----------------------------------------------------------------------
Non-offload | 24 | 11.9 | 13.5 | 15.1
----------------------------------------------------------------------
Non-ipsec | 1 | 29 | 3.2 | 5.5
----------------------------------------------------------------------
Non-ipsec | 24 | 68.2 | 18.5 | 39.8
----------------------------------------------------------------------
Non-ipsec packet rate: 13.56Mpps, 472 instructions/pkt, 191 cycles/pkt
--- .../mellanox/mlx5/core/en_accel/en_accel.h | 46 +++++++- .../mellanox/mlx5/core/en_accel/ipsec.c | 3 + .../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 110 +++++++++++++++--- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 29 ++++- .../net/ethernet/mellanox/mlx5/core/en_tx.c | 43 ++++++- 5 files changed, 202 insertions(+), 29 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +40 -6
@@ -107,6 +107,9 @@ struct mlx5e_accel_tx_state {#ifdef CONFIG_MLX5_EN_TLS struct mlx5e_accel_tx_tls_state tls;#endif +#ifdef CONFIG_MLX5_EN_IPSEC +struct mlx5e_accel_tx_ipsec_state ipsec; +#endif }; static inline bool mlx5e_accel_tx_begin(struct net_device *dev,
@@ -125,22 +128,46 @@ static inline bool mlx5e_accel_tx_begin(struct net_device *dev, }#endif +#ifdef CONFIG_MLX5_EN_IPSEC +if (test_bit (MLX5E_SQ_STATE_IPSEC , &sq->state) &&xfrm_offload (skb)) { +if (unlikely (!mlx5e_ipsec_handle_tx_skb (dev, skb, &state->ipsec))) +return false; + } +#endif +return true; } +static inline bool mlx5e_accel_tx_is_ipsec_flow (struct mlx5e_accel_tx_state *state) +{ +#ifdef CONFIG_MLX5_EN_IPSEC +return mlx5e_ipsec_is_tx_flow (&state->ipsec); +#endif + +return false; +} + +static inline unsigned int mlx5e_accel_tx_ids_len (struct mlx5e_txqsq *sq, +struct mlx5e_accel_tx_state *state) +{ +#ifdef CONFIG_MLX5_EN_IPSEC +if (test_bit (MLX5E_SQ_STATE_IPSEC , &sq->state)) +return mlx5e_ipsec_tx_ids_len (&state->ipsec); +#endif + +return 0 ; +} +/* Part of the eseg touched by TX offloads */ #define MLX5E_ACCEL_ESEG_LEN offsetof(struct mlx5_wqe_eth_seg, mss)static inline bool mlx5e_accel_tx_eseg (struct mlx5e_priv *priv, -struct mlx5e_txqsq *sq,struct sk_buff *skb,struct mlx5_wqe_eth_seg *eseg) {#ifdef CONFIG_MLX5_EN_IPSEC -if (test_bit (MLX5E_SQ_STATE_IPSEC , &sq->state)) { -if (unlikely (!mlx5e_ipsec_handle_tx_skb (priv, eseg, skb))) -return false; - } +if (xfrm_offload (skb)) +mlx5e_ipsec_tx_build_eseg (priv, skb, eseg);#endif #if IS_ENABLED (CONFIG_GENEVE )
@@ -153,11 +180,18 @@ static inline bool mlx5e_accel_tx_eseg(struct mlx5e_priv *priv,static inline void mlx5e_accel_tx_finish (struct mlx5e_txqsq *sq,struct mlx5e_tx_wqe *wqe, -struct mlx5e_accel_tx_state *state) +struct mlx5e_accel_tx_state *state, +struct mlx5_wqe_inline_seg *inlseg) {#ifdef CONFIG_MLX5_EN_TLS mlx5e_tls_handle_tx_wqe (sq, &wqe->ctrl, &state->tls);#endif + +#ifdef CONFIG_MLX5_EN_IPSEC +if (test_bit (MLX5E_SQ_STATE_IPSEC , &sq->state) && + state->ipsec.xo && state->ipsec.tailen) +mlx5e_ipsec_handle_tx_wqe (wqe, &state->ipsec, inlseg); +#endif }static inline int mlx5e_accel_init_rx (struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +3 -0
@@ -560,6 +560,9 @@ void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv)return ; } +if (mlx5_is_ipsec_device (mdev)) + netdev->gso_partial_features |=NETIF_F_GSO_ESP ; +mlx5_core_dbg (mdev,"mlx5e: ESP GSO capability turned on\n" ); netdev->features |=NETIF_F_GSO_ESP ; netdev->hw_features |=NETIF_F_GSO_ESP ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c +96 -14
136 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h +26 -3
@@ -43,6 +43,13 @@#define MLX5_IPSEC_METADATA_SYNDROM_MASK (0x7F)#define MLX5_IPSEC_METADATA_HANDLE (metadata) (((metadata) >> 8) & 0xFF) +struct mlx5e_accel_tx_ipsec_state { +struct xfrm_offload *xo; +struct xfrm_state *x; +u32 tailen; +u32 plen; +}; +#ifdef CONFIG_MLX5_EN_IPSEC struct sk_buff *mlx5e_ipsec_handle_rx_skb(struct net_device *netdev,
@@ -55,16 +62,32 @@ void mlx5e_ipsec_set_iv_esn(struct sk_buff *skb, struct xfrm_state *x, struct xfrm_offload *xo);void mlx5e_ipsec_set_iv (struct sk_buff *skb,struct xfrm_state *x,struct xfrm_offload *xo); -bool mlx5e_ipsec_handle_tx_skb (struct mlx5e_priv *priv, -struct mlx5_wqe_eth_seg *eseg, -struct sk_buff *skb); +bool mlx5e_ipsec_handle_tx_skb (struct net_device *netdev, +struct sk_buff *skb, +struct mlx5e_accel_tx_ipsec_state *ipsec_st); +void mlx5e_ipsec_handle_tx_wqe (struct mlx5e_tx_wqe *wqe, +struct mlx5e_accel_tx_ipsec_state *ipsec_st, +struct mlx5_wqe_inline_seg *inlseg);void mlx5e_ipsec_offload_handle_rx_skb (struct net_device *netdev,struct sk_buff *skb,struct mlx5_cqe64 *cqe); +static inline unsigned int mlx5e_ipsec_tx_ids_len (struct mlx5e_accel_tx_ipsec_state *ipsec_st) +{ +return ipsec_st->tailen; +} +static inline bool mlx5_ipsec_is_rx_flow (struct mlx5_cqe64 *cqe) {return !!(MLX5_IPSEC_METADATA_MARKER_MASK &be32_to_cpu (cqe->ft_metadata)); } + +static inline bool mlx5e_ipsec_is_tx_flow (struct mlx5e_accel_tx_ipsec_state *ipsec_st) +{ +return ipsec_st->x; +} + +void mlx5e_ipsec_tx_build_eseg (struct mlx5e_priv *priv,struct sk_buff *skb, +struct mlx5_wqe_eth_seg *eseg);#else static inline void mlx5e_ipsec_offload_handle_rx_skb(struct net_device *netdev,
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +37 -6
117 lines not on this page · raw message
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerQuoted 5 lines · On Mon, 12 Oct 2020 15:41:48 -0700 Saeed Mahameed wrote:
Hi Jakub,
This small series add xfrm IPSec TX offload support to mlx5 driver.
Please pull and let me know if there is any problem.
Pulled, thanks!