cxgb4/chcr: Enable ktls settings at run time
Subsystems (5)
PATCH 1/1 cxgb4/chcr: Enable ktls settings at run time
Current design enables ktls setting from start, which is not efficient. Now the feature will be enabled when user demands TLS offload on any interface.
Signed-off-by Rohit Maheshwari <[email protected]>
--- drivers/crypto/chelsio/chcr_ktls.c | 19 +++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 4 ++ .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 2 + .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 26 +++++++- .../net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 66 ++++++++++++++----- .../net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 4 ++ drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 10 ++- 7 files changed, 109 insertions(+), 22 deletions(-)
drivers/crypto/chelsio/chcr_ktls.c +18 -1
@@ -409,6 +409,10 @@ static void chcr_ktls_dev_del(struct net_device *netdev, }atomic64_inc (&tx_info->adap->chcr_stats.ktls_tx_connection_close); +/* check if ktls settings are no more required. */ +cxgb4_set_ktls_feature (tx_info->adap, +FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE ); +kvfree (tx_info); tx_ctx->chcr_info =NULL ; }
@@ -529,6 +533,9 @@ static int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk, goto out2;atomic64_inc (&adap->chcr_stats.ktls_tx_connection_open); + +cxgb4_set_ktls_feature (tx_info->adap, +FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE );return 0 ; out2:kvfree (tx_info);
@@ -550,11 +557,17 @@ void chcr_enable_ktls(struct adapter *adap)struct net_device *netdev;int i; +/* clear refcount */ +refcount_set (&adap->chcr_ktls.ktls_refcount,0 ); +for_each_port (adap, i) { netdev = adap->port[i]; - netdev->features |=NETIF_F_HW_TLS_TX ; netdev->hw_features |=NETIF_F_HW_TLS_TX ; netdev->tlsdev_ops = &chcr_ktls_ops; + +rtnl_lock (); +netdev_update_features (netdev); +rtnl_unlock (); } }
@@ -571,6 +584,10 @@ void chcr_disable_ktls(struct adapter *adap) netdev->features &= ~NETIF_F_HW_TLS_TX ; netdev->hw_features &= ~NETIF_F_HW_TLS_TX ; netdev->tlsdev_ops =NULL ; + +rtnl_lock (); +netdev_update_features (netdev); +rtnl_unlock (); } }
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +4 -0
@@ -1091,6 +1091,7 @@ struct adapter {/* TC u32 offload */ struct cxgb4_tc_u32_table *tc_u32; +struct chcr_ktls chcr_ktls;struct chcr_stats_debug chcr_stats;/* TC flower offload */
@@ -2050,4 +2051,7 @@ int cxgb_open(struct net_device *dev);int cxgb_close (struct net_device *dev);void cxgb4_enable_rx (struct adapter *adap,struct sge_rspq *q);void cxgb4_quiesce_rx (struct sge_rspq *q); +#ifdef CONFIG_CHELSIO_TLS_DEVICE +int cxgb4_set_ktls_feature (struct adapter *adap,bool enable); +#endif #endif /* __CXGB4_H__ */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +2 -0
@@ -3411,6 +3411,8 @@ static int chcr_stats_show(struct seq_file *seq, void *v) atomic_read(&adap->chcr_stats.tls_key));#ifdef CONFIG_CHELSIO_TLS_DEVICE seq_puts (seq,"\nChelsio KTLS Crypto Accelerator Stats\n" ); +seq_printf (seq,"Tx TLS offload refcount: %20u\n" , +refcount_read (&adap->chcr_ktls.ktls_refcount));seq_printf (seq,"Tx HW offload contexts added: %20llu\n" ,atomic64_read (&adap->chcr_stats.ktls_tx_ctx)); seq_printf(seq, "Tx connection created: %20llu\n",
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +25 -1
@@ -1255,10 +1255,34 @@ int cxgb4_set_rspq_intr_params(struct sge_rspq *q,static int cxgb_set_features (struct net_device *dev,netdev_features_t features) { -const struct port_info *pi =netdev_priv (dev);netdev_features_t changed = dev->features ^ features; +const struct port_info *pi =netdev_priv (dev); +#ifdef CONFIG_CHELSIO_TLS_DEVICE +bool enable; +#endif int err; +#ifdef CONFIG_CHELSIO_TLS_DEVICE +/* tls offload will be enabled runtime on user request only, we are +* going to inform the same to FW. +*/ + enable = !!((features &NETIF_F_HW_TLS_TX ) & dev->hw_features); + +if ((changed &NETIF_F_HW_TLS_TX ) && + (pi->adapter->params.crypto &FW_CAPS_CONFIG_TLS_HW )) { + err =cxgb4_set_ktls_feature (pi->adapter, enable); +if (err) +return err; + +/* if wanted_features has NETIF_F_HW_TLS_TX set, it will cause +* feature flag also get set, though hw_features is not even +* set, better return failure here. +*/ +if (!(dev->hw_features &NETIF_F_HW_TLS_TX )) +return -EINVAL ; + } +#endif +if (!(changed &NETIF_F_HW_VLAN_CTAG_RX ))return 0 ;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +48 -18
96 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +4 -0
@@ -263,6 +263,10 @@ struct filter_ctx {u32 tid;/* to store tid */ }; +struct chcr_ktls { +refcount_t ktls_refcount; +}; +struct ch_filter_specification ; int cxgb4_get_free_ftid(struct net_device *dev, u8 family, bool hash_en,
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +8 -2
@@ -1205,7 +1205,7 @@ enum fw_caps_config_crypto {FW_CAPS_CONFIG_CRYPTO_LOOKASIDE =0x00000001 ,FW_CAPS_CONFIG_TLS_INLINE =0x00000002 ,FW_CAPS_CONFIG_IPSEC_INLINE =0x00000004 , - FW_CAPS_CONFIG_TX_TLS_HW = 0x00000008, + FW_CAPS_CONFIG_TLS_HW = 0x00000008, }; enum fw_caps_config_fcoe {
@@ -1329,7 +1329,7 @@ enum fw_params_param_dev {FW_PARAMS_PARAM_DEV_DBQ_TIMERTICK =0x2A ,FW_PARAMS_PARAM_DEV_NUM_TM_CLASS =0x2B ,FW_PARAMS_PARAM_DEV_FILTER =0x2E , - FW_PARAMS_PARAM_DEV_KTLS_TX_HW = 0x31, + FW_PARAMS_PARAM_DEV_KTLS_HW = 0x31, };/*
@@ -1412,6 +1412,12 @@ enum fw_params_param_dmaq { FW_PARAMS_PARAM_DMAQ_CONM_CTXT = 0x20, }; +enum fw_params_param_dev_ktls_hw { +FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE =0x00 , +FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE =0x01 , +FW_PARAMS_PARAM_DEV_KTLS_HW_USER_ENABLE =0x01 , +}; +enum fw_params_param_dev_phyfw {FW_PARAMS_PARAM_DEV_PHYFW_DOWNLOAD =0x00 ,FW_PARAMS_PARAM_DEV_PHYFW_VERSION =0x01 ,
Signature · 1 line
2.18.1
Jakub Kicinski
maintainerQuoted 13 lines · On Mon, 18 May 2020 14:29:18 +0530 Rohit Maheshwari wrote:
drivers/crypto/chelsio/chcr_ktls.c +4
-1for_each_port (adap, i) { netdev = adap->port[i]; - netdev->features |=NETIF_F_HW_TLS_TX ; netdev->hw_features |=NETIF_F_HW_TLS_TX ; netdev->tlsdev_ops = &chcr_ktls_ops; + +rtnl_lock (); +netdev_update_features (netdev); +rtnl_unlock (); } }
drivers/crypto/chelsio/chcr_ktls.c void chcr_disable_ktls(struct adapter *adap) · line 585
Quoted 2 lines
drivers/crypto/chelsio/chcr_ktls.c +0
-0@@ -571,6 +584,10 @@ void chcr_disable_ktls(struct adapter *adap) netdev->features &= ~NETIF_F_HW_TLS_TX ; netdev->hw_features &= ~NETIF_F_HW_TLS_TX ;
Twiddling with device flags without holding rtnl_lock seems questionable.
drivers/crypto/chelsio/chcr_ktls.c void chcr_disable_ktls(struct adapter *adap) · line 586
Quoted 1 line
drivers/crypto/chelsio/chcr_ktls.c +0
-0netdev->tlsdev_ops =NULL ;
Clearing the ops pointer at runtime with no synchronization - even more so. What if TLS code is mid-way through adding a connection?
Quoted 5 lines
drivers/crypto/chelsio/chcr_ktls.c +3
-0+rtnl_lock (); +netdev_update_features (netdev); +rtnl_unlock (); } }