Cleanups for ixgbe, i40e, and iavf PMD's
cover Cleanups for ixgbe, i40e, and iavf PMD's
This patchset is an assortment of cleanups for ixgbe, i40e, and iavf PMD.
IXGBE:
- Remove unnecessary macros and #ifdef's
- Disentangle unrelated flow API code paths
I40E:
- Get rid of global variables and unnecessary allocations
- Reduce code duplication around default RSS keys
- Use more appropriate integer types and definitions
IAVF:
- Remove dead code
- Remove unnecessary allocations
- Separate RSS uninit from hash flow parser uninit
This is done in preparation for further rework.
Anatoly Burakov (12):
net/ixgbe: remove MAC type check macros net/ixgbe: remove security-related ifdefery net/ixgbe: split security and ntuple filters net/i40e: get rid of global filter variables net/i40e: use stack allocations for tunnel set net/i40e: make default RSS key global net/i40e: use unsigned types for queue comparisons net/i40e: use proper flex len define net/i40e: remove global pattern variable net/iavf: remove remnants of pipeline mode net/iavf: do not use malloc in crypto VF commands net/iavf: decouple hash uninit from parser uninit
drivers/net/intel/i40e/i40e_ethdev.c | 148 ++++++++--------- drivers/net/intel/i40e/i40e_ethdev.h | 24 +-- drivers/net/intel/i40e/i40e_flow.c | 146 ++++++++--------- drivers/net/intel/i40e/i40e_hash.c | 27 +++- drivers/net/intel/i40e/i40e_hash.h | 3 + drivers/net/intel/iavf/iavf_ethdev.c | 4 + drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 -- drivers/net/intel/iavf/iavf_hash.c | 14 +- drivers/net/intel/iavf/iavf_hash.h | 13 ++ drivers/net/intel/iavf/iavf_ipsec_crypto.c | 158 ++++++------------ drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 - drivers/net/intel/ixgbe/ixgbe_ethdev.h | 16 -- drivers/net/intel/ixgbe/ixgbe_flow.c | 162 ++++++++++++------- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 --- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 - drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 - 18 files changed, 352 insertions(+), 422 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
Signature · 1 line
2.47.3
PATCH 1/12 net/ixgbe: remove MAC type check macros
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -12
@@ -137,18 +137,6 @@#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)#define IXGBE_MAX_L2_TN_FILTER_NUM 128 -#define MAC_TYPE_FILTER_SUP_EXT (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\ - return -ENOTSUP;\ -} while (0) - -#define MAC_TYPE_FILTER_SUP (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\ - (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\ - (type) != ixgbe_mac_X550EM_a && (type) != ixgbe_mac_E610)\ - return -ENOTSUP;\ -} while (0) -/* Link speed for X550 auto negotiation */ #define IXGBE_LINK_SPEED_X550_AUTONEG (IXGBE_LINK_SPEED_100_FULL | \ IXGBE_LINK_SPEED_1GB_FULL | \
drivers/net/intel/ixgbe/ixgbe_flow.c +17 -3
@@ -621,7 +621,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP_EXT (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540) +return -ENOTSUP ; ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error);
@@ -861,7 +863,13 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_ethertype_filter (attr, pattern, actions, filter, error);
@@ -1150,7 +1158,13 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_syn_filter (attr, pattern, actions, filter, error);
Signature · 1 line
2.47.3
PATCH 2/12 net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovThe security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 ------ drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 --- drivers/net/intel/ixgbe/ixgbe_flow.c | 6 ----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 -------------------- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 -- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 ----- 6 files changed, 52 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0 -8
@@ -32,9 +32,7 @@#include <rte_random.h> #include <dev_driver.h> #include <rte_hash_crc.h> -#ifdef RTE_LIB_SECURITY #include <rte_security_driver.h> -#endif #include <rte_os_shim.h> #include "ixgbe_logs.h"
@@ -1177,11 +1175,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)/* Unlock any pending hardware semaphore */ ixgbe_swfw_lock_reset (hw); -#ifdef RTE_LIB_SECURITY /* Initialize security_ctx only for primary process*/ if (ixgbe_ipsec_ctx_create (eth_dev))return -ENOMEM ; -#endif /* Initialize DCB configuration*/ memset (dcb_config,0 ,sizeof (struct ixgbe_dcb_config ));
@@ -1362,10 +1358,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; err_exit: -#ifdef RTE_LIB_SECURITY rte_free (eth_dev->security_ctx); eth_dev->security_ctx =NULL ; -#endif return ret; }
@@ -3148,10 +3142,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* Remove all Traffic Manager configuration */ ixgbe_tm_conf_uninit (dev); -#ifdef RTE_LIB_SECURITY rte_free (dev->security_ctx); dev->security_ctx =NULL ; -#endif return ret; }
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -4
@@ -14,9 +14,7 @@#include "base/ixgbe_dcb_82599.h" #include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" -#ifdef RTE_LIB_SECURITY #include "ixgbe_ipsec.h" -#endif #include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h>
@@ -478,9 +476,7 @@ struct ixgbe_adapter {struct ixgbe_filter_info filter;struct ixgbe_l2_tn_info l2_tn;struct ixgbe_bw_conf bw_conf; -#ifdef RTE_LIB_SECURITY struct ixgbe_ipsec ipsec; -#endif bool rx_bulk_alloc_allowed;bool rx_vec_allowed;struct rte_timecounter systime_tc;
drivers/net/intel/ixgbe/ixgbe_flow.c +0 -6
@@ -214,7 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -#ifdef RTE_LIB_SECURITY /** * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY */
@@ -249,7 +248,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); } -#endif /* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -630,11 +628,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (filter->proto ==IPPROTO_ESP )return 0 ; -#endif /* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {
@@ -3074,11 +3070,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev, ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error); -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (ntuple_filter.proto ==IPPROTO_ESP )return flow; -#endif if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -26
@@ -459,7 +459,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, seqnum_seed |= tx_offload.l2_len <<IXGBE_ADVTXD_TUNNEL_LEN ; } -#ifdef RTE_LIB_SECURITY if (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ) {union ixgbe_crypto_tx_desc_md *md = (union ixgbe_crypto_tx_desc_md *)mdata;
@@ -473,7 +472,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, tx_offload_mask.sa_idx |= ~0 ; tx_offload_mask.sec_pad_len |= ~0 ; } -#endif txq->ctx_cache[ctx_idx].flags = ol_flags; txq->ctx_cache[ctx_idx].tx_offload.data[0] =
@@ -652,9 +650,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint32_t ctx =0 ;uint32_t new_ctx;union ixgbe_tx_offload tx_offload; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec; -#endif tx_offload.data[0 ] =0 ; tx_offload.data[1 ] =0 ;
@@ -682,9 +678,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,* are needed for offload functionality. */ ol_flags = tx_pkt->ol_flags; -#ifdef RTE_LIB_SECURITY use_ipsec = txq->using_ipsec && (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ); -#endif /* If hardware offload required */ tx_ol_req = ol_flags &IXGBE_TX_OFFLOAD_MASK ;
@@ -696,7 +690,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.tso_segsz = tx_pkt->tso_segsz; tx_offload.outer_l2_len = tx_pkt->outer_l2_len; tx_offload.outer_l3_len = tx_pkt->outer_l3_len; -#ifdef RTE_LIB_SECURITY if (use_ipsec) {union ixgbe_crypto_tx_desc_md *ipsec_mdata = (union ixgbe_crypto_tx_desc_md *)
@@ -704,7 +697,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.sa_idx = ipsec_mdata->sa_idx; tx_offload.sec_pad_len = ipsec_mdata->pad_len; } -#endif /* If new context need be built or reuse the exist ctx. */ ctx = what_advctx_update(txq, tx_ol_req,
@@ -896,10 +888,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, olinfo_status |= ctx <<IXGBE_ADVTXD_IDX_SHIFT ; } olinfo_status |= (pkt_len <<IXGBE_ADVTXD_PAYLEN_SHIFT ); -#ifdef RTE_LIB_SECURITY if (use_ipsec) olinfo_status |=IXGBE_ADVTXD_POPTS_IPSEC ; -#endif m_seg = tx_pkt; do {
@@ -1523,13 +1513,11 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status, uint16_t pkt_info, pkt_flags |=RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD ; } -#ifdef RTE_LIB_SECURITY if (rx_status &IXGBE_RXD_STAT_SECP ) { pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD ;if (rx_status &IXGBE_RXDADV_LNKSEC_ERROR_BAD_SIG ) pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED ; } -#endif return pkt_flags; }
@@ -2490,9 +2478,7 @@ ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) {struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;if (txq->offloads ==0 && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST ) { if (txq->tx_rs_thresh <= IXGBE_TX_MAX_FREE_BUF_SZ && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
@@ -2648,9 +2634,7 @@ ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ci_tx_queue *txq) {/* Use a simple Tx queue (no offloads, no multi segs) if possible */ if ((txq->offloads ==0 ) && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif (txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST )) {PMD_INIT_LOG (DEBUG ,"Using simple tx code path" ); dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
@@ -2711,10 +2695,8 @@ ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_SECURITY ; -#endif return tx_offload_capa; }
@@ -2884,10 +2866,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; -#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY ); -#endif /* * Modification to set VFTDT for virtual function if vf is detected
@@ -3171,10 +3151,8 @@ ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) offloads |=RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; -#endif return offloads; }
@@ -5102,10 +5080,8 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)struct ci_rx_queue *rxq = dev->data->rx_queues[i]; rxq->vector_rx = rx_using_sse; -#ifdef RTE_LIB_SECURITY rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ); -#endif } }
@@ -5611,7 +5587,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)ixgbe_setup_loopback_link_x540_x550 (hw, true); } -#ifdef RTE_LIB_SECURITY if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) || (dev->data->dev_conf.txmode.offloads &
@@ -5624,7 +5599,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)return ret; } } -#endif return 0 ; }
drivers/net/intel/ixgbe/ixgbe_rxtx.h +0 -2
@@ -99,11 +99,9 @@ union ixgbe_tx_offload {/* fields for TX offloading of tunnels */ uint64_t outer_l3_len:8; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:8; /**< Outer L2 (MAC) Hdr Length. */ -#ifdef RTE_LIB_SECURITY /* inline ipsec related*/ uint64_t sa_idx:8; /**< TX SA database entry index */ uint64_t sec_pad_len:4; /**< padding length */ -#endif }; };
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c +0 -6
@@ -21,7 +21,6 @@ ixgbe_rxq_rearm(struct ci_rx_queue *rxq)ci_rxq_rearm (rxq,CI_RX_VEC_LEVEL_SSE ); } -#ifdef RTE_LIB_SECURITY static inline void desc_to_olflags_v_ipsec (__m128i descs[4 ],struct rte_mbuf **rx_pkts) {
@@ -56,7 +55,6 @@ desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts) *rearm2 =_mm_extract_epi32 (rearm,2 ); *rearm3 =_mm_extract_epi32 (rearm,3 ); } -#endif static inline void desc_to_olflags_v(__m128i descs[4], __m128i mbuf_init, uint8_t vlan_flags,
@@ -265,9 +263,7 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,volatile union ixgbe_adv_rx_desc *rxdp;struct ci_rx_entry *sw_ring;uint16_t nb_pkts_recd; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec = rxq->using_ipsec; -#endif int pos;uint64_t var;__m128i shuf_msk;
@@ -444,10 +440,8 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,desc_to_olflags_v (descs, mbuf_init, vlan_flags, udp_p_flag, &rx_pkts[pos]); -#ifdef RTE_LIB_SECURITY if (unlikely (use_ipsec))desc_to_olflags_v_ipsec (descs, &rx_pkts[pos]); -#endif /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */ pkt_mb4 =_mm_add_epi16 (pkt_mb4, crc_adjust);
Signature · 1 line
2.47.3
PATCH 3/12 net/ixgbe: split security and ntuple filters
In reply to Anatoly BurakovThese filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
While we're at it, we're making checks more stringent (such as checking for NULL conf), and more type safe.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 136 ++++++++++++++++++--------- 1 file changed, 91 insertions(+), 45 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +91 -45
@@ -214,41 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -/** -* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY -*/ - act =next_no_void_action (actions,NULL ); -if (act->type ==RTE_FLOW_ACTION_TYPE_SECURITY ) { -const void *conf = act->conf; -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -/* get the IP pattern*/ - item =next_no_void_pattern (pattern,NULL ); -while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { -if (item->last || - item->type ==RTE_FLOW_ITEM_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"IP pattern missing." ); -return -rte_errno; - } - item =next_no_void_pattern (pattern, item); - } - - filter->proto =IPPROTO_ESP ; -return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, - item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); - } -/* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -607,6 +572,81 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return 0 ; } +static int __rte_unused +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[],const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +const struct rte_flow_action_security *security; +const struct rte_flow_item *item; +const struct rte_flow_action *act; + +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; + +if (pattern ==NULL ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (actions ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (attr ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +return -rte_errno; + } + +/* check if next non-void action is security */ + act =next_no_void_action (actions,NULL ); +if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + security = act->conf; +if (security ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"NULL security action config." ); + } +/* check if the next not void item is END */ + act =next_no_void_action (actions, act); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + +/* get the IP pattern*/ + item =next_no_void_pattern (pattern,NULL ); +while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +if (item->last || item->type ==RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"IP pattern missing." ); +return -rte_errno; + } + item =next_no_void_pattern (pattern, item); + } + +return ixgbe_crypto_add_ingress_sa_from_flow (security->security_session, + item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -628,10 +668,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -/* ESP flow not really a flow*/ -if (filter->proto ==IPPROTO_ESP ) -return 0 ; -/* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -3066,14 +3102,17 @@ ixgbe_flow_create(struct rte_eth_dev *dev,TAILQ_INSERT_TAIL (&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries); -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, - actions, &ntuple_filter, error); - -/* ESP flow not really a flow*/ -if (ntuple_filter.proto ==IPPROTO_ESP ) +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret)return flow; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);if (!ret) {
@@ -3297,6 +3336,13 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf rss_conf;int ret; +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) +return 0 ; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error);
Signature · 1 line
2.47.3
PATCH 4/12 net/i40e: get rid of global filter variables
In reply to Anatoly BurakovCurrently, i40e driver relies on global state to work around the fact that rte_flow_validate() is being called directly from rte_flow_create(), and it not being possible to pass state between two functions. Fix that by making a small wrapper around validation that will create a dummy context.
Additionally, tunnel filter doesn't appear to be used by anything and so is omitted from the structure.
--- drivers/net/intel/i40e/i40e_ethdev.h | 16 ++-- drivers/net/intel/i40e/i40e_flow.c | 117 ++++++++++++++------------- 2 files changed, 68 insertions(+), 65 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +9 -7
@@ -1304,12 +1304,14 @@ struct i40e_vf_representor {extern const struct rte_flow_ops i40e_flow_ops; -union i40e_filter_t { -struct rte_eth_ethertype_filter ethertype_filter; -struct i40e_fdir_filter_conf fdir_filter; -struct rte_eth_tunnel_filter_conf tunnel_filter; -struct i40e_tunnel_filter_conf consistent_tunnel_filter; -struct i40e_rte_flow_rss_conf rss_conf; +struct i40e_filter_ctx { +union { +struct rte_eth_ethertype_filter ethertype_filter; +struct i40e_fdir_filter_conf fdir_filter; +struct i40e_tunnel_filter_conf consistent_tunnel_filter; +struct i40e_rte_flow_rss_conf rss_conf; + }; +enum rte_filter_type type; }; typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -1317,7 +1319,7 @@ typedef int (*parse_filter_t)(struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error, - union i40e_filter_t *filter); + struct i40e_filter_ctx *filter);struct i40e_valid_pattern {enum rte_flow_item_type *items;parse_filter_t parse_filter;
drivers/net/intel/i40e/i40e_flow.c +59 -58
351 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH 5/12 net/i40e: use stack allocations for tunnel set
In reply to Anatoly BurakovCurrently, the tunnel "set" function is using rte_zmalloc to allocate a temporary variable. It is actually not needed in this context and can be avoided entirely and replaced with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++--------------- 1 file changed, 53 insertions(+), 71 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +53 -71
@@ -8511,38 +8511,27 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,struct i40e_pf_vf *vf =NULL ;struct i40e_hw *hw =I40E_PF_TO_HW (pf);struct i40e_vsi *vsi; -struct i40e_aqc_cloud_filters_element_bb *cld_filter; -struct i40e_aqc_cloud_filters_element_bb *pfilter; +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 };struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -struct i40e_tunnel_filter *tunnel, *node; +struct i40e_tunnel_filter *node;struct i40e_tunnel_filter check_filter;/* Check if filter exists */ uint32_t teid_le;bool big_buffer =0 ; - cld_filter =rte_zmalloc ("tunnel_filter" , -sizeof (struct i40e_aqc_add_rm_cloud_filt_elem_ext ), -0 ); - -if (cld_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - pfilter = cld_filter; -rte_ether_addr_copy (&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&pfilter->element.outer_mac); + (struct rte_ether_addr *)&cld_filter.element.outer_mac);rte_ether_addr_copy (&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&pfilter->element.inner_mac); + (struct rte_ether_addr *)&cld_filter.element.inner_mac); - pfilter->element.inner_vlan = + cld_filter.element.inner_vlan =rte_cpu_to_le_16 (tunnel_filter->inner_vlan);if (tunnel_filter->ip_type ==I40E_TUNNEL_IPTYPE_IPV4 ) { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV4 ; ipv4_addr =rte_be_to_cpu_32 (tunnel_filter->ip_addr.ipv4_addr); ipv4_addr_le =rte_cpu_to_le_32 (ipv4_addr); -rte_memcpy (&pfilter->element.ipaddr.v4.data, +rte_memcpy (&cld_filter.element.ipaddr.v4.data, &ipv4_addr_le, -sizeof (pfilter->element.ipaddr.v4.data)); +sizeof (cld_filter.element.ipaddr.v4.data)); }else { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ;for (i =0 ; i <4 ; i++) {
@@ -8550,9 +8539,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,rte_cpu_to_le_32 (rte_be_to_cpu_32 ( tunnel_filter->ip_addr.ipv6_addr[i])); } -rte_memcpy (&pfilter->element.ipaddr.v6.data, +rte_memcpy (&cld_filter.element.ipaddr.v6.data, &convert_ipv6, -sizeof (pfilter->element.ipaddr.v6.data)); +sizeof (cld_filter.element.ipaddr.v6.data)); }/* check tunneled type */
@@ -8573,11 +8562,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x40 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP ;
@@ -8589,11 +8578,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x0 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE ;
@@ -8605,11 +8594,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8620,11 +8609,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8641,8 +8630,8 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,* Big Buffer should be set, see changes in * i40e_aq_add_cloud_filters */ - pfilter->general_fields[0 ] = tunnel_filter->inner_vlan; - pfilter->general_fields[1 ] = tunnel_filter->outer_vlan; + cld_filter.general_fields[0 ] = tunnel_filter->inner_vlan; + cld_filter.general_fields[1 ] = tunnel_filter->outer_vlan; big_buffer =1 ;break ;case I40E_CLOUD_TYPE_UDP :
@@ -8657,20 +8646,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->sport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }else {
@@ -8682,20 +8671,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->dport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }
@@ -8704,48 +8693,46 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,default :/* Other tunnel types is not supported. */ PMD_DRV_LOG (ERR ,"tunnel type is not supported." ); -rte_free (cld_filter);return -EINVAL ; }if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPC ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPU ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_QINQ ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_SCTP ) {if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ; }else { val =i40e_dev_get_filter_type (tunnel_filter->filter_type, - &pfilter->element.flags); + &cld_filter.element.flags);if (val <0 ) { -rte_free (cld_filter);return -EINVAL ; } } - pfilter->element.flags |=rte_cpu_to_le_16 ( -I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | - ip_type | (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); - pfilter->element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->element.queue_number = + cld_filter.element.flags |= +rte_cpu_to_le_16 (I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type | + (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); + cld_filter.element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); + cld_filter.element.queue_number =rte_cpu_to_le_16 (tunnel_filter->queue_id);if (!tunnel_filter->is_to_vf)
@@ -8753,7 +8740,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,else {if (tunnel_filter->vf_id >= pf->vf_num) {PMD_DRV_LOG (ERR ,"Invalid argument." ); -rte_free (cld_filter);return -EINVAL ; } vf = &pf->vfs[tunnel_filter->vf_id];
@@ -8762,38 +8748,36 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,/* Check if there is the filter in SW list */ memset (&check_filter,0 ,sizeof (check_filter)); -i40e_tunnel_filter_convert (cld_filter, &check_filter); +i40e_tunnel_filter_convert (&cld_filter, &check_filter); check_filter.is_to_vf = tunnel_filter->is_to_vf; check_filter.vf_id = tunnel_filter->vf_id; node =i40e_sw_tunnel_filter_lookup (tunnel_rule, &check_filter.input);if (add && node) {PMD_DRV_LOG (ERR ,"Conflict with existing tunnel rules!" ); -rte_free (cld_filter);return -EINVAL ; }if (!add && !node) {PMD_DRV_LOG (ERR ,"There's no corresponding tunnel filter!" ); -rte_free (cld_filter);return -EINVAL ; }if (add) { +struct i40e_tunnel_filter *tunnel; +if (big_buffer) ret =i40e_aq_add_cloud_filters_bb (hw, - vsi->seid, cld_filter,1 ); + vsi->seid, &cld_filter,1 );else ret =i40e_aq_add_cloud_filters (hw, - vsi->seid, &cld_filter->element,1 ); + vsi->seid, &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to add a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } tunnel =rte_zmalloc ("tunnel_filter" ,sizeof (*tunnel),0 );if (tunnel ==NULL ) {PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -rte_free (cld_filter);return -ENOMEM ; }
@@ -8804,19 +8788,17 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, }else {if (big_buffer) ret =i40e_aq_rem_cloud_filters_bb ( - hw, vsi->seid, cld_filter,1 ); + hw, vsi->seid, &cld_filter,1 );else ret =i40e_aq_rem_cloud_filters (hw, vsi->seid, - &cld_filter->element,1 ); + &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to delete a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } ret =i40e_sw_tunnel_filter_del (pf, &node->input); } -rte_free (cld_filter);return ret; }
Signature · 1 line
2.47.3
PATCH 6/12 net/i40e: make default RSS key global
In reply to Anatoly BurakovCurrently, there are multiple places where we need a default RSS key, but in each of those places we define it as a local variable. Make it global constant, and adjust all callers to use the global constant. When dealing with adminq, we cannot send down the constant because adminq commands do not guarantee const-ness, so copy RSS key into a local buffer before sending it down to hardware.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 ++++++++++------------ drivers/net/intel/i40e/i40e_hash.c | 23 +++++++++++++++++------ drivers/net/intel/i40e/i40e_hash.h | 3 +++ 3 files changed, 30 insertions(+), 18 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +10 -12
@@ -9064,23 +9064,21 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)int i40e_pf_reset_rss_key (struct i40e_pf *pf) { -const uint8_t key_len = (I40E_PFQF_HKEY_MAX_INDEX +1 ) * -sizeof (uint32_t ); -uint8_t *rss_key; +uint8_t key_buf[I40E_RSS_KEY_LEN ]; +const uint8_t *rss_key;/* Reset key */ rss_key = pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key; -if (!rss_key || - pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len < key_len) { -static uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; +if (!rss_key || pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len <sizeof (key_buf)) + rss_key = i40e_rss_key_default; - rss_key = (uint8_t *)rss_key_default; - } +/* +* adminq does not guarantee const-ness of RSS key once a command is sent down, so make a +* local copy. +*/ +memcpy (&key_buf, rss_key,sizeof (key_buf)); -return i40e_set_rss_key (pf->main_vsi, rss_key, key_len); +return i40e_set_rss_key (pf->main_vsi, key_buf,sizeof (key_buf)); } static int
drivers/net/intel/i40e/i40e_hash.c +17 -6
@@ -233,6 +233,22 @@ struct i40e_hash_match_pattern { RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) +const uint8_t i40e_rss_key_default[] = { +0x44 ,0x39 ,0x79 ,0x6b , +0xb5 ,0x4c ,0x50 ,0x23 , +0xb6 ,0x75 ,0xea ,0x5b , +0x12 ,0x4f ,0x9f ,0x30 , +0xb8 ,0xa2 ,0xc0 ,0x3d , +0xdf ,0xdc ,0x4d ,0x02 , +0xa0 ,0x8c ,0x9b ,0x33 , +0x4a ,0xf6 ,0x4a ,0x4c , +0x05 ,0xc6 ,0xfa ,0x34 , +0x39 ,0x58 ,0xd8 ,0x55 , +0x7d ,0x99 ,0x58 ,0x3a , +0xe1 ,0x38 ,0xc9 ,0x2e , +0x81 ,0x15 ,0x03 ,0x66 +}; +/* Current supported patterns and RSS types. * All items that have the same pattern types are together. */
@@ -910,17 +926,12 @@ i40e_hash_parse_key(const struct rte_flow_action_rss *rss_act,const uint8_t *key = rss_act->key;if (!key || rss_act->key_len !=sizeof (rss_conf->key)) { -const uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; -if (rss_act->key_len !=sizeof (rss_conf->key))PMD_DRV_LOG (WARNING ,"RSS key length invalid, must be %u bytes, now set key to default" , (uint32_t )sizeof (rss_conf->key)); -memcpy (rss_conf->key, rss_key_default,sizeof (rss_conf->key)); +memcpy (rss_conf->key, i40e_rss_key_default,sizeof (rss_conf->key)); }else {memcpy (rss_conf->key, key,sizeof (rss_conf->key)); }
drivers/net/intel/i40e/i40e_hash.h +3 -0
@@ -27,6 +27,9 @@ int i40e_hash_filter_destroy(struct i40e_pf *pf, const struct i40e_rss_filter *rss_filter);int i40e_hash_filter_flush (struct i40e_pf *pf); +#define I40E_RSS_KEY_LEN ((I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) +extern const uint8_t i40e_rss_key_default[I40E_RSS_KEY_LEN ]; + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH 7/12 net/i40e: use unsigned types for queue comparisons
In reply to Anatoly BurakovCurrently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare I40E_MAX_Q_PER_TC to an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence, i40e_align_floor now returns unsigned value as well - this is correct, because nothing about that function implies signed usage being a valid use case.
--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +1 -1
@@ -9040,7 +9040,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
drivers/net/intel/i40e/i40e_ethdev.h +3 -3
@@ -24,7 +24,7 @@#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ -#define I40E_MAX_Q_PER_TC 64 +#define I40E_MAX_Q_PER_TC 64U#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw) hw->aq.asq_buf_size =I40E_AQ_BUF_SZ ; } -static inline int -i40e_align_floor (int n) +static inline uint32_t +i40e_align_floor (uint32_t n) {if (n ==0 )return 0 ;
drivers/net/intel/i40e/i40e_hash.c +2 -2
@@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev,struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue; hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); if (!rss_act->queue_num ||
@@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, max_queue =RTE_MIN (max_queue,I40E_MAX_Q_PER_TC );for (i =0 ; i < rss_act->queue_num; i++) { -if ((int )rss_act->queue[i] >= max_queue) +if (rss_act->queue[i] >= max_queue)break ; }
Signature · 1 line
2.47.3
PATCH 8/12 net/i40e: use proper flex len define
In reply to Anatoly BurakovFor FDIR, we have byte arrays that are supposed to be limited to whatever the HW supports in terms of flex descriptor matching. However, in the structure definition, spec and mask bytes are using different array length defines, and the only reason why this works is because they evaluate to the same value.
Use the i40e-specific definition instead.
--- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -631,7 +631,7 @@ struct i40e_fdir_flex_pit {/* A structure used to contain extend input of flow */ struct i40e_fdir_flow_ext {uint16_t vlan_tci; -uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN ]; +uint8_t flexbytes[I40E_FDIR_MAX_FLEX_LEN ];/* It is filled by the flexible payload to match. */ uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN ];uint8_t raw_id;
Signature · 1 line
2.47.3
PATCH 9/12 net/i40e: remove global pattern variable
In reply to Anatoly BurakovWhen parsing flow patterns, current code cleans up the pattern list by removing void flow items, and copies the patterns into an array. That array, when dealing with under 32 flow items, is allocated on the stack, but when the pattern is big enough, a new list is dynamically allocated. This allocated list is a global variable, and is allocated using rte_zmalloc call which seems like overkill for this use case.
Remove the global variable, and replace the split behavior with unconditional allocation.
--- drivers/net/intel/i40e/i40e_flow.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +9 -20
@@ -145,9 +145,6 @@ const struct rte_flow_ops i40e_flow_ops = { .query = i40e_flow_query, }; -/* internal pattern w/o VOID items */ -struct rte_flow_item g_items[32 ]; -/* Pattern matched ethertype filter */ static enum rte_flow_item_type pattern_ethertype[] = {RTE_FLOW_ITEM_TYPE_ETH ,
@@ -3837,19 +3834,13 @@ i40e_flow_check(struct rte_eth_dev *dev, i++; } item_num++; - -if (item_num <=ARRAY_SIZE (g_items)) { - items = g_items; - }else { - items =rte_zmalloc ("i40e_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); -if (!items) { -rte_flow_error_set (error,ENOMEM , -RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL , -"No memory for PMD internal items." ); -return -ENOMEM ; - } + items =calloc (item_num,sizeof (struct rte_flow_item )); +if (items ==NULL ) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL , +"No memory for PMD internal items." ); +return -ENOMEM ; }i40e_pattern_skip_void_item (items, pattern);
@@ -3862,8 +3853,7 @@ i40e_flow_check(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ITEM , pattern, "Unsupported pattern"); -if (items != g_items) -rte_free (items); +free (items);return -rte_errno; }
@@ -3873,8 +3863,7 @@ i40e_flow_check(struct rte_eth_dev *dev, flag = true; }while ((ret <0 ) && (i <RTE_DIM (i40e_supported_patterns))); -if (items != g_items) -rte_free (items); +free (items);return ret; }
Signature · 1 line
2.47.3
PATCH 10/12 net/iavf: remove remnants of pipeline mode
In reply to Anatoly BurakovWhen pipeline mode was removed, some of the things used by pipelines were left in the code. Remove them as they are unused.
--- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 --------------- drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_ipsec_crypto.c | 1 - 5 files changed, 19 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +0 -1
@@ -1632,7 +1632,6 @@ static struct iavf_flow_parser iavf_fdir_parser = { .array = iavf_fdir_pattern, .array_len = RTE_DIM(iavf_fdir_pattern), .parse_pattern_action = iavf_fdir_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fdir_engine_register)
drivers/net/intel/iavf/iavf_fsub.c +0 -1
@@ -814,7 +814,6 @@ iavf_flow_parser iavf_fsub_parser = { .array = iavf_fsub_pattern_list, .array_len = RTE_DIM(iavf_fsub_pattern_list), .parse_pattern_action = iavf_fsub_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fsub_engine_init)
drivers/net/intel/iavf/iavf_generic_flow.h +0 -15
@@ -485,20 +485,6 @@ enum iavf_flow_engine_type { IAVF_FLOW_ENGINE_MAX, }; -/** -* classification stages. -* for non-pipeline mode, we have two classification stages: Distributor/RSS -* for pipeline-mode we have three classification stages: -* Permission/Distributor/RSS -*/ -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 , -}; -/* Struct to store engine created. */ struct iavf_flow_engine {TAILQ_ENTRY (iavf_flow_engine) node;
@@ -527,7 +513,6 @@ struct iavf_flow_parser {struct iavf_pattern_match_item *array;uint32_t array_len;parse_pattern_action_t parse_pattern_action; -enum iavf_flow_classification_stage stage; };/* Struct to store parser created. */
drivers/net/intel/iavf/iavf_hash.c +0 -1
@@ -691,7 +691,6 @@ static struct iavf_flow_parser iavf_hash_parser = { .array = iavf_hash_pattern_list, .array_len = RTE_DIM(iavf_hash_pattern_list), .parse_pattern_action = iavf_hash_parse_pattern_action, - .stage = IAVF_FLOW_STAGE_RSS, };int
drivers/net/intel/iavf/iavf_ipsec_crypto.c +0 -1
@@ -1983,7 +1983,6 @@ static struct iavf_flow_parser iavf_ipsec_flow_parser = { .array = iavf_ipsec_flow_pattern, .array_len = RTE_DIM(iavf_ipsec_flow_pattern), .parse_pattern_action = iavf_ipsec_flow_parse, - .stage = IAVF_FLOW_STAGE_IPSEC_CRYPTO, };RTE_INIT (iavf_ipsec_flow_engine_register)
Signature · 1 line
2.47.3
PATCH 11/12 net/iavf: do not use malloc in crypto VF commands
In reply to Anatoly BurakovCurrently, when calling down into the VF mailbox, IPsec code will use dynamic memory allocation (rte_malloc one at that!) to allocate VF message structures which are ~40 bytes in size, and then immediately frees them. This is wasteful and unnecessary, so use stack allocation instead.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 157 +++++++-------------- 1 file changed, 51 insertions(+), 106 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +51 -106
@@ -458,36 +458,24 @@ static uint32_t iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, struct rte_security_session_conf *conf) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -struct virtchnl_ipsec_sa_cfg *sa_cfg; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg sa_cfg; + } sa_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp; +struct inline_ipsec_msg *request = &sa_req.msg, *response = &sa_resp.msg; +struct virtchnl_ipsec_sa_cfg *sa_cfg = &sa_req.sa_cfg;int rc; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg ); - - request =rte_malloc ("iavf-sad-add-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg_resp ); - response =rte_malloc ("iavf-sad-add-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;/* set SA configuration params */ - sa_cfg = (struct virtchnl_ipsec_sa_cfg *)(request +1 ); - sa_cfg->spi = conf->ipsec.spi; sa_cfg->virtchnl_protocol_type =VIRTCHNL_PROTO_ESP ; sa_cfg->virtchnl_direction =
@@ -541,10 +529,10 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sa_req), + (uint8_t *)response,sizeof (sa_resp));if (rc) - goto update_cleanup; +return rc;/* verify response id */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -552,9 +540,6 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, rc = -EFAULT ; else rc = response->ipsec_data.sa_cfg_resp->sa_handle; -update_cleanup: -rte_free (response); -rte_free (request);return rc; }
@@ -722,19 +707,18 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, bool is_udp, uint16_t udp_port) { -struct inline_ipsec_msg *request =NULL , *response =NULL ; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg sp_cfg; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg; +struct inline_ipsec_msg *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg ); - request =rte_malloc ("iavf-inbound-security-policy-add-request" , - request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -768,21 +752,12 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, request->ipsec_data.sp_cfg->is_udp = is_udp; request->ipsec_data.sp_cfg->udp_port =htons (udp_port); - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg_resp ); - response =rte_malloc ("iavf-inbound-security-policy-add-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -791,10 +766,6 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,else rc = response->ipsec_data.sp_cfg_resp->rule_id; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -802,26 +773,17 @@ static uint32_t iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_update sa_update; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_update ); - request =rte_malloc ("iavf-sa-update-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sa-update-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_UPDATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -833,10 +795,10 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -845,10 +807,6 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,else rc = response->ipsec_data.ipsec_resp->resp; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -899,26 +857,17 @@ int iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter, uint8_t is_v4, uint32_t flow_id) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_destroy sp_destroy; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_destroy ); - request =rte_malloc ("iavf-sp-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sp-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -931,21 +880,17 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode || response->req_id != request->req_id) rc = -EFAULT ;else -return response->ipsec_data.ipsec_status->status; - -update_cleanup: -rte_free (request); -rte_free (response); + rc = response->ipsec_data.ipsec_status->status;return rc; }
Signature · 1 line
2.47.3
PATCH 12/12 net/iavf: decouple hash uninit from parser uninit
In reply to Anatoly BurakovCurrently, parser deinitialization will trigger removal of current RSS configuration. This should not be done as part of parser deinitialization, but should rather be a separate step in dev close flow.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++++ drivers/net/intel/iavf/iavf_hash.c | 13 +++++++++---- drivers/net/intel/iavf/iavf_hash.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
drivers/net/intel/iavf/iavf_ethdev.c +4 -0
@@ -35,6 +35,7 @@#include "iavf_generic_flow.h" #include "rte_pmd_iavf.h" #include "iavf_ipsec_crypto.h" +#include "iavf_hash.h" /* devargs */ #define IAVF_PROTO_XTR_ARG "proto_xtr"
@@ -2972,6 +2973,9 @@ iavf_dev_close(struct rte_eth_dev *dev)/* free iAVF security device context all related resources */ iavf_security_ctx_destroy (adapter); +/* remove RSS configuration */ +iavf_hash_uninit (adapter); +iavf_flow_flush (dev,NULL );iavf_flow_uninit (adapter);
drivers/net/intel/iavf/iavf_hash.c +9 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "iavf_hash.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -77,7 +78,7 @@ static int iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow, struct rte_flow_error *error);static void -iavf_hash_uninit (struct iavf_adapter *ad); +iavf_hash_uninit_parser (struct iavf_adapter *ad);static void iavf_hash_free (struct rte_flow *flow); static int
@@ -680,7 +681,7 @@ static struct iavf_flow_engine iavf_hash_engine = { .init = iavf_hash_init, .create = iavf_hash_create, .destroy = iavf_hash_destroy, - .uninit = iavf_hash_uninit, + .uninit = iavf_hash_uninit_parser, .free = iavf_hash_free, .type = IAVF_FLOW_ENGINE_HASH, };
@@ -1641,6 +1642,12 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad, }static void +iavf_hash_uninit_parser (struct iavf_adapter *ad) +{ +iavf_unregister_parser (&iavf_hash_parser, ad); +} + +void iavf_hash_uninit (struct iavf_adapter *ad) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);
@@ -1658,8 +1665,6 @@ iavf_hash_uninit(struct iavf_adapter *ad) rss_conf = &ad->dev_data->dev_conf.rx_adv_conf.rss_conf;if (iavf_rss_hash_set (ad, rss_conf->rss_hf, false))PMD_DRV_LOG (ERR ,"fail to delete default RSS" ); - -iavf_unregister_parser (&iavf_hash_parser, ad); } static void
drivers/net/intel/iavf/iavf_hash.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */
Signature · 1 line
2.47.3
Re: [PATCH v1 05/12] net/i40e: use stack allocations for tunnel set
In reply to Anatoly BurakovQuoted 6 lines · Anatoly Burakov
Currently, the tunnel "set" function is using
rte_zmallocto allocate a temporary variable. It is actually not needed in this context and can be avoided entirely and replaced with stack allocation.Signed-off-by Anatoly Burakov <[email protected]>---
I've actually found quite a few more of these so I'll send them out as a separate patchset.
Signature · 2 lines
Thanks, Anatoly
v2 cover Cleanups for ixgbe, i40e, iavf, and ice PMD's
In reply to Anatoly BurakovThis patchset is an assortment of cleanups for ixgbe, i40e, iavf, and ice PMD.
IXGBE:
- Remove unnecessary macros and #ifdef's
- Disentangle unrelated flow API code paths
I40E:
- Get rid of global variables and unnecessary allocations
- Reduce code duplication around default RSS keys
- Use more appropriate integer types and definitions
IAVF:
- Remove dead code
- Remove unnecessary allocations
- Separate RSS uninit from hash flow parser uninit
ICE:
- Remove unnecessary allocations
This is done in preparation for further rework.
Note that IXGBE part of this patchset depends on MAC type check fixes [1].
v1 -> v2:
- Added more cleanups around rte_malloc usage
Anatoly Burakov (26):
net/ixgbe: remove MAC type check macros net/ixgbe: remove security-related ifdefery net/ixgbe: split security and ntuple filters net/i40e: get rid of global filter variables net/i40e: make default RSS key global net/i40e: use unsigned types for queue comparisons net/i40e: use proper flex len define net/i40e: remove global pattern variable net/i40e: avoid rte malloc in tunnel set net/i40e: avoid rte malloc in RSS RETA operations net/i40e: avoid rte malloc in MAC/VLAN filtering net/i40e: avoid rte malloc in VF resource queries net/i40e: avoid rte malloc in adminq operations net/i40e: avoid rte malloc in DDP package handling net/i40e: avoid rte malloc in DDP ptype handling net/iavf: remove remnants of pipeline mode net/iavf: do not use malloc in crypto VF commands net/iavf: decouple hash uninit from parser uninit net/iavf: avoid rte malloc in RSS configuration net/iavf: avoid rte malloc in MAC address operations net/iavf: avoid rte malloc in IPsec operations net/iavf: avoid rte malloc in queue operations net/iavf: avoid rte malloc in irq map config net/ice: avoid rte malloc in RSS RETA operations net/ice: avoid rte malloc in MAC address operations net/ice: avoid rte malloc in raw pattern parsing
drivers/net/intel/i40e/i40e_ethdev.c | 223 +++++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 24 +- drivers/net/intel/i40e/i40e_flow.c | 146 ++++++------ drivers/net/intel/i40e/i40e_hash.c | 27 ++- drivers/net/intel/i40e/i40e_hash.h | 3 + drivers/net/intel/i40e/i40e_pf.c | 26 +-- drivers/net/intel/i40e/rte_pmd_i40e.c | 59 ++--- drivers/net/intel/iavf/iavf_ethdev.c | 8 +- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 -- drivers/net/intel/iavf/iavf_hash.c | 14 +- drivers/net/intel/iavf/iavf_hash.h | 13 ++ drivers/net/intel/iavf/iavf_ipsec_crypto.c | 216 ++++++------------ drivers/net/intel/iavf/iavf_vchnl.c | 85 +++---- drivers/net/intel/ice/ice_dcf_ethdev.c | 8 +- drivers/net/intel/ice/ice_ethdev.c | 8 +- drivers/net/intel/ice/ice_fdir_filter.c | 14 +- drivers/net/intel/ice/ice_hash.c | 10 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 - drivers/net/intel/ixgbe/ixgbe_ethdev.h | 16 -- drivers/net/intel/ixgbe/ixgbe_flow.c | 162 +++++++++----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 --- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 - drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 - 25 files changed, 496 insertions(+), 625 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
Signature · 1 line
2.47.3
PATCH v2 1/26 net/ixgbe: remove MAC type check macros
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -12
@@ -137,18 +137,6 @@#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)#define IXGBE_MAX_L2_TN_FILTER_NUM 128 -#define MAC_TYPE_FILTER_SUP_EXT (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\ - return -ENOTSUP;\ -} while (0) - -#define MAC_TYPE_FILTER_SUP (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\ - (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\ - (type) != ixgbe_mac_X550EM_a && (type) != ixgbe_mac_E610)\ - return -ENOTSUP;\ -} while (0) -/* Link speed for X550 auto negotiation */ #define IXGBE_LINK_SPEED_X550_AUTONEG (IXGBE_LINK_SPEED_100_FULL | \ IXGBE_LINK_SPEED_1GB_FULL | \
drivers/net/intel/ixgbe/ixgbe_flow.c +17 -3
@@ -621,7 +621,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP_EXT (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540) +return -ENOTSUP ; ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error);
@@ -861,7 +863,13 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_ethertype_filter (attr, pattern, actions, filter, error);
@@ -1150,7 +1158,13 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_syn_filter (attr, pattern, actions, filter, error);
Signature · 1 line
2.47.3
PATCH v2 3/26 net/ixgbe: split security and ntuple filters
In reply to Anatoly BurakovThese filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
While we're at it, we're making checks more stringent (such as checking for NULL conf), and more type safe.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 136 ++++++++++++++++++--------- 1 file changed, 91 insertions(+), 45 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +91 -45
@@ -214,41 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -/** -* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY -*/ - act =next_no_void_action (actions,NULL ); -if (act->type ==RTE_FLOW_ACTION_TYPE_SECURITY ) { -const void *conf = act->conf; -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -/* get the IP pattern*/ - item =next_no_void_pattern (pattern,NULL ); -while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { -if (item->last || - item->type ==RTE_FLOW_ITEM_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"IP pattern missing." ); -return -rte_errno; - } - item =next_no_void_pattern (pattern, item); - } - - filter->proto =IPPROTO_ESP ; -return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, - item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); - } -/* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -607,6 +572,81 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return 0 ; } +static int __rte_unused +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[],const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +const struct rte_flow_action_security *security; +const struct rte_flow_item *item; +const struct rte_flow_action *act; + +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; + +if (pattern ==NULL ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (actions ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (attr ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +return -rte_errno; + } + +/* check if next non-void action is security */ + act =next_no_void_action (actions,NULL ); +if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + security = act->conf; +if (security ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"NULL security action config." ); + } +/* check if the next not void item is END */ + act =next_no_void_action (actions, act); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + +/* get the IP pattern*/ + item =next_no_void_pattern (pattern,NULL ); +while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +if (item->last || item->type ==RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"IP pattern missing." ); +return -rte_errno; + } + item =next_no_void_pattern (pattern, item); + } + +return ixgbe_crypto_add_ingress_sa_from_flow (security->security_session, + item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -628,10 +668,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -/* ESP flow not really a flow*/ -if (filter->proto ==IPPROTO_ESP ) -return 0 ; -/* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -3066,14 +3102,17 @@ ixgbe_flow_create(struct rte_eth_dev *dev,TAILQ_INSERT_TAIL (&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries); -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, - actions, &ntuple_filter, error); - -/* ESP flow not really a flow*/ -if (ntuple_filter.proto ==IPPROTO_ESP ) +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret)return flow; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);if (!ret) {
@@ -3297,6 +3336,13 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf rss_conf;int ret; +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) +return 0 ; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error);
Signature · 1 line
2.47.3
PATCH v2 4/26 net/i40e: get rid of global filter variables
In reply to Anatoly BurakovCurrently, i40e driver relies on global state to work around the fact that rte_flow_validate() is being called directly from rte_flow_create(), and it not being possible to pass state between two functions. Fix that by making a small wrapper around validation that will create a dummy context.
Additionally, tunnel filter doesn't appear to be used by anything and so is omitted from the structure.
--- drivers/net/intel/i40e/i40e_ethdev.h | 16 ++-- drivers/net/intel/i40e/i40e_flow.c | 117 ++++++++++++++------------- 2 files changed, 68 insertions(+), 65 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +9 -7
@@ -1304,12 +1304,14 @@ struct i40e_vf_representor {extern const struct rte_flow_ops i40e_flow_ops; -union i40e_filter_t { -struct rte_eth_ethertype_filter ethertype_filter; -struct i40e_fdir_filter_conf fdir_filter; -struct rte_eth_tunnel_filter_conf tunnel_filter; -struct i40e_tunnel_filter_conf consistent_tunnel_filter; -struct i40e_rte_flow_rss_conf rss_conf; +struct i40e_filter_ctx { +union { +struct rte_eth_ethertype_filter ethertype_filter; +struct i40e_fdir_filter_conf fdir_filter; +struct i40e_tunnel_filter_conf consistent_tunnel_filter; +struct i40e_rte_flow_rss_conf rss_conf; + }; +enum rte_filter_type type; }; typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -1317,7 +1319,7 @@ typedef int (*parse_filter_t)(struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error, - union i40e_filter_t *filter); + struct i40e_filter_ctx *filter);struct i40e_valid_pattern {enum rte_flow_item_type *items;parse_filter_t parse_filter;
drivers/net/intel/i40e/i40e_flow.c +59 -58
351 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 5/26 net/i40e: make default RSS key global
In reply to Anatoly BurakovCurrently, there are multiple places where we need a default RSS key, but in each of those places we define it as a local variable. Make it global constant, and adjust all callers to use the global constant. When dealing with adminq, we cannot send down the constant because adminq commands do not guarantee const-ness, so copy RSS key into a local buffer before sending it down to hardware.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 ++++++++++------------ drivers/net/intel/i40e/i40e_hash.c | 23 +++++++++++++++++------ drivers/net/intel/i40e/i40e_hash.h | 3 +++ 3 files changed, 30 insertions(+), 18 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +10 -12
@@ -9082,23 +9082,21 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)int i40e_pf_reset_rss_key (struct i40e_pf *pf) { -const uint8_t key_len = (I40E_PFQF_HKEY_MAX_INDEX +1 ) * -sizeof (uint32_t ); -uint8_t *rss_key; +uint8_t key_buf[I40E_RSS_KEY_LEN ]; +const uint8_t *rss_key;/* Reset key */ rss_key = pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key; -if (!rss_key || - pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len < key_len) { -static uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; +if (!rss_key || pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len <sizeof (key_buf)) + rss_key = i40e_rss_key_default; - rss_key = (uint8_t *)rss_key_default; - } +/* +* adminq does not guarantee const-ness of RSS key once a command is sent down, so make a +* local copy. +*/ +memcpy (&key_buf, rss_key,sizeof (key_buf)); -return i40e_set_rss_key (pf->main_vsi, rss_key, key_len); +return i40e_set_rss_key (pf->main_vsi, key_buf,sizeof (key_buf)); } static int
drivers/net/intel/i40e/i40e_hash.c +17 -6
@@ -233,6 +233,22 @@ struct i40e_hash_match_pattern { RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) +const uint8_t i40e_rss_key_default[] = { +0x44 ,0x39 ,0x79 ,0x6b , +0xb5 ,0x4c ,0x50 ,0x23 , +0xb6 ,0x75 ,0xea ,0x5b , +0x12 ,0x4f ,0x9f ,0x30 , +0xb8 ,0xa2 ,0xc0 ,0x3d , +0xdf ,0xdc ,0x4d ,0x02 , +0xa0 ,0x8c ,0x9b ,0x33 , +0x4a ,0xf6 ,0x4a ,0x4c , +0x05 ,0xc6 ,0xfa ,0x34 , +0x39 ,0x58 ,0xd8 ,0x55 , +0x7d ,0x99 ,0x58 ,0x3a , +0xe1 ,0x38 ,0xc9 ,0x2e , +0x81 ,0x15 ,0x03 ,0x66 +}; +/* Current supported patterns and RSS types. * All items that have the same pattern types are together. */
@@ -910,17 +926,12 @@ i40e_hash_parse_key(const struct rte_flow_action_rss *rss_act,const uint8_t *key = rss_act->key;if (!key || rss_act->key_len !=sizeof (rss_conf->key)) { -const uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; -if (rss_act->key_len !=sizeof (rss_conf->key))PMD_DRV_LOG (WARNING ,"RSS key length invalid, must be %u bytes, now set key to default" , (uint32_t )sizeof (rss_conf->key)); -memcpy (rss_conf->key, rss_key_default,sizeof (rss_conf->key)); +memcpy (rss_conf->key, i40e_rss_key_default,sizeof (rss_conf->key)); }else {memcpy (rss_conf->key, key,sizeof (rss_conf->key)); }
drivers/net/intel/i40e/i40e_hash.h +3 -0
@@ -27,6 +27,9 @@ int i40e_hash_filter_destroy(struct i40e_pf *pf, const struct i40e_rss_filter *rss_filter);int i40e_hash_filter_flush (struct i40e_pf *pf); +#define I40E_RSS_KEY_LEN ((I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) +extern const uint8_t i40e_rss_key_default[I40E_RSS_KEY_LEN ]; + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH v2 6/26 net/i40e: use unsigned types for queue comparisons
In reply to Anatoly BurakovCurrently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare I40E_MAX_Q_PER_TC to an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence, i40e_align_floor now returns unsigned value as well - this is correct, because nothing about that function implies signed usage being a valid use case.
--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +1 -1
@@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
drivers/net/intel/i40e/i40e_ethdev.h +3 -3
@@ -24,7 +24,7 @@#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ -#define I40E_MAX_Q_PER_TC 64 +#define I40E_MAX_Q_PER_TC 64U#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw) hw->aq.asq_buf_size =I40E_AQ_BUF_SZ ; } -static inline int -i40e_align_floor (int n) +static inline uint32_t +i40e_align_floor (uint32_t n) {if (n ==0 )return 0 ;
drivers/net/intel/i40e/i40e_hash.c +2 -2
@@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev,struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue; hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); if (!rss_act->queue_num ||
@@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, max_queue =RTE_MIN (max_queue,I40E_MAX_Q_PER_TC );for (i =0 ; i < rss_act->queue_num; i++) { -if ((int )rss_act->queue[i] >= max_queue) +if (rss_act->queue[i] >= max_queue)break ; }
Signature · 1 line
2.47.3
PATCH v2 7/26 net/i40e: use proper flex len define
In reply to Anatoly BurakovFor FDIR, we have byte arrays that are supposed to be limited to whatever the HW supports in terms of flex descriptor matching. However, in the structure definition, spec and mask bytes are using different array length defines, and the only reason why this works is because they evaluate to the same value.
Use the i40e-specific definition instead.
--- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -631,7 +631,7 @@ struct i40e_fdir_flex_pit {/* A structure used to contain extend input of flow */ struct i40e_fdir_flow_ext {uint16_t vlan_tci; -uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN ]; +uint8_t flexbytes[I40E_FDIR_MAX_FLEX_LEN ];/* It is filled by the flexible payload to match. */ uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN ];uint8_t raw_id;
Signature · 1 line
2.47.3
PATCH v2 8/26 net/i40e: remove global pattern variable
In reply to Anatoly BurakovWhen parsing flow patterns, current code cleans up the pattern list by removing void flow items, and copies the patterns into an array. That array, when dealing with under 32 flow items, is allocated on the stack, but when the pattern is big enough, a new list is dynamically allocated. This allocated list is a global variable, and is allocated using rte_zmalloc call which seems like overkill for this use case.
Remove the global variable, and replace the split behavior with unconditional allocation.
--- drivers/net/intel/i40e/i40e_flow.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +9 -20
@@ -145,9 +145,6 @@ const struct rte_flow_ops i40e_flow_ops = { .query = i40e_flow_query, }; -/* internal pattern w/o VOID items */ -struct rte_flow_item g_items[32 ]; -/* Pattern matched ethertype filter */ static enum rte_flow_item_type pattern_ethertype[] = {RTE_FLOW_ITEM_TYPE_ETH ,
@@ -3837,19 +3834,13 @@ i40e_flow_check(struct rte_eth_dev *dev, i++; } item_num++; - -if (item_num <=ARRAY_SIZE (g_items)) { - items = g_items; - }else { - items =rte_zmalloc ("i40e_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); -if (!items) { -rte_flow_error_set (error,ENOMEM , -RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL , -"No memory for PMD internal items." ); -return -ENOMEM ; - } + items =calloc (item_num,sizeof (struct rte_flow_item )); +if (items ==NULL ) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL , +"No memory for PMD internal items." ); +return -ENOMEM ; }i40e_pattern_skip_void_item (items, pattern);
@@ -3862,8 +3853,7 @@ i40e_flow_check(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ITEM , pattern, "Unsupported pattern"); -if (items != g_items) -rte_free (items); +free (items);return -rte_errno; }
@@ -3873,8 +3863,7 @@ i40e_flow_check(struct rte_eth_dev *dev, flag = true; }while ((ret <0 ) && (i <RTE_DIM (i40e_supported_patterns))); -if (items != g_items) -rte_free (items); +free (items);return ret; }
Signature · 1 line
2.47.3
PATCH v2 9/26 net/i40e: avoid rte malloc in tunnel set
In reply to Anatoly BurakovCurrently, when setting tunnel configuration, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++--------------- 1 file changed, 53 insertions(+), 71 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +53 -71
@@ -8511,38 +8511,27 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,struct i40e_pf_vf *vf =NULL ;struct i40e_hw *hw =I40E_PF_TO_HW (pf);struct i40e_vsi *vsi; -struct i40e_aqc_cloud_filters_element_bb *cld_filter; -struct i40e_aqc_cloud_filters_element_bb *pfilter; +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 };struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -struct i40e_tunnel_filter *tunnel, *node; +struct i40e_tunnel_filter *node;struct i40e_tunnel_filter check_filter;/* Check if filter exists */ uint32_t teid_le;bool big_buffer =0 ; - cld_filter =rte_zmalloc ("tunnel_filter" , -sizeof (struct i40e_aqc_add_rm_cloud_filt_elem_ext ), -0 ); - -if (cld_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - pfilter = cld_filter; -rte_ether_addr_copy (&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&pfilter->element.outer_mac); + (struct rte_ether_addr *)&cld_filter.element.outer_mac);rte_ether_addr_copy (&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&pfilter->element.inner_mac); + (struct rte_ether_addr *)&cld_filter.element.inner_mac); - pfilter->element.inner_vlan = + cld_filter.element.inner_vlan =rte_cpu_to_le_16 (tunnel_filter->inner_vlan);if (tunnel_filter->ip_type ==I40E_TUNNEL_IPTYPE_IPV4 ) { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV4 ; ipv4_addr =rte_be_to_cpu_32 (tunnel_filter->ip_addr.ipv4_addr); ipv4_addr_le =rte_cpu_to_le_32 (ipv4_addr); -rte_memcpy (&pfilter->element.ipaddr.v4.data, +rte_memcpy (&cld_filter.element.ipaddr.v4.data, &ipv4_addr_le, -sizeof (pfilter->element.ipaddr.v4.data)); +sizeof (cld_filter.element.ipaddr.v4.data)); }else { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ;for (i =0 ; i <4 ; i++) {
@@ -8550,9 +8539,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,rte_cpu_to_le_32 (rte_be_to_cpu_32 ( tunnel_filter->ip_addr.ipv6_addr[i])); } -rte_memcpy (&pfilter->element.ipaddr.v6.data, +rte_memcpy (&cld_filter.element.ipaddr.v6.data, &convert_ipv6, -sizeof (pfilter->element.ipaddr.v6.data)); +sizeof (cld_filter.element.ipaddr.v6.data)); }/* check tunneled type */
@@ -8573,11 +8562,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x40 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP ;
@@ -8589,11 +8578,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x0 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE ;
@@ -8605,11 +8594,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8620,11 +8609,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8641,8 +8630,8 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,* Big Buffer should be set, see changes in * i40e_aq_add_cloud_filters */ - pfilter->general_fields[0 ] = tunnel_filter->inner_vlan; - pfilter->general_fields[1 ] = tunnel_filter->outer_vlan; + cld_filter.general_fields[0 ] = tunnel_filter->inner_vlan; + cld_filter.general_fields[1 ] = tunnel_filter->outer_vlan; big_buffer =1 ;break ;case I40E_CLOUD_TYPE_UDP :
@@ -8657,20 +8646,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->sport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }else {
@@ -8682,20 +8671,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->dport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }
@@ -8704,48 +8693,46 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,default :/* Other tunnel types is not supported. */ PMD_DRV_LOG (ERR ,"tunnel type is not supported." ); -rte_free (cld_filter);return -EINVAL ; }if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPC ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPU ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_QINQ ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_SCTP ) {if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ; }else { val =i40e_dev_get_filter_type (tunnel_filter->filter_type, - &pfilter->element.flags); + &cld_filter.element.flags);if (val <0 ) { -rte_free (cld_filter);return -EINVAL ; } } - pfilter->element.flags |=rte_cpu_to_le_16 ( -I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | - ip_type | (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); - pfilter->element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->element.queue_number = + cld_filter.element.flags |= +rte_cpu_to_le_16 (I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type | + (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); + cld_filter.element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); + cld_filter.element.queue_number =rte_cpu_to_le_16 (tunnel_filter->queue_id);if (!tunnel_filter->is_to_vf)
@@ -8753,7 +8740,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,else {if (tunnel_filter->vf_id >= pf->vf_num) {PMD_DRV_LOG (ERR ,"Invalid argument." ); -rte_free (cld_filter);return -EINVAL ; } vf = &pf->vfs[tunnel_filter->vf_id];
@@ -8762,38 +8748,36 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,/* Check if there is the filter in SW list */ memset (&check_filter,0 ,sizeof (check_filter)); -i40e_tunnel_filter_convert (cld_filter, &check_filter); +i40e_tunnel_filter_convert (&cld_filter, &check_filter); check_filter.is_to_vf = tunnel_filter->is_to_vf; check_filter.vf_id = tunnel_filter->vf_id; node =i40e_sw_tunnel_filter_lookup (tunnel_rule, &check_filter.input);if (add && node) {PMD_DRV_LOG (ERR ,"Conflict with existing tunnel rules!" ); -rte_free (cld_filter);return -EINVAL ; }if (!add && !node) {PMD_DRV_LOG (ERR ,"There's no corresponding tunnel filter!" ); -rte_free (cld_filter);return -EINVAL ; }if (add) { +struct i40e_tunnel_filter *tunnel; +if (big_buffer) ret =i40e_aq_add_cloud_filters_bb (hw, - vsi->seid, cld_filter,1 ); + vsi->seid, &cld_filter,1 );else ret =i40e_aq_add_cloud_filters (hw, - vsi->seid, &cld_filter->element,1 ); + vsi->seid, &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to add a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } tunnel =rte_zmalloc ("tunnel_filter" ,sizeof (*tunnel),0 );if (tunnel ==NULL ) {PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -rte_free (cld_filter);return -ENOMEM ; }
@@ -8804,19 +8788,17 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, }else {if (big_buffer) ret =i40e_aq_rem_cloud_filters_bb ( - hw, vsi->seid, cld_filter,1 ); + hw, vsi->seid, &cld_filter,1 );else ret =i40e_aq_rem_cloud_filters (hw, vsi->seid, - &cld_filter->element,1 ); + &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to delete a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } ret =i40e_sw_tunnel_filter_del (pf, &node->input); } -rte_free (cld_filter);return ret; }
Signature · 1 line
2.47.3
PATCH v2 10/26 net/i40e: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +4 -4
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4649,7 +4649,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev, pf->adapter->rss_reta_updated =1 ; out: -rte_free (lut); +free (lut);return ret; }
@@ -4673,7 +4673,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4690,7 +4690,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v2 11/26 net/i40e: avoid rte malloc in MAC/VLAN filtering
In reply to Anatoly BurakovCurrently, when adding, removing, or configuring MAC and VLAN filters, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 38 +++++++++++++-------------- drivers/net/intel/i40e/rte_pmd_i40e.c | 16 +++++------ 2 files changed, 26 insertions(+), 28 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +18 -20
@@ -4165,8 +4165,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { i =0 ; num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -4206,7 +4205,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (ret)PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); } -rte_free (mac_filter); +free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -6231,8 +6230,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -6264,7 +6262,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) } DONE: -rte_free (mac_filter); +free (mac_filter);return ret; }
@@ -7154,7 +7152,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_add" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7207,7 +7205,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7230,7 +7228,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_remove" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7286,7 +7284,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7455,7 +7453,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)else num = vsi->mac_num * vsi->vlan_num; - mv_f =rte_zmalloc ("macvlan_data" , num *sizeof (*mv_f),0 ); + mv_f =calloc (num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7484,7 +7482,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi) ret =i40e_remove_macvlan_filters (vsi, mv_f, num); DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7510,7 +7508,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7532,7 +7530,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num++; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7561,7 +7559,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7594,7 +7592,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num--; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7626,7 +7624,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) mac_filter->filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7665,7 +7663,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7696,7 +7694,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7725,7 +7723,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
drivers/net/intel/i40e/rte_pmd_i40e.c +8 -8
@@ -233,7 +233,7 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -250,18 +250,18 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_remove_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
@@ -294,7 +294,7 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) f->mac_info.filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -312,18 +312,18 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_add_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
Signature · 1 line
2.47.3
PATCH v2 12/26 net/i40e: avoid rte malloc in VF resource queries
In reply to Anatoly BurakovCurrently, when responding to VF resource queries, we are dynamically allocating a temporary buffer with rte_zmalloc followed by an immediate rte_free. This is not needed as the response is only used temporarily, so replace it with a stack-allocated structure (the allocation is fixed in size and pretty small).
--- drivers/net/intel/i40e/i40e_pf.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/net/intel/i40e/i40e_pf.c +7 -19
@@ -309,9 +309,14 @@ static int i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg, bool b_op) { - struct virtchnl_vf_resource *vf_res = NULL; +/* only have 1 VSI by default */ +struct { +struct virtchnl_vf_resource vf_res; +struct virtchnl_vsi_resource vsi_res; + } res = {0 }; +struct virtchnl_vf_resource *vf_res = &res.vf_res; +uint32_t len =sizeof (res);struct i40e_hw *hw =I40E_PF_TO_HW (vf->pf); -uint32_t len =0 ;uint64_t default_hena =I40E_RSS_HENA_ALL ;int ret =I40E_SUCCESS ;
@@ -322,20 +327,6 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,return ret; } -/* only have 1 VSI by default */ - len =sizeof (struct virtchnl_vf_resource ) + -I40E_DEFAULT_VF_VSI_NUM * -sizeof (struct virtchnl_vsi_resource ); - - vf_res =rte_zmalloc ("i40e_vf_res" , len,0 ); -if (vf_res ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate mem" ); - ret =I40E_ERR_NO_MEMORY ; - vf_res =NULL ; - len =0 ; - goto send_msg; - } -if (VF_IS_V10 (&vf->version))/* doesn't support offload negotiate */ vf->request_caps =VIRTCHNL_VF_OFFLOAD_L2 |VIRTCHNL_VF_OFFLOAD_VLAN ;
@@ -377,11 +368,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,rte_ether_addr_copy (&vf->mac_addr, (struct rte_ether_addr *)vf_res->vsi_res[0 ].default_mac_addr); -send_msg:i40e_pf_host_send_msg_to_vf (vf,VIRTCHNL_OP_GET_VF_RESOURCES , ret, (uint8_t *)vf_res, len); -rte_free (vf_res); -return ret; }
Signature · 1 line
2.47.3
PATCH v2 13/26 net/i40e: avoid rte malloc in adminq operations
In reply to Anatoly BurakovCurrently, when processing admin queue messages, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as the message buffer is only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +2 -2
@@ -6896,7 +6896,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)int ret; info.buf_len =I40E_AQ_BUF_SZ ; - info.msg_buf =rte_zmalloc ("msg_buffer" , info.buf_len,0 ); + info.msg_buf =calloc (1 , info.buf_len);if (!info.msg_buf) {PMD_DRV_LOG (ERR ,"Failed to allocate mem" );return ;
@@ -6936,7 +6936,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)break ; } } -rte_free (info.msg_buf); +free (info.msg_buf); } static void
Signature · 1 line
2.47.3
PATCH v2 14/26 net/i40e: avoid rte malloc in DDP package handling
In reply to Anatoly BurakovCurrently, when processing Dynamic Driver Profile (DDP) packages and checking profile information, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily, so replace it with stack-allocated structures or regular malloc/free where appropriate.
--- drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++++++------------------ 1 file changed, 14 insertions(+), 29 deletions(-)
drivers/net/intel/i40e/rte_pmd_i40e.c +14 -29
@@ -1569,9 +1569,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)PMD_DRV_LOG (INFO ,"Read-only profile." );return 0 ; } - buff =rte_zmalloc ("pinfo_list" , - (I40E_PROFILE_INFO_SIZE *I40E_MAX_PROFILE_NUM +4 ), -0 ); + buff =calloc (I40E_MAX_PROFILE_NUM +4 ,I40E_PROFILE_INFO_SIZE );if (!buff) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return -1 ;
@@ -1583,7 +1581,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) 0, NULL);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get profile info list." ); -rte_free (buff); +free (buff);return -1 ; } p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1591,20 +1589,20 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) p = &p_list->p_info[i];if (pinfo->track_id == p->track_id) {PMD_DRV_LOG (INFO ,"Profile exists." ); -rte_free (buff); +free (buff);return 1 ; } }/* profile with group id 0xff is compatible with any other profile */ if ((pinfo->track_id & group_mask) == group_mask) { -rte_free (buff); +free (buff);return 0 ; }for (i =0 ; i < p_list->p_count; i++) { p = &p_list->p_info[i];if ((p->track_id & group_mask) ==0 ) {PMD_DRV_LOG (INFO ,"Profile of the group 0 exists." ); -rte_free (buff); +free (buff);return 2 ; } }
@@ -1615,12 +1613,12 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)if ((pinfo->track_id & group_mask) != (p->track_id & group_mask)) {PMD_DRV_LOG (INFO ,"Profile of different group exists." ); -rte_free (buff); +free (buff);return 3 ; } } -rte_free (buff); +free (buff);return 0 ; }
@@ -1636,7 +1634,10 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,struct i40e_generic_seg_header *profile_seg_hdr;struct i40e_generic_seg_header *metadata_seg_hdr;uint32_t track_id; -uint8_t *profile_info_sec; +struct { +struct i40e_profile_section_header sec; +struct i40e_profile_info info; + } profile_info_sec = {0 };int is_exist;enum i40e_status_code status =I40E_SUCCESS ;static const uint32_t type_mask =0xff000000 ;
@@ -1701,26 +1702,15 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,return -EINVAL ; } - profile_info_sec =rte_zmalloc ( -"i40e_profile_info" , -sizeof (struct i40e_profile_section_header ) + -sizeof (struct i40e_profile_info ), -0 ); -if (!profile_info_sec) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -return -EINVAL ; - } -/* Check if the profile already loaded */ i40e_generate_profile_info_sec ( ((struct i40e_profile_segment *)profile_seg_hdr)->name, &((struct i40e_profile_segment *)profile_seg_hdr)->version, - track_id, profile_info_sec, + track_id, (uint8_t * )&profile_info_sec, op ==RTE_PMD_I40E_PKG_OP_WR_ADD ); - is_exist =i40e_check_profile_info (port, profile_info_sec); + is_exist =i40e_check_profile_info (port, (uint8_t * )&profile_info_sec);if (is_exist <0 ) {PMD_DRV_LOG (ERR ,"Failed to check profile." ); -rte_free (profile_info_sec);return -EINVAL ; }
@@ -1733,13 +1723,11 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,else if (is_exist ==3 )PMD_DRV_LOG (ERR ,"Profile of different group already exists" );i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return -EEXIST ; } }else if (op ==RTE_PMD_I40E_PKG_OP_WR_DEL ) {if (is_exist !=1 ) {PMD_DRV_LOG (ERR ,"Profile does not exist." ); -rte_free (profile_info_sec);return -EACCES ; } }
@@ -1751,7 +1739,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, track_id);if (status) {PMD_DRV_LOG (ERR ,"Failed to write profile for delete." ); -rte_free (profile_info_sec);return status; } }else {
@@ -1764,14 +1751,13 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,PMD_DRV_LOG (ERR ,"Failed to write profile for add." ); else PMD_DRV_LOG(ERR, "Failed to write profile."); -rte_free (profile_info_sec);return status; } }if (track_id && (op !=RTE_PMD_I40E_PKG_OP_WR_ONLY )) {/* Modify loaded profiles info list */ - status =i40e_add_rm_profile_info (hw, profile_info_sec); + status =i40e_add_rm_profile_info (hw, (uint8_t * )&profile_info_sec);if (status) {if (op ==RTE_PMD_I40E_PKG_OP_WR_ADD )PMD_DRV_LOG (ERR ,"Failed to add profile to info list." );
@@ -1784,7 +1770,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, op == RTE_PMD_I40E_PKG_OP_WR_DEL)i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return status; }
Signature · 1 line
2.47.3
PATCH v2 15/26 net/i40e: avoid rte malloc in DDP ptype handling
In reply to Anatoly BurakovCurrently, when updating customized protocol and packet type information via DDP packages, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +12 -13
@@ -11787,7 +11787,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = pctype_num *sizeof (struct rte_pmd_i40e_proto_info ); - pctype =rte_zmalloc ("new_pctype" , buff_size,0 ); + pctype =calloc (pctype_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!pctype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11798,7 +11798,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get pctype list" ); -rte_free (pctype); +free (pctype);return -1 ; }
@@ -11879,7 +11879,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype); +free (pctype);return 0 ; }
@@ -11925,7 +11925,7 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_info ); - ptype =rte_zmalloc ("new_ptype" , buff_size,0 ); + ptype =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_info ));if (!ptype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11937,15 +11937,14 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get ptype list" ); -rte_free (ptype); +free (ptype);return ret; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_mapping ); - ptype_mapping =rte_zmalloc ("ptype_mapping" , buff_size,0 ); + ptype_mapping =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_mapping ));if (!ptype_mapping) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -rte_free (ptype); +free (ptype);return -1 ; }
@@ -12083,8 +12082,8 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (ERR ,"Failed to update ptype mapping table." ); -rte_free (ptype_mapping); -rte_free (ptype); +free (ptype_mapping); +free (ptype);return ret; }
@@ -12119,7 +12118,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = proto_num *sizeof (struct rte_pmd_i40e_proto_info ); - proto =rte_zmalloc ("new_proto" , buff_size,0 ); + proto =calloc (proto_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!proto) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return ;
@@ -12131,7 +12130,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get protocol list" ); -rte_free (proto); +free (proto);return ; }
@@ -12169,7 +12168,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (INFO ,"No ptype is updated." ); -rte_free (proto); +free (proto); }/* Create a QinQ cloud filter
Signature · 1 line
2.47.3
PATCH v2 16/26 net/iavf: remove remnants of pipeline mode
In reply to Anatoly BurakovWhen pipeline mode was removed, some of the things used by pipelines were left in the code. Remove them as they are unused.
--- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 --------------- drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_ipsec_crypto.c | 1 - 5 files changed, 19 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +0 -1
@@ -1632,7 +1632,6 @@ static struct iavf_flow_parser iavf_fdir_parser = { .array = iavf_fdir_pattern, .array_len = RTE_DIM(iavf_fdir_pattern), .parse_pattern_action = iavf_fdir_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fdir_engine_register)
drivers/net/intel/iavf/iavf_fsub.c +0 -1
@@ -814,7 +814,6 @@ iavf_flow_parser iavf_fsub_parser = { .array = iavf_fsub_pattern_list, .array_len = RTE_DIM(iavf_fsub_pattern_list), .parse_pattern_action = iavf_fsub_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fsub_engine_init)
drivers/net/intel/iavf/iavf_generic_flow.h +0 -15
@@ -485,20 +485,6 @@ enum iavf_flow_engine_type { IAVF_FLOW_ENGINE_MAX, }; -/** -* classification stages. -* for non-pipeline mode, we have two classification stages: Distributor/RSS -* for pipeline-mode we have three classification stages: -* Permission/Distributor/RSS -*/ -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 , -}; -/* Struct to store engine created. */ struct iavf_flow_engine {TAILQ_ENTRY (iavf_flow_engine) node;
@@ -527,7 +513,6 @@ struct iavf_flow_parser {struct iavf_pattern_match_item *array;uint32_t array_len;parse_pattern_action_t parse_pattern_action; -enum iavf_flow_classification_stage stage; };/* Struct to store parser created. */
drivers/net/intel/iavf/iavf_hash.c +0 -1
@@ -691,7 +691,6 @@ static struct iavf_flow_parser iavf_hash_parser = { .array = iavf_hash_pattern_list, .array_len = RTE_DIM(iavf_hash_pattern_list), .parse_pattern_action = iavf_hash_parse_pattern_action, - .stage = IAVF_FLOW_STAGE_RSS, };int
drivers/net/intel/iavf/iavf_ipsec_crypto.c +0 -1
@@ -1983,7 +1983,6 @@ static struct iavf_flow_parser iavf_ipsec_flow_parser = { .array = iavf_ipsec_flow_pattern, .array_len = RTE_DIM(iavf_ipsec_flow_pattern), .parse_pattern_action = iavf_ipsec_flow_parse, - .stage = IAVF_FLOW_STAGE_IPSEC_CRYPTO, };RTE_INIT (iavf_ipsec_flow_engine_register)
Signature · 1 line
2.47.3
PATCH v2 17/26 net/iavf: do not use malloc in crypto VF commands
In reply to Anatoly BurakovCurrently, when calling down into the VF mailbox, IPsec code will use dynamic memory allocation (rte_malloc one at that!) to allocate VF message structures which are ~40 bytes in size, and then immediately frees them. This is wasteful and unnecessary, so use stack allocation instead.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 157 +++++++-------------- 1 file changed, 51 insertions(+), 106 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +51 -106
@@ -458,36 +458,24 @@ static uint32_t iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, struct rte_security_session_conf *conf) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -struct virtchnl_ipsec_sa_cfg *sa_cfg; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg sa_cfg; + } sa_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp; +struct inline_ipsec_msg *request = &sa_req.msg, *response = &sa_resp.msg; +struct virtchnl_ipsec_sa_cfg *sa_cfg = &sa_req.sa_cfg;int rc; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg ); - - request =rte_malloc ("iavf-sad-add-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg_resp ); - response =rte_malloc ("iavf-sad-add-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;/* set SA configuration params */ - sa_cfg = (struct virtchnl_ipsec_sa_cfg *)(request +1 ); - sa_cfg->spi = conf->ipsec.spi; sa_cfg->virtchnl_protocol_type =VIRTCHNL_PROTO_ESP ; sa_cfg->virtchnl_direction =
@@ -541,10 +529,10 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sa_req), + (uint8_t *)response,sizeof (sa_resp));if (rc) - goto update_cleanup; +return rc;/* verify response id */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -552,9 +540,6 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, rc = -EFAULT ; else rc = response->ipsec_data.sa_cfg_resp->sa_handle; -update_cleanup: -rte_free (response); -rte_free (request);return rc; }
@@ -722,19 +707,18 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, bool is_udp, uint16_t udp_port) { -struct inline_ipsec_msg *request =NULL , *response =NULL ; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg sp_cfg; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg; +struct inline_ipsec_msg *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg ); - request =rte_malloc ("iavf-inbound-security-policy-add-request" , - request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -768,21 +752,12 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, request->ipsec_data.sp_cfg->is_udp = is_udp; request->ipsec_data.sp_cfg->udp_port =htons (udp_port); - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg_resp ); - response =rte_malloc ("iavf-inbound-security-policy-add-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -791,10 +766,6 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,else rc = response->ipsec_data.sp_cfg_resp->rule_id; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -802,26 +773,17 @@ static uint32_t iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_update sa_update; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_update ); - request =rte_malloc ("iavf-sa-update-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sa-update-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_UPDATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -833,10 +795,10 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -845,10 +807,6 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,else rc = response->ipsec_data.ipsec_resp->resp; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -899,26 +857,17 @@ int iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter, uint8_t is_v4, uint32_t flow_id) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_destroy sp_destroy; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_destroy ); - request =rte_malloc ("iavf-sp-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sp-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -931,21 +880,17 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode || response->req_id != request->req_id) rc = -EFAULT ;else -return response->ipsec_data.ipsec_status->status; - -update_cleanup: -rte_free (request); -rte_free (response); + rc = response->ipsec_data.ipsec_status->status;return rc; }
Signature · 1 line
2.47.3
PATCH v2 18/26 net/iavf: decouple hash uninit from parser uninit
In reply to Anatoly BurakovCurrently, parser deinitialization will trigger removal of current RSS configuration. This should not be done as part of parser deinitialization, but should rather be a separate step in dev close flow.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++++ drivers/net/intel/iavf/iavf_hash.c | 13 +++++++++---- drivers/net/intel/iavf/iavf_hash.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
drivers/net/intel/iavf/iavf_ethdev.c +4 -0
@@ -35,6 +35,7 @@#include "iavf_generic_flow.h" #include "rte_pmd_iavf.h" #include "iavf_ipsec_crypto.h" +#include "iavf_hash.h" /* devargs */ #define IAVF_PROTO_XTR_ARG "proto_xtr"
@@ -2972,6 +2973,9 @@ iavf_dev_close(struct rte_eth_dev *dev)/* free iAVF security device context all related resources */ iavf_security_ctx_destroy (adapter); +/* remove RSS configuration */ +iavf_hash_uninit (adapter); +iavf_flow_flush (dev,NULL );iavf_flow_uninit (adapter);
drivers/net/intel/iavf/iavf_hash.c +9 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "iavf_hash.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -77,7 +78,7 @@ static int iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow, struct rte_flow_error *error);static void -iavf_hash_uninit (struct iavf_adapter *ad); +iavf_hash_uninit_parser (struct iavf_adapter *ad);static void iavf_hash_free (struct rte_flow *flow); static int
@@ -680,7 +681,7 @@ static struct iavf_flow_engine iavf_hash_engine = { .init = iavf_hash_init, .create = iavf_hash_create, .destroy = iavf_hash_destroy, - .uninit = iavf_hash_uninit, + .uninit = iavf_hash_uninit_parser, .free = iavf_hash_free, .type = IAVF_FLOW_ENGINE_HASH, };
@@ -1641,6 +1642,12 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad, }static void +iavf_hash_uninit_parser (struct iavf_adapter *ad) +{ +iavf_unregister_parser (&iavf_hash_parser, ad); +} + +void iavf_hash_uninit (struct iavf_adapter *ad) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);
@@ -1658,8 +1665,6 @@ iavf_hash_uninit(struct iavf_adapter *ad) rss_conf = &ad->dev_data->dev_conf.rx_adv_conf.rss_conf;if (iavf_rss_hash_set (ad, rss_conf->rss_hf, false))PMD_DRV_LOG (ERR ,"fail to delete default RSS" ); - -iavf_unregister_parser (&iavf_hash_parser, ad); } static void
drivers/net/intel/iavf/iavf_hash.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */
Signature · 1 line
2.47.3
PATCH v2 19/26 net/iavf: avoid rte malloc in RSS configuration
In reply to Anatoly BurakovCurrently, when configuring RSS (redirection table, lookup table, and hash key), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++-- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/iavf/iavf_ethdev.c +2 -2
@@ -1554,7 +1554,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1574,7 +1574,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =iavf_configure_rss_lut (adapter);if (ret)/* revert back */ rte_memcpy (vf->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1159,7 +1159,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_lut) + vf->vf_res->rss_lut_size -1 ; - rss_lut =rte_zmalloc ("rss_lut" , len,0 ); + rss_lut =calloc (1 , len);if (!rss_lut)return -ENOMEM ;
@@ -1178,7 +1178,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_LUT" ); -rte_free (rss_lut); +free (rss_lut);return err; }
@@ -1191,7 +1191,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_key) + vf->vf_res->rss_key_size -1 ; - rss_key =rte_zmalloc ("rss_key" , len,0 ); + rss_key =calloc (1 , len);if (!rss_key)return -ENOMEM ;
@@ -1210,7 +1210,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_KEY" ); -rte_free (rss_key); +free (rss_key);return err; }
Signature · 1 line
2.47.3
PATCH v2 20/26 net/iavf: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +2 -2
@@ -1402,7 +1402,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) } } - list =rte_zmalloc ("iavf_del_mac_buffer" , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return ;
@@ -1434,7 +1434,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list); begin = next_begin; }while (begin <IAVF_NUM_MACADDR_MAX ); }
Signature · 1 line
2.47.3
PATCH v2 21/26 net/iavf: avoid rte malloc in IPsec operations
In reply to Anatoly BurakovCurrently, when performing IPsec security association operations and retrieving device capabilities, we are using rte_malloc followed by immediate rte_free. This is not needed as these structures are only used temporarily, so replace it with stack-allocated structures for small fixed-size messages and regular malloc/free for variable-sized buffers.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 58 ++++++++-------------- 1 file changed, 21 insertions(+), 37 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +21 -37
@@ -3,6 +3,7 @@*/ #include <stdalign.h> +#include <stdlib.h> #include <rte_cryptodev.h> #include <rte_ethdev.h>
@@ -899,29 +900,18 @@ static uint32_t iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_destroy sa_destroy; + } req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } resp; +struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_destroy ); - - request =rte_malloc ("iavf-sa-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - - response =rte_malloc ("iavf-sa-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -939,10 +929,10 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (req), + (uint8_t *)response,sizeof (resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -957,10 +947,6 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, response->ipsec_data.ipsec_status->status) rc = -EFAULT ; -update_cleanup: -rte_free (response); -rte_free (request); -return rc; }
@@ -1113,7 +1099,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-capability-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1121,8 +1107,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-capability-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1148,8 +1133,8 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,memcpy (capability, response->ipsec_data.ipsec_cap,sizeof (*capability)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
@@ -1538,7 +1523,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-status-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1546,8 +1531,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-status-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1573,8 +1557,8 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,memcpy (status, response->ipsec_data.ipsec_status,sizeof (*status)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
Signature · 1 line
2.47.3
PATCH v2 22/26 net/iavf: avoid rte malloc in queue operations
In reply to Anatoly BurakovCurrently, when enabling, disabling, or switching queues, we are using rte_malloc followed by an immediate rte_free. This is not needed as these structures are not being stored anywhere, so replace them with stack allocation or malloc/free where appropriate.
--- drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++++----------------- 1 file changed, 26 insertions(+), 39 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +26 -39
@@ -1020,19 +1020,15 @@ int iavf_enable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1048,7 +1044,7 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_ENABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1056,7 +1052,6 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_ENABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1064,19 +1059,15 @@ int iavf_disable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1092,7 +1083,7 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1100,7 +1091,6 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1109,17 +1099,15 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid, bool rx, bool on) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =1 ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1138,7 +1126,7 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,else args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1146,7 +1134,6 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,PMD_DRV_LOG (ERR ,"Failed to execute command of %s" , on ?"OP_ENABLE_QUEUES_V2" :"OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1229,7 +1216,7 @@ iavf_configure_queues(struct iavf_adapter *adapter, size =sizeof (*vc_config) +sizeof (vc_config->qpair[0 ]) * num_queue_pairs; - vc_config =rte_zmalloc ("cfg_queue" , size,0 ); + vc_config =calloc (1 , size);if (!vc_config)return -ENOMEM ;
@@ -1292,7 +1279,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,PMD_DRV_LOG (ERR ,"Failed to execute command of" " VIRTCHNL_OP_CONFIG_VSI_QUEUES" ); -rte_free (vc_config); +free (vc_config);return err; }
Signature · 1 line
2.47.3
PATCH v2 23/26 net/iavf: avoid rte malloc in irq map config
In reply to Anatoly BurakovCurrently, when configuring IRQ maps, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1295,7 +1295,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter) len =sizeof (struct virtchnl_irq_map_info ) +sizeof (struct virtchnl_vector_map ) * vf->nb_msix; - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1319,7 +1319,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter)if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_CONFIG_IRQ_MAP" ); -rte_free (map_info); +free (map_info);return err; }
@@ -1337,7 +1337,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num, len =sizeof (struct virtchnl_queue_vector_maps ) +sizeof (struct virtchnl_queue_vector ) * (num -1 ); - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1360,7 +1360,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_MAP_QUEUE_VECTOR" ); -rte_free (map_info); +free (map_info);return err; }
Signature · 1 line
2.47.3
PATCH v2 24/26 net/ice: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_ethdev.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -1338,7 +1338,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1358,7 +1358,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =ice_dcf_configure_rss_lut (hw);if (ret)/* revert back */ rte_memcpy (hw->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/ice/ice_ethdev.c +4 -4
@@ -5583,7 +5583,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,/* It MUST use the current LUT size to get the RSS lookup table, * otherwise if will fail with -100 error code. */ - lut =rte_zmalloc (NULL ,RTE_MAX (reta_size, lut_size),0 ); + lut =calloc (1 ,RTE_MAX (reta_size, lut_size));if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5607,7 +5607,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
@@ -5632,7 +5632,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc (NULL , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5650,7 +5650,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v2 25/26 net/ice: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular calloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -936,7 +936,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw, len =sizeof (struct virtchnl_ether_addr_list ); len +=sizeof (struct virtchnl_ether_addr ) * mc_addrs_num; - list =rte_zmalloc (NULL , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return -ENOMEM ;
@@ -961,7 +961,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list);return err; }
Signature · 1 line
2.47.3
PATCH v2 26/26 net/ice: avoid rte malloc in raw pattern parsing
In reply to Anatoly BurakovCurrently, when parsing raw flow patterns, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_fdir_filter.c | 14 +++++++------- drivers/net/intel/ice/ice_hash.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +7 -7
@@ -1879,13 +1879,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, pkt_len)return -rte_errno; - tmp_spec =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_spec =calloc (1 , pkt_len /2 );if (!tmp_spec)return -rte_errno; - tmp_mask =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_mask =calloc (1 , pkt_len /2 );if (!tmp_mask) { -rte_free (tmp_spec); +free (tmp_spec);return -rte_errno; }
@@ -1950,13 +1950,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, filter->parser_ena = true; -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);break ; raw_error: -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);return ret_val; }
drivers/net/intel/ice/ice_hash.c +5 -5
@@ -676,13 +676,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, pkt_len = spec_len /2 ; - pkt_buf =rte_zmalloc (NULL , pkt_len,0 ); + pkt_buf =calloc (1 , pkt_len);if (!pkt_buf)return -ENOMEM ; - msk_buf =rte_zmalloc (NULL , pkt_len,0 ); + msk_buf =calloc (1 , pkt_len);if (!msk_buf) { -rte_free (pkt_buf); +free (pkt_buf);return -ENOMEM ; }
@@ -733,8 +733,8 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,rte_memcpy (&meta->raw.prof, &prof,sizeof (prof)); free_mem: -rte_free (pkt_buf); -rte_free (msk_buf); +free (pkt_buf); +free (msk_buf);return ret; }
Signature · 1 line
2.47.3
PATCH v2 2/26 net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovThe security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 ------ drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 --- drivers/net/intel/ixgbe/ixgbe_flow.c | 6 ----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 -------------------- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 -- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 ----- 6 files changed, 52 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0 -8
@@ -32,9 +32,7 @@#include <rte_random.h> #include <dev_driver.h> #include <rte_hash_crc.h> -#ifdef RTE_LIB_SECURITY #include <rte_security_driver.h> -#endif #include <rte_os_shim.h> #include "ixgbe_logs.h"
@@ -1177,11 +1175,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)/* Unlock any pending hardware semaphore */ ixgbe_swfw_lock_reset (hw); -#ifdef RTE_LIB_SECURITY /* Initialize security_ctx only for primary process*/ if (ixgbe_ipsec_ctx_create (eth_dev))return -ENOMEM ; -#endif /* Initialize DCB configuration*/ memset (dcb_config,0 ,sizeof (struct ixgbe_dcb_config ));
@@ -1362,10 +1358,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; err_exit: -#ifdef RTE_LIB_SECURITY rte_free (eth_dev->security_ctx); eth_dev->security_ctx =NULL ; -#endif return ret; }
@@ -3148,10 +3142,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* Remove all Traffic Manager configuration */ ixgbe_tm_conf_uninit (dev); -#ifdef RTE_LIB_SECURITY rte_free (dev->security_ctx); dev->security_ctx =NULL ; -#endif return ret; }
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -4
@@ -14,9 +14,7 @@#include "base/ixgbe_dcb_82599.h" #include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" -#ifdef RTE_LIB_SECURITY #include "ixgbe_ipsec.h" -#endif #include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h>
@@ -478,9 +476,7 @@ struct ixgbe_adapter {struct ixgbe_filter_info filter;struct ixgbe_l2_tn_info l2_tn;struct ixgbe_bw_conf bw_conf; -#ifdef RTE_LIB_SECURITY struct ixgbe_ipsec ipsec; -#endif bool rx_bulk_alloc_allowed;bool rx_vec_allowed;struct rte_timecounter systime_tc;
drivers/net/intel/ixgbe/ixgbe_flow.c +0 -6
@@ -214,7 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -#ifdef RTE_LIB_SECURITY /** * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY */
@@ -249,7 +248,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); } -#endif /* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -630,11 +628,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (filter->proto ==IPPROTO_ESP )return 0 ; -#endif /* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {
@@ -3074,11 +3070,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev, ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error); -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (ntuple_filter.proto ==IPPROTO_ESP )return flow; -#endif if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -26
@@ -459,7 +459,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, seqnum_seed |= tx_offload.l2_len <<IXGBE_ADVTXD_TUNNEL_LEN ; } -#ifdef RTE_LIB_SECURITY if (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ) {union ixgbe_crypto_tx_desc_md *md = (union ixgbe_crypto_tx_desc_md *)mdata;
@@ -473,7 +472,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, tx_offload_mask.sa_idx |= ~0 ; tx_offload_mask.sec_pad_len |= ~0 ; } -#endif txq->ctx_cache[ctx_idx].flags = ol_flags; txq->ctx_cache[ctx_idx].tx_offload.data[0] =
@@ -652,9 +650,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint32_t ctx =0 ;uint32_t new_ctx;union ixgbe_tx_offload tx_offload; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec; -#endif tx_offload.data[0 ] =0 ; tx_offload.data[1 ] =0 ;
@@ -682,9 +678,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,* are needed for offload functionality. */ ol_flags = tx_pkt->ol_flags; -#ifdef RTE_LIB_SECURITY use_ipsec = txq->using_ipsec && (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ); -#endif /* If hardware offload required */ tx_ol_req = ol_flags &IXGBE_TX_OFFLOAD_MASK ;
@@ -696,7 +690,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.tso_segsz = tx_pkt->tso_segsz; tx_offload.outer_l2_len = tx_pkt->outer_l2_len; tx_offload.outer_l3_len = tx_pkt->outer_l3_len; -#ifdef RTE_LIB_SECURITY if (use_ipsec) {union ixgbe_crypto_tx_desc_md *ipsec_mdata = (union ixgbe_crypto_tx_desc_md *)
@@ -704,7 +697,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.sa_idx = ipsec_mdata->sa_idx; tx_offload.sec_pad_len = ipsec_mdata->pad_len; } -#endif /* If new context need be built or reuse the exist ctx. */ ctx = what_advctx_update(txq, tx_ol_req,
@@ -896,10 +888,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, olinfo_status |= ctx <<IXGBE_ADVTXD_IDX_SHIFT ; } olinfo_status |= (pkt_len <<IXGBE_ADVTXD_PAYLEN_SHIFT ); -#ifdef RTE_LIB_SECURITY if (use_ipsec) olinfo_status |=IXGBE_ADVTXD_POPTS_IPSEC ; -#endif m_seg = tx_pkt; do {
@@ -1523,13 +1513,11 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status, uint16_t pkt_info, pkt_flags |=RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD ; } -#ifdef RTE_LIB_SECURITY if (rx_status &IXGBE_RXD_STAT_SECP ) { pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD ;if (rx_status &IXGBE_RXDADV_LNKSEC_ERROR_BAD_SIG ) pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED ; } -#endif return pkt_flags; }
@@ -2490,9 +2478,7 @@ ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) {struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;if (txq->offloads ==0 && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST ) { if (txq->tx_rs_thresh <= IXGBE_TX_MAX_FREE_BUF_SZ && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
@@ -2648,9 +2634,7 @@ ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ci_tx_queue *txq) {/* Use a simple Tx queue (no offloads, no multi segs) if possible */ if ((txq->offloads ==0 ) && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif (txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST )) {PMD_INIT_LOG (DEBUG ,"Using simple tx code path" ); dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
@@ -2711,10 +2695,8 @@ ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_SECURITY ; -#endif return tx_offload_capa; }
@@ -2884,10 +2866,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; -#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY ); -#endif /* * Modification to set VFTDT for virtual function if vf is detected
@@ -3171,10 +3151,8 @@ ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) offloads |=RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; -#endif return offloads; }
@@ -5102,10 +5080,8 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)struct ci_rx_queue *rxq = dev->data->rx_queues[i]; rxq->vector_rx = rx_using_sse; -#ifdef RTE_LIB_SECURITY rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ); -#endif } }
@@ -5611,7 +5587,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)ixgbe_setup_loopback_link_x540_x550 (hw, true); } -#ifdef RTE_LIB_SECURITY if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) || (dev->data->dev_conf.txmode.offloads &
@@ -5624,7 +5599,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)return ret; } } -#endif return 0 ; }
drivers/net/intel/ixgbe/ixgbe_rxtx.h +0 -2
@@ -99,11 +99,9 @@ union ixgbe_tx_offload {/* fields for TX offloading of tunnels */ uint64_t outer_l3_len:8; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:8; /**< Outer L2 (MAC) Hdr Length. */ -#ifdef RTE_LIB_SECURITY /* inline ipsec related*/ uint64_t sa_idx:8; /**< TX SA database entry index */ uint64_t sec_pad_len:4; /**< padding length */ -#endif }; };
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c +0 -6
@@ -21,7 +21,6 @@ ixgbe_rxq_rearm(struct ci_rx_queue *rxq)ci_rxq_rearm (rxq,CI_RX_VEC_LEVEL_SSE ); } -#ifdef RTE_LIB_SECURITY static inline void desc_to_olflags_v_ipsec (__m128i descs[4 ],struct rte_mbuf **rx_pkts) {
@@ -56,7 +55,6 @@ desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts) *rearm2 =_mm_extract_epi32 (rearm,2 ); *rearm3 =_mm_extract_epi32 (rearm,3 ); } -#endif static inline void desc_to_olflags_v(__m128i descs[4], __m128i mbuf_init, uint8_t vlan_flags,
@@ -265,9 +263,7 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,volatile union ixgbe_adv_rx_desc *rxdp;struct ci_rx_entry *sw_ring;uint16_t nb_pkts_recd; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec = rxq->using_ipsec; -#endif int pos;uint64_t var;__m128i shuf_msk;
@@ -444,10 +440,8 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,desc_to_olflags_v (descs, mbuf_init, vlan_flags, udp_p_flag, &rx_pkts[pos]); -#ifdef RTE_LIB_SECURITY if (unlikely (use_ipsec))desc_to_olflags_v_ipsec (descs, &rx_pkts[pos]); -#endif /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */ pkt_mb4 =_mm_add_epi16 (pkt_mb4, crc_adjust);
Signature · 1 line
2.47.3
v3 cover Cleanups for ixgbe, i40e, iavf, and ice PMD's
In reply to Anatoly BurakovThis patchset is an assortment of cleanups for ixgbe, i40e, iavf, and ice PMD.
IXGBE:
- Remove unnecessary macros and #ifdef's
- Disentangle unrelated flow API code paths
I40E:
- Get rid of global variables and unnecessary allocations
- Reduce code duplication around default RSS keys
- Use more appropriate integer types and definitions
IAVF:
- Remove dead code
- Remove unnecessary allocations
- Separate RSS uninit from hash flow parser uninit
ICE:
- Remove unnecessary allocations
This is done in preparation for further rework.
Note that this patchset depends on driver bug fix patchset [1].
[1] https://patches.dpdk.org/project/dpdk/list/?series=37333
v1 -> v2:
- Added more cleanups around rte_malloc usage
v2 -> v3:
- Reworded some commit messages
- Added a new patch for ICE
- Rebased on latest bug fix patches
Anatoly Burakov (27):
net/ixgbe: remove MAC type check macros net/ixgbe: remove security-related ifdefery net/ixgbe: split security and ntuple filters net/i40e: get rid of global filter variables net/i40e: make default RSS key global net/i40e: use unsigned types for queue comparisons net/i40e: use proper flex len define net/i40e: remove global pattern variable net/i40e: avoid rte malloc in tunnel set net/i40e: avoid rte malloc in RSS RETA operations net/i40e: avoid rte malloc in MAC/VLAN filtering net/i40e: avoid rte malloc in VF resource queries net/i40e: avoid rte malloc in adminq operations net/i40e: avoid rte malloc in DDP package handling net/i40e: avoid rte malloc in DDP ptype handling net/iavf: remove remnants of pipeline mode net/iavf: avoid rte malloc in VF mailbox for IPsec net/iavf: decouple hash uninit from parser uninit net/iavf: avoid rte malloc in RSS configuration net/iavf: avoid rte malloc in MAC address operations net/iavf: avoid rte malloc in IPsec operations net/iavf: avoid rte malloc in queue operations net/iavf: avoid rte malloc in irq map config net/ice: avoid rte malloc in RSS RETA operations net/ice: avoid rte malloc in MAC address operations net/ice: avoid rte malloc in raw pattern parsing net/ice: avoid rte malloc in flow pattern match
drivers/net/intel/i40e/i40e_ethdev.c | 223 +++++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 24 +- drivers/net/intel/i40e/i40e_flow.c | 146 ++++++------ drivers/net/intel/i40e/i40e_hash.c | 27 ++- drivers/net/intel/i40e/i40e_hash.h | 3 + drivers/net/intel/i40e/i40e_pf.c | 26 +-- drivers/net/intel/i40e/rte_pmd_i40e.c | 59 ++--- drivers/net/intel/iavf/iavf_ethdev.c | 8 +- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 -- drivers/net/intel/iavf/iavf_hash.c | 14 +- drivers/net/intel/iavf/iavf_hash.h | 13 ++ drivers/net/intel/iavf/iavf_ipsec_crypto.c | 216 ++++++------------ drivers/net/intel/iavf/iavf_vchnl.c | 85 +++---- drivers/net/intel/ice/ice_acl_filter.c | 3 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 8 +- drivers/net/intel/ice/ice_ethdev.c | 8 +- drivers/net/intel/ice/ice_fdir_filter.c | 19 +- drivers/net/intel/ice/ice_generic_flow.c | 15 +- drivers/net/intel/ice/ice_hash.c | 13 +- drivers/net/intel/ice/ice_switch_filter.c | 5 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 - drivers/net/intel/ixgbe/ixgbe_ethdev.h | 16 -- drivers/net/intel/ixgbe/ixgbe_flow.c | 162 +++++++++----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 --- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 - drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 - 28 files changed, 513 insertions(+), 639 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
Signature · 1 line
2.47.3
PATCH v3 1/27 net/ixgbe: remove MAC type check macros
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -12
@@ -137,18 +137,6 @@#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)#define IXGBE_MAX_L2_TN_FILTER_NUM 128 -#define MAC_TYPE_FILTER_SUP_EXT (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\ - return -ENOTSUP;\ -} while (0) - -#define MAC_TYPE_FILTER_SUP (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\ - (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\ - (type) != ixgbe_mac_X550EM_a && (type) != ixgbe_mac_E610)\ - return -ENOTSUP;\ -} while (0) -/* Link speed for X550 auto negotiation */ #define IXGBE_LINK_SPEED_X550_AUTONEG (IXGBE_LINK_SPEED_100_FULL | \ IXGBE_LINK_SPEED_1GB_FULL | \
drivers/net/intel/ixgbe/ixgbe_flow.c +17 -3
@@ -621,7 +621,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP_EXT (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540) +return -ENOTSUP ; ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error);
@@ -861,7 +863,13 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_ethertype_filter (attr, pattern, actions, filter, error);
@@ -1150,7 +1158,13 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_syn_filter (attr, pattern, actions, filter, error);
Signature · 1 line
2.47.3
PATCH v3 2/27 net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovThe security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 ------ drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 --- drivers/net/intel/ixgbe/ixgbe_flow.c | 6 ----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 -------------------- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 -- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 ----- 6 files changed, 52 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0 -8
@@ -32,9 +32,7 @@#include <rte_random.h> #include <dev_driver.h> #include <rte_hash_crc.h> -#ifdef RTE_LIB_SECURITY #include <rte_security_driver.h> -#endif #include <rte_os_shim.h> #include "ixgbe_logs.h"
@@ -1177,11 +1175,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)/* Unlock any pending hardware semaphore */ ixgbe_swfw_lock_reset (hw); -#ifdef RTE_LIB_SECURITY /* Initialize security_ctx only for primary process*/ if (ixgbe_ipsec_ctx_create (eth_dev))return -ENOMEM ; -#endif /* Initialize DCB configuration*/ memset (dcb_config,0 ,sizeof (struct ixgbe_dcb_config ));
@@ -1362,10 +1358,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; err_exit: -#ifdef RTE_LIB_SECURITY rte_free (eth_dev->security_ctx); eth_dev->security_ctx =NULL ; -#endif return ret; }
@@ -3148,10 +3142,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* Remove all Traffic Manager configuration */ ixgbe_tm_conf_uninit (dev); -#ifdef RTE_LIB_SECURITY rte_free (dev->security_ctx); dev->security_ctx =NULL ; -#endif return ret; }
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -4
@@ -14,9 +14,7 @@#include "base/ixgbe_dcb_82599.h" #include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" -#ifdef RTE_LIB_SECURITY #include "ixgbe_ipsec.h" -#endif #include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h>
@@ -480,9 +478,7 @@ struct ixgbe_adapter {struct ixgbe_filter_info filter;struct ixgbe_l2_tn_info l2_tn;struct ixgbe_bw_conf bw_conf; -#ifdef RTE_LIB_SECURITY struct ixgbe_ipsec ipsec; -#endif bool rx_bulk_alloc_allowed;bool rx_vec_allowed;struct rte_timecounter systime_tc;
drivers/net/intel/ixgbe/ixgbe_flow.c +0 -6
@@ -214,7 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -#ifdef RTE_LIB_SECURITY /** * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY */
@@ -249,7 +248,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); } -#endif /* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -630,11 +628,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (filter->proto ==IPPROTO_ESP )return 0 ; -#endif /* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {
@@ -3074,13 +3070,11 @@ ixgbe_flow_create(struct rte_eth_dev *dev, ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error); -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (ntuple_filter.proto ==IPPROTO_ESP ) { flow->is_security = true;return flow; } -#endif if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -26
@@ -459,7 +459,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, seqnum_seed |= tx_offload.l2_len <<IXGBE_ADVTXD_TUNNEL_LEN ; } -#ifdef RTE_LIB_SECURITY if (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ) {union ixgbe_crypto_tx_desc_md *md = (union ixgbe_crypto_tx_desc_md *)mdata;
@@ -473,7 +472,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, tx_offload_mask.sa_idx |= ~0 ; tx_offload_mask.sec_pad_len |= ~0 ; } -#endif txq->ctx_cache[ctx_idx].flags = ol_flags; txq->ctx_cache[ctx_idx].tx_offload.data[0] =
@@ -652,9 +650,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint32_t ctx =0 ;uint32_t new_ctx;union ixgbe_tx_offload tx_offload; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec; -#endif tx_offload.data[0 ] =0 ; tx_offload.data[1 ] =0 ;
@@ -682,9 +678,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,* are needed for offload functionality. */ ol_flags = tx_pkt->ol_flags; -#ifdef RTE_LIB_SECURITY use_ipsec = txq->using_ipsec && (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ); -#endif /* If hardware offload required */ tx_ol_req = ol_flags &IXGBE_TX_OFFLOAD_MASK ;
@@ -696,7 +690,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.tso_segsz = tx_pkt->tso_segsz; tx_offload.outer_l2_len = tx_pkt->outer_l2_len; tx_offload.outer_l3_len = tx_pkt->outer_l3_len; -#ifdef RTE_LIB_SECURITY if (use_ipsec) {union ixgbe_crypto_tx_desc_md *ipsec_mdata = (union ixgbe_crypto_tx_desc_md *)
@@ -704,7 +697,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.sa_idx = ipsec_mdata->sa_idx; tx_offload.sec_pad_len = ipsec_mdata->pad_len; } -#endif /* If new context need be built or reuse the exist ctx. */ ctx = what_advctx_update(txq, tx_ol_req,
@@ -896,10 +888,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, olinfo_status |= ctx <<IXGBE_ADVTXD_IDX_SHIFT ; } olinfo_status |= (pkt_len <<IXGBE_ADVTXD_PAYLEN_SHIFT ); -#ifdef RTE_LIB_SECURITY if (use_ipsec) olinfo_status |=IXGBE_ADVTXD_POPTS_IPSEC ; -#endif m_seg = tx_pkt; do {
@@ -1523,13 +1513,11 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status, uint16_t pkt_info, pkt_flags |=RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD ; } -#ifdef RTE_LIB_SECURITY if (rx_status &IXGBE_RXD_STAT_SECP ) { pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD ;if (rx_status &IXGBE_RXDADV_LNKSEC_ERROR_BAD_SIG ) pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED ; } -#endif return pkt_flags; }
@@ -2490,9 +2478,7 @@ ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) {struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;if (txq->offloads ==0 && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST ) { if (txq->tx_rs_thresh <= IXGBE_TX_MAX_FREE_BUF_SZ && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
@@ -2648,9 +2634,7 @@ ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ci_tx_queue *txq) {/* Use a simple Tx queue (no offloads, no multi segs) if possible */ if ((txq->offloads ==0 ) && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif (txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST )) {PMD_INIT_LOG (DEBUG ,"Using simple tx code path" ); dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
@@ -2711,10 +2695,8 @@ ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_SECURITY ; -#endif return tx_offload_capa; }
@@ -2884,10 +2866,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; -#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY ); -#endif /* * Modification to set VFTDT for virtual function if vf is detected
@@ -3171,10 +3151,8 @@ ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) offloads |=RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; -#endif return offloads; }
@@ -5102,10 +5080,8 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)struct ci_rx_queue *rxq = dev->data->rx_queues[i]; rxq->vector_rx = rx_using_sse; -#ifdef RTE_LIB_SECURITY rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ); -#endif } }
@@ -5611,7 +5587,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)ixgbe_setup_loopback_link_x540_x550 (hw, true); } -#ifdef RTE_LIB_SECURITY if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) || (dev->data->dev_conf.txmode.offloads &
@@ -5624,7 +5599,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)return ret; } } -#endif return 0 ; }
drivers/net/intel/ixgbe/ixgbe_rxtx.h +0 -2
@@ -99,11 +99,9 @@ union ixgbe_tx_offload {/* fields for TX offloading of tunnels */ uint64_t outer_l3_len:8; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:8; /**< Outer L2 (MAC) Hdr Length. */ -#ifdef RTE_LIB_SECURITY /* inline ipsec related*/ uint64_t sa_idx:8; /**< TX SA database entry index */ uint64_t sec_pad_len:4; /**< padding length */ -#endif }; };
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c +0 -6
@@ -21,7 +21,6 @@ ixgbe_rxq_rearm(struct ci_rx_queue *rxq)ci_rxq_rearm (rxq,CI_RX_VEC_LEVEL_SSE ); } -#ifdef RTE_LIB_SECURITY static inline void desc_to_olflags_v_ipsec (__m128i descs[4 ],struct rte_mbuf **rx_pkts) {
@@ -56,7 +55,6 @@ desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts) *rearm2 =_mm_extract_epi32 (rearm,2 ); *rearm3 =_mm_extract_epi32 (rearm,3 ); } -#endif static inline void desc_to_olflags_v(__m128i descs[4], __m128i mbuf_init, uint8_t vlan_flags,
@@ -265,9 +263,7 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,volatile union ixgbe_adv_rx_desc *rxdp;struct ci_rx_entry *sw_ring;uint16_t nb_pkts_recd; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec = rxq->using_ipsec; -#endif int pos;uint64_t var;__m128i shuf_msk;
@@ -444,10 +440,8 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,desc_to_olflags_v (descs, mbuf_init, vlan_flags, udp_p_flag, &rx_pkts[pos]); -#ifdef RTE_LIB_SECURITY if (unlikely (use_ipsec))desc_to_olflags_v_ipsec (descs, &rx_pkts[pos]); -#endif /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */ pkt_mb4 =_mm_add_epi16 (pkt_mb4, crc_adjust);
Signature · 1 line
2.47.3
PATCH v3 3/27 net/ixgbe: split security and ntuple filters
In reply to Anatoly BurakovThese filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
While we're at it, we're making checks more stringent (such as checking for NULL conf), and more type safe.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 136 ++++++++++++++++++--------- 1 file changed, 91 insertions(+), 45 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +91 -45
@@ -214,41 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -/** -* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY -*/ - act =next_no_void_action (actions,NULL ); -if (act->type ==RTE_FLOW_ACTION_TYPE_SECURITY ) { -const void *conf = act->conf; -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -/* get the IP pattern*/ - item =next_no_void_pattern (pattern,NULL ); -while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { -if (item->last || - item->type ==RTE_FLOW_ITEM_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"IP pattern missing." ); -return -rte_errno; - } - item =next_no_void_pattern (pattern, item); - } - - filter->proto =IPPROTO_ESP ; -return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, - item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); - } -/* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -607,6 +572,81 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return 0 ; } +static int +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[],const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +const struct rte_flow_action_security *security; +const struct rte_flow_item *item; +const struct rte_flow_action *act; + +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; + +if (pattern ==NULL ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (actions ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (attr ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +return -rte_errno; + } + +/* check if next non-void action is security */ + act =next_no_void_action (actions,NULL ); +if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + security = act->conf; +if (security ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"NULL security action config." ); + } +/* check if the next not void item is END */ + act =next_no_void_action (actions, act); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + +/* get the IP pattern*/ + item =next_no_void_pattern (pattern,NULL ); +while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +if (item->last || item->type ==RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"IP pattern missing." ); +return -rte_errno; + } + item =next_no_void_pattern (pattern, item); + } + +return ixgbe_crypto_add_ingress_sa_from_flow (security->security_session, + item->spec, item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -628,10 +668,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -/* ESP flow not really a flow*/ -if (filter->proto ==IPPROTO_ESP ) -return 0 ; -/* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -3066,16 +3102,19 @@ ixgbe_flow_create(struct rte_eth_dev *dev,TAILQ_INSERT_TAIL (&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries); -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, - actions, &ntuple_filter, error); - -/* ESP flow not really a flow*/ -if (ntuple_filter.proto ==IPPROTO_ESP ) { +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) { flow->is_security = true;return flow; } +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);if (!ret) {
@@ -3299,6 +3338,13 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf rss_conf;int ret; +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) +return 0 ; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error);
Signature · 1 line
2.47.3
PATCH v3 4/27 net/i40e: get rid of global filter variables
In reply to Anatoly BurakovCurrently, i40e driver relies on global state to work around the fact that rte_flow_validate() is being called directly from rte_flow_create(), and it not being possible to pass state between two functions. Fix that by making a small wrapper around validation that will create a dummy context.
Additionally, tunnel filter doesn't appear to be used by anything and so is omitted from the structure.
--- drivers/net/intel/i40e/i40e_ethdev.h | 16 ++-- drivers/net/intel/i40e/i40e_flow.c | 117 ++++++++++++++------------- 2 files changed, 68 insertions(+), 65 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +9 -7
@@ -1304,12 +1304,14 @@ struct i40e_vf_representor {extern const struct rte_flow_ops i40e_flow_ops; -union i40e_filter_t { -struct rte_eth_ethertype_filter ethertype_filter; -struct i40e_fdir_filter_conf fdir_filter; -struct rte_eth_tunnel_filter_conf tunnel_filter; -struct i40e_tunnel_filter_conf consistent_tunnel_filter; -struct i40e_rte_flow_rss_conf rss_conf; +struct i40e_filter_ctx { +union { +struct rte_eth_ethertype_filter ethertype_filter; +struct i40e_fdir_filter_conf fdir_filter; +struct i40e_tunnel_filter_conf consistent_tunnel_filter; +struct i40e_rte_flow_rss_conf rss_conf; + }; +enum rte_filter_type type; }; typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -1317,7 +1319,7 @@ typedef int (*parse_filter_t)(struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error, - union i40e_filter_t *filter); + struct i40e_filter_ctx *filter);struct i40e_valid_pattern {enum rte_flow_item_type *items;parse_filter_t parse_filter;
drivers/net/intel/i40e/i40e_flow.c +59 -58
351 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v3 5/27 net/i40e: make default RSS key global
In reply to Anatoly BurakovCurrently, there are multiple places where we need a default RSS key, but in each of those places we define it as a local variable. Make it global constant, and adjust all callers to use the global constant. When dealing with adminq, we cannot send down the constant because adminq commands do not guarantee const-ness, so copy RSS key into a local buffer before sending it down to hardware.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 ++++++++++------------ drivers/net/intel/i40e/i40e_hash.c | 23 +++++++++++++++++------ drivers/net/intel/i40e/i40e_hash.h | 3 +++ 3 files changed, 30 insertions(+), 18 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +10 -12
@@ -9082,23 +9082,21 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)int i40e_pf_reset_rss_key (struct i40e_pf *pf) { -const uint8_t key_len = (I40E_PFQF_HKEY_MAX_INDEX +1 ) * -sizeof (uint32_t ); -uint8_t *rss_key; +uint8_t key_buf[I40E_RSS_KEY_LEN ]; +const uint8_t *rss_key;/* Reset key */ rss_key = pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key; -if (!rss_key || - pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len < key_len) { -static uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; +if (!rss_key || pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len <sizeof (key_buf)) + rss_key = i40e_rss_key_default; - rss_key = (uint8_t *)rss_key_default; - } +/* +* adminq does not guarantee const-ness of RSS key once a command is sent down, so make a +* local copy. +*/ +memcpy (&key_buf, rss_key,sizeof (key_buf)); -return i40e_set_rss_key (pf->main_vsi, rss_key, key_len); +return i40e_set_rss_key (pf->main_vsi, key_buf,sizeof (key_buf)); } static int
drivers/net/intel/i40e/i40e_hash.c +17 -6
@@ -233,6 +233,22 @@ struct i40e_hash_match_pattern { RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) +const uint8_t i40e_rss_key_default[] = { +0x44 ,0x39 ,0x79 ,0x6b , +0xb5 ,0x4c ,0x50 ,0x23 , +0xb6 ,0x75 ,0xea ,0x5b , +0x12 ,0x4f ,0x9f ,0x30 , +0xb8 ,0xa2 ,0xc0 ,0x3d , +0xdf ,0xdc ,0x4d ,0x02 , +0xa0 ,0x8c ,0x9b ,0x33 , +0x4a ,0xf6 ,0x4a ,0x4c , +0x05 ,0xc6 ,0xfa ,0x34 , +0x39 ,0x58 ,0xd8 ,0x55 , +0x7d ,0x99 ,0x58 ,0x3a , +0xe1 ,0x38 ,0xc9 ,0x2e , +0x81 ,0x15 ,0x03 ,0x66 +}; +/* Current supported patterns and RSS types. * All items that have the same pattern types are together. */
@@ -910,17 +926,12 @@ i40e_hash_parse_key(const struct rte_flow_action_rss *rss_act,const uint8_t *key = rss_act->key;if (!key || rss_act->key_len !=sizeof (rss_conf->key)) { -const uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; -if (rss_act->key_len !=sizeof (rss_conf->key))PMD_DRV_LOG (WARNING ,"RSS key length invalid, must be %u bytes, now set key to default" , (uint32_t )sizeof (rss_conf->key)); -memcpy (rss_conf->key, rss_key_default,sizeof (rss_conf->key)); +memcpy (rss_conf->key, i40e_rss_key_default,sizeof (rss_conf->key)); }else {memcpy (rss_conf->key, key,sizeof (rss_conf->key)); }
drivers/net/intel/i40e/i40e_hash.h +3 -0
@@ -27,6 +27,9 @@ int i40e_hash_filter_destroy(struct i40e_pf *pf, const struct i40e_rss_filter *rss_filter);int i40e_hash_filter_flush (struct i40e_pf *pf); +#define I40E_RSS_KEY_LEN ((I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) +extern const uint8_t i40e_rss_key_default[I40E_RSS_KEY_LEN ]; + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH v3 6/27 net/i40e: use unsigned types for queue comparisons
In reply to Anatoly BurakovCurrently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare I40E_MAX_Q_PER_TC to an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence, i40e_align_floor now returns unsigned value as well - this is correct, because nothing about that function implies signed usage being a valid use case.
--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +1 -1
@@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
drivers/net/intel/i40e/i40e_ethdev.h +3 -3
@@ -24,7 +24,7 @@#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ -#define I40E_MAX_Q_PER_TC 64 +#define I40E_MAX_Q_PER_TC 64U#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw) hw->aq.asq_buf_size =I40E_AQ_BUF_SZ ; } -static inline int -i40e_align_floor (int n) +static inline uint32_t +i40e_align_floor (uint32_t n) {if (n ==0 )return 0 ;
drivers/net/intel/i40e/i40e_hash.c +2 -2
@@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev,struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue; hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); if (!rss_act->queue_num ||
@@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, max_queue =RTE_MIN (max_queue,I40E_MAX_Q_PER_TC );for (i =0 ; i < rss_act->queue_num; i++) { -if ((int )rss_act->queue[i] >= max_queue) +if (rss_act->queue[i] >= max_queue)break ; }
Signature · 1 line
2.47.3
PATCH v3 7/27 net/i40e: use proper flex len define
In reply to Anatoly BurakovFor FDIR, we have byte arrays that are supposed to be limited to whatever the HW supports in terms of flex descriptor matching. However, in the structure definition, spec and mask bytes are using different array length defines, and the only reason why this works is because they evaluate to the same value.
Use the i40e-specific definition instead.
--- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -631,7 +631,7 @@ struct i40e_fdir_flex_pit {/* A structure used to contain extend input of flow */ struct i40e_fdir_flow_ext {uint16_t vlan_tci; -uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN ]; +uint8_t flexbytes[I40E_FDIR_MAX_FLEX_LEN ];/* It is filled by the flexible payload to match. */ uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN ];uint8_t raw_id;
Signature · 1 line
2.47.3
PATCH v3 8/27 net/i40e: remove global pattern variable
In reply to Anatoly BurakovWhen parsing flow patterns, current code cleans up the pattern list by removing void flow items, and copies the patterns into an array. That array, when dealing with under 32 flow items, is allocated on the stack, but when the pattern is big enough, a new list is dynamically allocated. This allocated list is a global variable, and is allocated using rte_zmalloc call which seems like overkill for this use case.
Remove the global variable, and replace the split behavior with unconditional allocation.
--- drivers/net/intel/i40e/i40e_flow.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +9 -20
@@ -145,9 +145,6 @@ const struct rte_flow_ops i40e_flow_ops = { .query = i40e_flow_query, }; -/* internal pattern w/o VOID items */ -struct rte_flow_item g_items[32 ]; -/* Pattern matched ethertype filter */ static enum rte_flow_item_type pattern_ethertype[] = {RTE_FLOW_ITEM_TYPE_ETH ,
@@ -3837,19 +3834,13 @@ i40e_flow_check(struct rte_eth_dev *dev, i++; } item_num++; - -if (item_num <=ARRAY_SIZE (g_items)) { - items = g_items; - }else { - items =rte_zmalloc ("i40e_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); -if (!items) { -rte_flow_error_set (error,ENOMEM , -RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL , -"No memory for PMD internal items." ); -return -ENOMEM ; - } + items =calloc (item_num,sizeof (struct rte_flow_item )); +if (items ==NULL ) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL , +"No memory for PMD internal items." ); +return -ENOMEM ; }i40e_pattern_skip_void_item (items, pattern);
@@ -3862,8 +3853,7 @@ i40e_flow_check(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ITEM , pattern, "Unsupported pattern"); -if (items != g_items) -rte_free (items); +free (items);return -rte_errno; }
@@ -3873,8 +3863,7 @@ i40e_flow_check(struct rte_eth_dev *dev, flag = true; }while ((ret <0 ) && (i <RTE_DIM (i40e_supported_patterns))); -if (items != g_items) -rte_free (items); +free (items);return ret; }
Signature · 1 line
2.47.3
PATCH v3 9/27 net/i40e: avoid rte malloc in tunnel set
In reply to Anatoly BurakovCurrently, when setting tunnel configuration, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++--------------- 1 file changed, 53 insertions(+), 71 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +53 -71
@@ -8511,38 +8511,27 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,struct i40e_pf_vf *vf =NULL ;struct i40e_hw *hw =I40E_PF_TO_HW (pf);struct i40e_vsi *vsi; -struct i40e_aqc_cloud_filters_element_bb *cld_filter; -struct i40e_aqc_cloud_filters_element_bb *pfilter; +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 };struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -struct i40e_tunnel_filter *tunnel, *node; +struct i40e_tunnel_filter *node;struct i40e_tunnel_filter check_filter;/* Check if filter exists */ uint32_t teid_le;bool big_buffer =0 ; - cld_filter =rte_zmalloc ("tunnel_filter" , -sizeof (struct i40e_aqc_add_rm_cloud_filt_elem_ext ), -0 ); - -if (cld_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - pfilter = cld_filter; -rte_ether_addr_copy (&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&pfilter->element.outer_mac); + (struct rte_ether_addr *)&cld_filter.element.outer_mac);rte_ether_addr_copy (&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&pfilter->element.inner_mac); + (struct rte_ether_addr *)&cld_filter.element.inner_mac); - pfilter->element.inner_vlan = + cld_filter.element.inner_vlan =rte_cpu_to_le_16 (tunnel_filter->inner_vlan);if (tunnel_filter->ip_type ==I40E_TUNNEL_IPTYPE_IPV4 ) { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV4 ; ipv4_addr =rte_be_to_cpu_32 (tunnel_filter->ip_addr.ipv4_addr); ipv4_addr_le =rte_cpu_to_le_32 (ipv4_addr); -rte_memcpy (&pfilter->element.ipaddr.v4.data, +rte_memcpy (&cld_filter.element.ipaddr.v4.data, &ipv4_addr_le, -sizeof (pfilter->element.ipaddr.v4.data)); +sizeof (cld_filter.element.ipaddr.v4.data)); }else { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ;for (i =0 ; i <4 ; i++) {
@@ -8550,9 +8539,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,rte_cpu_to_le_32 (rte_be_to_cpu_32 ( tunnel_filter->ip_addr.ipv6_addr[i])); } -rte_memcpy (&pfilter->element.ipaddr.v6.data, +rte_memcpy (&cld_filter.element.ipaddr.v6.data, &convert_ipv6, -sizeof (pfilter->element.ipaddr.v6.data)); +sizeof (cld_filter.element.ipaddr.v6.data)); }/* check tunneled type */
@@ -8573,11 +8562,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x40 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP ;
@@ -8589,11 +8578,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x0 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE ;
@@ -8605,11 +8594,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8620,11 +8609,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8641,8 +8630,8 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,* Big Buffer should be set, see changes in * i40e_aq_add_cloud_filters */ - pfilter->general_fields[0 ] = tunnel_filter->inner_vlan; - pfilter->general_fields[1 ] = tunnel_filter->outer_vlan; + cld_filter.general_fields[0 ] = tunnel_filter->inner_vlan; + cld_filter.general_fields[1 ] = tunnel_filter->outer_vlan; big_buffer =1 ;break ;case I40E_CLOUD_TYPE_UDP :
@@ -8657,20 +8646,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->sport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }else {
@@ -8682,20 +8671,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->dport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }
@@ -8704,48 +8693,46 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,default :/* Other tunnel types is not supported. */ PMD_DRV_LOG (ERR ,"tunnel type is not supported." ); -rte_free (cld_filter);return -EINVAL ; }if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPC ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPU ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_QINQ ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_SCTP ) {if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ; }else { val =i40e_dev_get_filter_type (tunnel_filter->filter_type, - &pfilter->element.flags); + &cld_filter.element.flags);if (val <0 ) { -rte_free (cld_filter);return -EINVAL ; } } - pfilter->element.flags |=rte_cpu_to_le_16 ( -I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | - ip_type | (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); - pfilter->element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->element.queue_number = + cld_filter.element.flags |= +rte_cpu_to_le_16 (I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type | + (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); + cld_filter.element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); + cld_filter.element.queue_number =rte_cpu_to_le_16 (tunnel_filter->queue_id);if (!tunnel_filter->is_to_vf)
@@ -8753,7 +8740,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,else {if (tunnel_filter->vf_id >= pf->vf_num) {PMD_DRV_LOG (ERR ,"Invalid argument." ); -rte_free (cld_filter);return -EINVAL ; } vf = &pf->vfs[tunnel_filter->vf_id];
@@ -8762,38 +8748,36 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,/* Check if there is the filter in SW list */ memset (&check_filter,0 ,sizeof (check_filter)); -i40e_tunnel_filter_convert (cld_filter, &check_filter); +i40e_tunnel_filter_convert (&cld_filter, &check_filter); check_filter.is_to_vf = tunnel_filter->is_to_vf; check_filter.vf_id = tunnel_filter->vf_id; node =i40e_sw_tunnel_filter_lookup (tunnel_rule, &check_filter.input);if (add && node) {PMD_DRV_LOG (ERR ,"Conflict with existing tunnel rules!" ); -rte_free (cld_filter);return -EINVAL ; }if (!add && !node) {PMD_DRV_LOG (ERR ,"There's no corresponding tunnel filter!" ); -rte_free (cld_filter);return -EINVAL ; }if (add) { +struct i40e_tunnel_filter *tunnel; +if (big_buffer) ret =i40e_aq_add_cloud_filters_bb (hw, - vsi->seid, cld_filter,1 ); + vsi->seid, &cld_filter,1 );else ret =i40e_aq_add_cloud_filters (hw, - vsi->seid, &cld_filter->element,1 ); + vsi->seid, &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to add a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } tunnel =rte_zmalloc ("tunnel_filter" ,sizeof (*tunnel),0 );if (tunnel ==NULL ) {PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -rte_free (cld_filter);return -ENOMEM ; }
@@ -8804,19 +8788,17 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, }else {if (big_buffer) ret =i40e_aq_rem_cloud_filters_bb ( - hw, vsi->seid, cld_filter,1 ); + hw, vsi->seid, &cld_filter,1 );else ret =i40e_aq_rem_cloud_filters (hw, vsi->seid, - &cld_filter->element,1 ); + &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to delete a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } ret =i40e_sw_tunnel_filter_del (pf, &node->input); } -rte_free (cld_filter);return ret; }
Signature · 1 line
2.47.3
PATCH v3 10/27 net/i40e: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +4 -4
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4649,7 +4649,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev, pf->adapter->rss_reta_updated =1 ; out: -rte_free (lut); +free (lut);return ret; }
@@ -4673,7 +4673,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4690,7 +4690,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v3 11/27 net/i40e: avoid rte malloc in MAC/VLAN filtering
In reply to Anatoly BurakovCurrently, when adding, removing, or configuring MAC and VLAN filters, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 38 +++++++++++++-------------- drivers/net/intel/i40e/rte_pmd_i40e.c | 16 +++++------ 2 files changed, 26 insertions(+), 28 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +18 -20
@@ -4165,8 +4165,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { i =0 ; num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -4206,7 +4205,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (ret)PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); } -rte_free (mac_filter); +free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -6231,8 +6230,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -6264,7 +6262,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) } DONE: -rte_free (mac_filter); +free (mac_filter);return ret; }
@@ -7154,7 +7152,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_add" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7207,7 +7205,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7230,7 +7228,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_remove" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7286,7 +7284,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7455,7 +7453,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)else num = vsi->mac_num * vsi->vlan_num; - mv_f =rte_zmalloc ("macvlan_data" , num *sizeof (*mv_f),0 ); + mv_f =calloc (num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7484,7 +7482,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi) ret =i40e_remove_macvlan_filters (vsi, mv_f, num); DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7510,7 +7508,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7532,7 +7530,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num++; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7561,7 +7559,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7594,7 +7592,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num--; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7626,7 +7624,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) mac_filter->filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7665,7 +7663,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7696,7 +7694,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7725,7 +7723,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
drivers/net/intel/i40e/rte_pmd_i40e.c +8 -8
@@ -233,7 +233,7 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -250,18 +250,18 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_remove_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
@@ -294,7 +294,7 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) f->mac_info.filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -312,18 +312,18 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_add_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
Signature · 1 line
2.47.3
PATCH v3 12/27 net/i40e: avoid rte malloc in VF resource queries
In reply to Anatoly BurakovCurrently, when responding to VF resource queries, we are dynamically allocating a temporary buffer with rte_zmalloc followed by an immediate rte_free. This is not needed as the response is only used temporarily, so replace it with a stack-allocated structure (the allocation is fixed in size and pretty small).
--- drivers/net/intel/i40e/i40e_pf.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/net/intel/i40e/i40e_pf.c +7 -19
@@ -309,9 +309,14 @@ static int i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg, bool b_op) { - struct virtchnl_vf_resource *vf_res = NULL; +/* only have 1 VSI by default */ +struct { +struct virtchnl_vf_resource vf_res; +struct virtchnl_vsi_resource vsi_res; + } res = {0 }; +struct virtchnl_vf_resource *vf_res = &res.vf_res; +uint32_t len =sizeof (res);struct i40e_hw *hw =I40E_PF_TO_HW (vf->pf); -uint32_t len =0 ;uint64_t default_hena =I40E_RSS_HENA_ALL ;int ret =I40E_SUCCESS ;
@@ -322,20 +327,6 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,return ret; } -/* only have 1 VSI by default */ - len =sizeof (struct virtchnl_vf_resource ) + -I40E_DEFAULT_VF_VSI_NUM * -sizeof (struct virtchnl_vsi_resource ); - - vf_res =rte_zmalloc ("i40e_vf_res" , len,0 ); -if (vf_res ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate mem" ); - ret =I40E_ERR_NO_MEMORY ; - vf_res =NULL ; - len =0 ; - goto send_msg; - } -if (VF_IS_V10 (&vf->version))/* doesn't support offload negotiate */ vf->request_caps =VIRTCHNL_VF_OFFLOAD_L2 |VIRTCHNL_VF_OFFLOAD_VLAN ;
@@ -377,11 +368,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,rte_ether_addr_copy (&vf->mac_addr, (struct rte_ether_addr *)vf_res->vsi_res[0 ].default_mac_addr); -send_msg:i40e_pf_host_send_msg_to_vf (vf,VIRTCHNL_OP_GET_VF_RESOURCES , ret, (uint8_t *)vf_res, len); -rte_free (vf_res); -return ret; }
Signature · 1 line
2.47.3
PATCH v3 13/27 net/i40e: avoid rte malloc in adminq operations
In reply to Anatoly BurakovCurrently, when processing admin queue messages, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as the message buffer is only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +2 -2
@@ -6896,7 +6896,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)int ret; info.buf_len =I40E_AQ_BUF_SZ ; - info.msg_buf =rte_zmalloc ("msg_buffer" , info.buf_len,0 ); + info.msg_buf =calloc (1 , info.buf_len);if (!info.msg_buf) {PMD_DRV_LOG (ERR ,"Failed to allocate mem" );return ;
@@ -6936,7 +6936,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)break ; } } -rte_free (info.msg_buf); +free (info.msg_buf); } static void
Signature · 1 line
2.47.3
PATCH v3 14/27 net/i40e: avoid rte malloc in DDP package handling
In reply to Anatoly BurakovCurrently, when processing Dynamic Driver Profile (DDP) packages and checking profile information, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily, so replace it with stack-allocated structures or regular malloc/free where appropriate.
--- drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++++++------------------ 1 file changed, 14 insertions(+), 29 deletions(-)
drivers/net/intel/i40e/rte_pmd_i40e.c +14 -29
@@ -1569,9 +1569,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)PMD_DRV_LOG (INFO ,"Read-only profile." );return 0 ; } - buff =rte_zmalloc ("pinfo_list" , - (I40E_PROFILE_INFO_SIZE *I40E_MAX_PROFILE_NUM +4 ), -0 ); + buff =calloc (I40E_MAX_PROFILE_NUM +4 ,I40E_PROFILE_INFO_SIZE );if (!buff) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return -1 ;
@@ -1583,7 +1581,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) 0, NULL);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get profile info list." ); -rte_free (buff); +free (buff);return -1 ; } p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1591,20 +1589,20 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) p = &p_list->p_info[i];if (pinfo->track_id == p->track_id) {PMD_DRV_LOG (INFO ,"Profile exists." ); -rte_free (buff); +free (buff);return 1 ; } }/* profile with group id 0xff is compatible with any other profile */ if ((pinfo->track_id & group_mask) == group_mask) { -rte_free (buff); +free (buff);return 0 ; }for (i =0 ; i < p_list->p_count; i++) { p = &p_list->p_info[i];if ((p->track_id & group_mask) ==0 ) {PMD_DRV_LOG (INFO ,"Profile of the group 0 exists." ); -rte_free (buff); +free (buff);return 2 ; } }
@@ -1615,12 +1613,12 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)if ((pinfo->track_id & group_mask) != (p->track_id & group_mask)) {PMD_DRV_LOG (INFO ,"Profile of different group exists." ); -rte_free (buff); +free (buff);return 3 ; } } -rte_free (buff); +free (buff);return 0 ; }
@@ -1636,7 +1634,10 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,struct i40e_generic_seg_header *profile_seg_hdr;struct i40e_generic_seg_header *metadata_seg_hdr;uint32_t track_id; -uint8_t *profile_info_sec; +struct { +struct i40e_profile_section_header sec; +struct i40e_profile_info info; + } profile_info_sec = {0 };int is_exist;enum i40e_status_code status =I40E_SUCCESS ;static const uint32_t type_mask =0xff000000 ;
@@ -1701,26 +1702,15 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,return -EINVAL ; } - profile_info_sec =rte_zmalloc ( -"i40e_profile_info" , -sizeof (struct i40e_profile_section_header ) + -sizeof (struct i40e_profile_info ), -0 ); -if (!profile_info_sec) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -return -EINVAL ; - } -/* Check if the profile already loaded */ i40e_generate_profile_info_sec ( ((struct i40e_profile_segment *)profile_seg_hdr)->name, &((struct i40e_profile_segment *)profile_seg_hdr)->version, - track_id, profile_info_sec, + track_id, (uint8_t * )&profile_info_sec, op ==RTE_PMD_I40E_PKG_OP_WR_ADD ); - is_exist =i40e_check_profile_info (port, profile_info_sec); + is_exist =i40e_check_profile_info (port, (uint8_t * )&profile_info_sec);if (is_exist <0 ) {PMD_DRV_LOG (ERR ,"Failed to check profile." ); -rte_free (profile_info_sec);return -EINVAL ; }
@@ -1733,13 +1723,11 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,else if (is_exist ==3 )PMD_DRV_LOG (ERR ,"Profile of different group already exists" );i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return -EEXIST ; } }else if (op ==RTE_PMD_I40E_PKG_OP_WR_DEL ) {if (is_exist !=1 ) {PMD_DRV_LOG (ERR ,"Profile does not exist." ); -rte_free (profile_info_sec);return -EACCES ; } }
@@ -1751,7 +1739,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, track_id);if (status) {PMD_DRV_LOG (ERR ,"Failed to write profile for delete." ); -rte_free (profile_info_sec);return status; } }else {
@@ -1764,14 +1751,13 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,PMD_DRV_LOG (ERR ,"Failed to write profile for add." ); else PMD_DRV_LOG(ERR, "Failed to write profile."); -rte_free (profile_info_sec);return status; } }if (track_id && (op !=RTE_PMD_I40E_PKG_OP_WR_ONLY )) {/* Modify loaded profiles info list */ - status =i40e_add_rm_profile_info (hw, profile_info_sec); + status =i40e_add_rm_profile_info (hw, (uint8_t * )&profile_info_sec);if (status) {if (op ==RTE_PMD_I40E_PKG_OP_WR_ADD )PMD_DRV_LOG (ERR ,"Failed to add profile to info list." );
@@ -1784,7 +1770,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, op == RTE_PMD_I40E_PKG_OP_WR_DEL)i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return status; }
Signature · 1 line
2.47.3
PATCH v3 15/27 net/i40e: avoid rte malloc in DDP ptype handling
In reply to Anatoly BurakovCurrently, when updating customized protocol and packet type information via DDP packages, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +12 -13
@@ -11787,7 +11787,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = pctype_num *sizeof (struct rte_pmd_i40e_proto_info ); - pctype =rte_zmalloc ("new_pctype" , buff_size,0 ); + pctype =calloc (pctype_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!pctype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11798,7 +11798,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get pctype list" ); -rte_free (pctype); +free (pctype);return -1 ; }
@@ -11879,7 +11879,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype); +free (pctype);return 0 ; }
@@ -11925,7 +11925,7 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_info ); - ptype =rte_zmalloc ("new_ptype" , buff_size,0 ); + ptype =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_info ));if (!ptype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11937,15 +11937,14 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get ptype list" ); -rte_free (ptype); +free (ptype);return ret; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_mapping ); - ptype_mapping =rte_zmalloc ("ptype_mapping" , buff_size,0 ); + ptype_mapping =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_mapping ));if (!ptype_mapping) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -rte_free (ptype); +free (ptype);return -1 ; }
@@ -12083,8 +12082,8 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (ERR ,"Failed to update ptype mapping table." ); -rte_free (ptype_mapping); -rte_free (ptype); +free (ptype_mapping); +free (ptype);return ret; }
@@ -12119,7 +12118,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = proto_num *sizeof (struct rte_pmd_i40e_proto_info ); - proto =rte_zmalloc ("new_proto" , buff_size,0 ); + proto =calloc (proto_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!proto) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return ;
@@ -12131,7 +12130,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get protocol list" ); -rte_free (proto); +free (proto);return ; }
@@ -12169,7 +12168,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (INFO ,"No ptype is updated." ); -rte_free (proto); +free (proto); }/* Create a QinQ cloud filter
Signature · 1 line
2.47.3
PATCH v3 16/27 net/iavf: remove remnants of pipeline mode
In reply to Anatoly BurakovWhen pipeline mode was removed, some of the things used by pipelines were left in the code. Remove them as they are unused.
--- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 --------------- drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_ipsec_crypto.c | 1 - 5 files changed, 19 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +0 -1
@@ -1632,7 +1632,6 @@ static struct iavf_flow_parser iavf_fdir_parser = { .array = iavf_fdir_pattern, .array_len = RTE_DIM(iavf_fdir_pattern), .parse_pattern_action = iavf_fdir_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fdir_engine_register)
drivers/net/intel/iavf/iavf_fsub.c +0 -1
@@ -814,7 +814,6 @@ iavf_flow_parser iavf_fsub_parser = { .array = iavf_fsub_pattern_list, .array_len = RTE_DIM(iavf_fsub_pattern_list), .parse_pattern_action = iavf_fsub_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fsub_engine_init)
drivers/net/intel/iavf/iavf_generic_flow.h +0 -15
@@ -485,20 +485,6 @@ enum iavf_flow_engine_type { IAVF_FLOW_ENGINE_MAX, }; -/** -* classification stages. -* for non-pipeline mode, we have two classification stages: Distributor/RSS -* for pipeline-mode we have three classification stages: -* Permission/Distributor/RSS -*/ -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 , -}; -/* Struct to store engine created. */ struct iavf_flow_engine {TAILQ_ENTRY (iavf_flow_engine) node;
@@ -527,7 +513,6 @@ struct iavf_flow_parser {struct iavf_pattern_match_item *array;uint32_t array_len;parse_pattern_action_t parse_pattern_action; -enum iavf_flow_classification_stage stage; };/* Struct to store parser created. */
drivers/net/intel/iavf/iavf_hash.c +0 -1
@@ -691,7 +691,6 @@ static struct iavf_flow_parser iavf_hash_parser = { .array = iavf_hash_pattern_list, .array_len = RTE_DIM(iavf_hash_pattern_list), .parse_pattern_action = iavf_hash_parse_pattern_action, - .stage = IAVF_FLOW_STAGE_RSS, };int
drivers/net/intel/iavf/iavf_ipsec_crypto.c +0 -1
@@ -1983,7 +1983,6 @@ static struct iavf_flow_parser iavf_ipsec_flow_parser = { .array = iavf_ipsec_flow_pattern, .array_len = RTE_DIM(iavf_ipsec_flow_pattern), .parse_pattern_action = iavf_ipsec_flow_parse, - .stage = IAVF_FLOW_STAGE_IPSEC_CRYPTO, };RTE_INIT (iavf_ipsec_flow_engine_register)
Signature · 1 line
2.47.3
PATCH v3 17/27 net/iavf: avoid rte malloc in VF mailbox for IPsec
In reply to Anatoly BurakovCurrently, when calling down into the VF mailbox, IPsec code will use dynamic memory allocation (rte_malloc one at that!) to allocate VF message structures which are ~40 bytes in size, and then immediately frees them. This is wasteful and unnecessary, so use stack allocation instead.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 157 +++++++-------------- 1 file changed, 51 insertions(+), 106 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +51 -106
@@ -458,36 +458,24 @@ static uint32_t iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, struct rte_security_session_conf *conf) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -struct virtchnl_ipsec_sa_cfg *sa_cfg; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg sa_cfg; + } sa_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp; +struct inline_ipsec_msg *request = &sa_req.msg, *response = &sa_resp.msg; +struct virtchnl_ipsec_sa_cfg *sa_cfg = &sa_req.sa_cfg;int rc; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg ); - - request =rte_malloc ("iavf-sad-add-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg_resp ); - response =rte_malloc ("iavf-sad-add-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;/* set SA configuration params */ - sa_cfg = (struct virtchnl_ipsec_sa_cfg *)(request +1 ); - sa_cfg->spi = conf->ipsec.spi; sa_cfg->virtchnl_protocol_type =VIRTCHNL_PROTO_ESP ; sa_cfg->virtchnl_direction =
@@ -541,10 +529,10 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sa_req), + (uint8_t *)response,sizeof (sa_resp));if (rc) - goto update_cleanup; +return rc;/* verify response id */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -552,9 +540,6 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, rc = -EFAULT ; else rc = response->ipsec_data.sa_cfg_resp->sa_handle; -update_cleanup: -rte_free (response); -rte_free (request);return rc; }
@@ -722,19 +707,18 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, bool is_udp, uint16_t udp_port) { -struct inline_ipsec_msg *request =NULL , *response =NULL ; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg sp_cfg; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg; +struct inline_ipsec_msg *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg ); - request =rte_malloc ("iavf-inbound-security-policy-add-request" , - request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -768,21 +752,12 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, request->ipsec_data.sp_cfg->is_udp = is_udp; request->ipsec_data.sp_cfg->udp_port =htons (udp_port); - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg_resp ); - response =rte_malloc ("iavf-inbound-security-policy-add-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -791,10 +766,6 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,else rc = response->ipsec_data.sp_cfg_resp->rule_id; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -802,26 +773,17 @@ static uint32_t iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_update sa_update; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_update ); - request =rte_malloc ("iavf-sa-update-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sa-update-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_UPDATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -833,10 +795,10 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -845,10 +807,6 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,else rc = response->ipsec_data.ipsec_resp->resp; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -899,26 +857,17 @@ int iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter, uint8_t is_v4, uint32_t flow_id) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_destroy sp_destroy; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_destroy ); - request =rte_malloc ("iavf-sp-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sp-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -931,21 +880,17 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode || response->req_id != request->req_id) rc = -EFAULT ;else -return response->ipsec_data.ipsec_status->status; - -update_cleanup: -rte_free (request); -rte_free (response); + rc = response->ipsec_data.ipsec_status->status;return rc; }
Signature · 1 line
2.47.3
PATCH v3 18/27 net/iavf: decouple hash uninit from parser uninit
In reply to Anatoly BurakovCurrently, parser deinitialization will trigger removal of current RSS configuration. This should not be done as part of parser deinitialization, but should rather be a separate step in dev close flow.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++++ drivers/net/intel/iavf/iavf_hash.c | 13 +++++++++---- drivers/net/intel/iavf/iavf_hash.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
drivers/net/intel/iavf/iavf_ethdev.c +4 -0
@@ -35,6 +35,7 @@#include "iavf_generic_flow.h" #include "rte_pmd_iavf.h" #include "iavf_ipsec_crypto.h" +#include "iavf_hash.h" /* devargs */ #define IAVF_PROTO_XTR_ARG "proto_xtr"
@@ -2972,6 +2973,9 @@ iavf_dev_close(struct rte_eth_dev *dev)/* free iAVF security device context all related resources */ iavf_security_ctx_destroy (adapter); +/* remove RSS configuration */ +iavf_hash_uninit (adapter); +iavf_flow_flush (dev,NULL );iavf_flow_uninit (adapter);
drivers/net/intel/iavf/iavf_hash.c +9 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "iavf_hash.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -77,7 +78,7 @@ static int iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow, struct rte_flow_error *error);static void -iavf_hash_uninit (struct iavf_adapter *ad); +iavf_hash_uninit_parser (struct iavf_adapter *ad);static void iavf_hash_free (struct rte_flow *flow); static int
@@ -680,7 +681,7 @@ static struct iavf_flow_engine iavf_hash_engine = { .init = iavf_hash_init, .create = iavf_hash_create, .destroy = iavf_hash_destroy, - .uninit = iavf_hash_uninit, + .uninit = iavf_hash_uninit_parser, .free = iavf_hash_free, .type = IAVF_FLOW_ENGINE_HASH, };
@@ -1641,6 +1642,12 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad, }static void +iavf_hash_uninit_parser (struct iavf_adapter *ad) +{ +iavf_unregister_parser (&iavf_hash_parser, ad); +} + +void iavf_hash_uninit (struct iavf_adapter *ad) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);
@@ -1658,8 +1665,6 @@ iavf_hash_uninit(struct iavf_adapter *ad) rss_conf = &ad->dev_data->dev_conf.rx_adv_conf.rss_conf;if (iavf_rss_hash_set (ad, rss_conf->rss_hf, false))PMD_DRV_LOG (ERR ,"fail to delete default RSS" ); - -iavf_unregister_parser (&iavf_hash_parser, ad); } static void
drivers/net/intel/iavf/iavf_hash.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */
Signature · 1 line
2.47.3
PATCH v3 19/27 net/iavf: avoid rte malloc in RSS configuration
In reply to Anatoly BurakovCurrently, when configuring RSS (redirection table, lookup table, and hash key), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++-- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/iavf/iavf_ethdev.c +2 -2
@@ -1554,7 +1554,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1574,7 +1574,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =iavf_configure_rss_lut (adapter);if (ret)/* revert back */ rte_memcpy (vf->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1159,7 +1159,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_lut) + vf->vf_res->rss_lut_size -1 ; - rss_lut =rte_zmalloc ("rss_lut" , len,0 ); + rss_lut =calloc (1 , len);if (!rss_lut)return -ENOMEM ;
@@ -1178,7 +1178,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_LUT" ); -rte_free (rss_lut); +free (rss_lut);return err; }
@@ -1191,7 +1191,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_key) + vf->vf_res->rss_key_size -1 ; - rss_key =rte_zmalloc ("rss_key" , len,0 ); + rss_key =calloc (1 , len);if (!rss_key)return -ENOMEM ;
@@ -1210,7 +1210,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_KEY" ); -rte_free (rss_key); +free (rss_key);return err; }
Signature · 1 line
2.47.3
PATCH v3 20/27 net/iavf: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +2 -2
@@ -1402,7 +1402,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) } } - list =rte_zmalloc ("iavf_del_mac_buffer" , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return ;
@@ -1434,7 +1434,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list); begin = next_begin; }while (begin <IAVF_NUM_MACADDR_MAX ); }
Signature · 1 line
2.47.3
PATCH v3 21/27 net/iavf: avoid rte malloc in IPsec operations
In reply to Anatoly BurakovCurrently, when performing IPsec security association operations and retrieving device capabilities, we are using rte_malloc followed by immediate rte_free. This is not needed as these structures are only used temporarily, so replace it with stack-allocated structures for small fixed-size messages and regular malloc/free for variable-sized buffers.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 58 ++++++++-------------- 1 file changed, 21 insertions(+), 37 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +21 -37
@@ -3,6 +3,7 @@*/ #include <stdalign.h> +#include <stdlib.h> #include <rte_cryptodev.h> #include <rte_ethdev.h>
@@ -899,29 +900,18 @@ static uint32_t iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_destroy sa_destroy; + } req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } resp; +struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_destroy ); - - request =rte_malloc ("iavf-sa-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - - response =rte_malloc ("iavf-sa-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -939,10 +929,10 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (req), + (uint8_t *)response,sizeof (resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -957,10 +947,6 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, response->ipsec_data.ipsec_status->status) rc = -EFAULT ; -update_cleanup: -rte_free (response); -rte_free (request); -return rc; }
@@ -1113,7 +1099,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-capability-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1121,8 +1107,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-capability-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1148,8 +1133,8 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,memcpy (capability, response->ipsec_data.ipsec_cap,sizeof (*capability)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
@@ -1538,7 +1523,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-status-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1546,8 +1531,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-status-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1573,8 +1557,8 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,memcpy (status, response->ipsec_data.ipsec_status,sizeof (*status)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
Signature · 1 line
2.47.3
PATCH v3 22/27 net/iavf: avoid rte malloc in queue operations
In reply to Anatoly BurakovCurrently, when enabling, disabling, or switching queues, we are using rte_malloc followed by an immediate rte_free. This is not needed as these structures are not being stored anywhere, so replace them with stack allocation or malloc/free where appropriate.
--- drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++++----------------- 1 file changed, 26 insertions(+), 39 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +26 -39
@@ -1020,19 +1020,15 @@ int iavf_enable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1048,7 +1044,7 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_ENABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1056,7 +1052,6 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_ENABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1064,19 +1059,15 @@ int iavf_disable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1092,7 +1083,7 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1100,7 +1091,6 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1109,17 +1099,15 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid, bool rx, bool on) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =1 ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1138,7 +1126,7 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,else args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1146,7 +1134,6 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,PMD_DRV_LOG (ERR ,"Failed to execute command of %s" , on ?"OP_ENABLE_QUEUES_V2" :"OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1229,7 +1216,7 @@ iavf_configure_queues(struct iavf_adapter *adapter, size =sizeof (*vc_config) +sizeof (vc_config->qpair[0 ]) * num_queue_pairs; - vc_config =rte_zmalloc ("cfg_queue" , size,0 ); + vc_config =calloc (1 , size);if (!vc_config)return -ENOMEM ;
@@ -1292,7 +1279,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,PMD_DRV_LOG (ERR ,"Failed to execute command of" " VIRTCHNL_OP_CONFIG_VSI_QUEUES" ); -rte_free (vc_config); +free (vc_config);return err; }
Signature · 1 line
2.47.3
PATCH v3 23/27 net/iavf: avoid rte malloc in irq map config
In reply to Anatoly BurakovCurrently, when configuring IRQ maps, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1295,7 +1295,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter) len =sizeof (struct virtchnl_irq_map_info ) +sizeof (struct virtchnl_vector_map ) * vf->nb_msix; - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1319,7 +1319,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter)if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_CONFIG_IRQ_MAP" ); -rte_free (map_info); +free (map_info);return err; }
@@ -1337,7 +1337,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num, len =sizeof (struct virtchnl_queue_vector_maps ) +sizeof (struct virtchnl_queue_vector ) * (num -1 ); - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1360,7 +1360,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_MAP_QUEUE_VECTOR" ); -rte_free (map_info); +free (map_info);return err; }
Signature · 1 line
2.47.3
PATCH v3 24/27 net/ice: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_ethdev.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -1338,7 +1338,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1358,7 +1358,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =ice_dcf_configure_rss_lut (hw);if (ret)/* revert back */ rte_memcpy (hw->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/ice/ice_ethdev.c +4 -4
@@ -5583,7 +5583,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,/* It MUST use the current LUT size to get the RSS lookup table, * otherwise if will fail with -100 error code. */ - lut =rte_zmalloc (NULL ,RTE_MAX (reta_size, lut_size),0 ); + lut =calloc (1 ,RTE_MAX (reta_size, lut_size));if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5607,7 +5607,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
@@ -5632,7 +5632,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc (NULL , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5650,7 +5650,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v3 25/27 net/ice: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular calloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -936,7 +936,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw, len =sizeof (struct virtchnl_ether_addr_list ); len +=sizeof (struct virtchnl_ether_addr ) * mc_addrs_num; - list =rte_zmalloc (NULL , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return -ENOMEM ;
@@ -961,7 +961,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list);return err; }
Signature · 1 line
2.47.3
PATCH v3 26/27 net/ice: avoid rte malloc in raw pattern parsing
In reply to Anatoly BurakovCurrently, when parsing raw flow patterns, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_fdir_filter.c | 14 +++++++------- drivers/net/intel/ice/ice_hash.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +7 -7
@@ -1879,13 +1879,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, pkt_len)return -rte_errno; - tmp_spec =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_spec =calloc (1 , pkt_len /2 );if (!tmp_spec)return -rte_errno; - tmp_mask =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_mask =calloc (1 , pkt_len /2 );if (!tmp_mask) { -rte_free (tmp_spec); +free (tmp_spec);return -rte_errno; }
@@ -1950,13 +1950,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, filter->parser_ena = true; -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);break ; raw_error: -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);return ret_val; }
drivers/net/intel/ice/ice_hash.c +5 -5
@@ -676,13 +676,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, pkt_len = spec_len /2 ; - pkt_buf =rte_zmalloc (NULL , pkt_len,0 ); + pkt_buf =calloc (1 , pkt_len);if (!pkt_buf)return -ENOMEM ; - msk_buf =rte_zmalloc (NULL , pkt_len,0 ); + msk_buf =calloc (1 , pkt_len);if (!msk_buf) { -rte_free (pkt_buf); +free (pkt_buf);return -ENOMEM ; }
@@ -733,8 +733,8 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,rte_memcpy (&meta->raw.prof, &prof,sizeof (prof)); free_mem: -rte_free (pkt_buf); -rte_free (msk_buf); +free (pkt_buf); +free (msk_buf);return ret; }
Signature · 1 line
2.47.3
PATCH v3 27/27 net/ice: avoid rte malloc in flow pattern match
In reply to Anatoly BurakovCurrently, when allocating buffers for pattern match items and flow item storage, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular calloc/free.
--- drivers/net/intel/ice/ice_acl_filter.c | 3 ++- drivers/net/intel/ice/ice_fdir_filter.c | 5 +++-- drivers/net/intel/ice/ice_generic_flow.c | 15 +++++++-------- drivers/net/intel/ice/ice_hash.c | 3 ++- drivers/net/intel/ice/ice_switch_filter.c | 5 +++-- 5 files changed, 17 insertions(+), 14 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +2 -1
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -1009,7 +1010,7 @@ ice_acl_parse(struct ice_adapter *ad, *meta = filter; error: -rte_free (item); +free (item);return ret; }
drivers/net/intel/ice/ice_fdir_filter.c +3 -2
@@ -3,6 +3,7 @@*/ #include <stdio.h> +#include <stdlib.h> #include <rte_flow.h> #include <rte_hash.h> #include <rte_hash_crc.h>
@@ -2504,11 +2505,11 @@ ice_fdir_parse(struct ice_adapter *ad,rte_free (filter->pkt_buf); } -rte_free (item); +free (item);return ret; error:rte_free (filter->pkt_buf); -rte_free (item); +free (item);return ret; }
drivers/net/intel/ice/ice_generic_flow.c +7 -8
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -2136,19 +2137,17 @@ ice_search_pattern_match_item(struct ice_adapter *ad, } item_num++; - items =rte_zmalloc ("ice_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); + items =calloc (item_num,sizeof (struct rte_flow_item ));if (!items) {rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ITEM_NUM ,NULL ,"No memory for PMD internal items." );return NULL ; } - pattern_match_item =rte_zmalloc ("ice_pattern_match_item" , -sizeof (struct ice_pattern_match_item ),0 ); + pattern_match_item =calloc (1 ,sizeof (struct ice_pattern_match_item ));if (!pattern_match_item) {rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL ,"Failed to allocate memory." ); -rte_free (items); +free (items);return NULL ; }
@@ -2167,7 +2166,7 @@ ice_search_pattern_match_item(struct ice_adapter *ad, pattern_match_item->pattern_list = array[i].pattern_list; pattern_match_item->meta = array[i].meta; -rte_free (items); +free (items);return pattern_match_item; } }
@@ -2175,8 +2174,8 @@ ice_search_pattern_match_item(struct ice_adapter *ad, unsupported:rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , pattern,"Unsupported pattern" ); -rte_free (items); -rte_free (pattern_match_item); +free (items); +free (pattern_match_item);return NULL ; }
drivers/net/intel/ice/ice_hash.c +2 -1
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h>
@@ -1211,7 +1212,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, *meta = rss_meta_ptr; elserte_free (rss_meta_ptr ); -rte_free (pattern_match_item); +free (pattern_match_item);return ret; }
drivers/net/intel/ice/ice_switch_filter.c +3 -2
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -1877,14 +1878,14 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,rte_free (sw_meta_ptr); } -rte_free (pattern_match_item); +free (pattern_match_item);return 0 ; error:rte_free (list);rte_free (sw_meta_ptr); -rte_free (pattern_match_item); +free (pattern_match_item);return -rte_errno; }
Signature · 1 line
2.47.3
Re: [PATCH v3 01/27] net/ixgbe: remove MAC type check macros
In reply to Anatoly BurakovQuoted 9 lines · Anatoly Burakov
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
Re: [PATCH v3 02/27] net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovQuoted 14 lines · Anatoly Burakov
The security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 ------ drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 --- drivers/net/intel/ixgbe/ixgbe_flow.c | 6 ----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 -------------------- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 -- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 ----- 6 files changed, 52 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
Re: [PATCH v3 03/27] net/ixgbe: split security and ntuple filters
In reply to Anatoly BurakovQuoted 98 lines · Anatoly Burakov
These filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
While we're at it, we're making checks more stringent (such as checking for NULL conf), and more type safe.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ixgbe/ixgbe_flow.c | 136 ++++++++++++++++++--------- 1 file changed, 91 insertions(+), 45 deletions(-)drivers/net/intel/ixgbe/ixgbe_flow.c +36
-35@@ -214,41 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -/** -* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY -*/ - act =next_no_void_action (actions,NULL ); -if (act->type ==RTE_FLOW_ACTION_TYPE_SECURITY ) { -const void *conf = act->conf; -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -/* get the IP pattern*/ - item =next_no_void_pattern (pattern,NULL ); -while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { -if (item->last || - item->type ==RTE_FLOW_ITEM_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"IP pattern missing." ); -return -rte_errno; - } - item =next_no_void_pattern (pattern, item); - } - - filter->proto =IPPROTO_ESP ; -return ixgbe_crypto_add_ingress_sa_from_flow (conf, item->spec, - item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ); - } -/* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );@@ -607,6 +572,81 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return 0 ; } +static int +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[],const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +const struct rte_flow_action_security *security; +const struct rte_flow_item *item; +const struct rte_flow_action *act; + +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; + +if (pattern ==NULL ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (actions ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (attr ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +return -rte_errno; + }
drivers/net/intel/ixgbe/ixgbe_flow.c cons_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 620
Quoted 10 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +10
-0+ +/* check if next non-void action is security */ + act =next_no_void_action (actions,NULL ); +if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + security = act->conf; +if (security ==NULL ) {
this looks like a bug fix. In a previous implementation it didn't check if act->conf is NULL and consequent calling for ixgbe_crypto_add_ingress_sa_from_flow() immediately dereference it. Probably it would be great to backport this as a fix.
Quoted 16 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +16
-0+return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"NULL security action config." ); + } +/* check if the next not void item is END */ + act =next_no_void_action (actions, act); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + +/* get the IP pattern*/ + item =next_no_void_pattern (pattern,NULL ); +while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) {
drivers/net/intel/ixgbe/ixgbe_flow.c cons_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 646
Quoted 10 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +10
-0+if (item->last || item->type ==RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"IP pattern missing." ); +return -rte_errno; + } + item =next_no_void_pattern (pattern, item); + } + + return ixgbe_crypto_add_ingress_sa_from_flow(security->security_session,
did you mean &security->security_session here?
drivers/net/intel/ixgbe/ixgbe_flow.c cons_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 647
Quoted 1 line
drivers/net/intel/ixgbe/ixgbe_flow.c +1
-0+ item->spec, item->type == RTE_FLOW_ITEM_TYPE_IPV6);
probably need to add check if item->spec is NULL
Quoted 5 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +2
-0+} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
<snip>
Signature · 2 lines
Regards, Vladimir
RE: [PATCH v3 06/27] net/i40e: use unsigned types for queue comparisons
In reply to Anatoly BurakovQuoted 23 lines
Currently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare
I40E_MAX_Q_PER_TCto an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence,i40e_align_floornow returns unsigned value as well - this
is correct, because nothing about that function implies signed usage being
a valid use case.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)drivers/net/intel/i40e/i40e_ethdev.c +0
-0
drivers/net/intel/i40e/i40e_ethdev.c i40e_pf_reset_rss_reta(struct i40e_pf *pf) · line 9061
Quoted 5 lines
drivers/net/intel/i40e/i40e_ethdev.c +1
-1@@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;
Why not just unsigned int? size_t seems weird when not counting bytes.
Or uint16_t, considering its use.
Quoted 34 lines
drivers/net/intel/i40e/i40e_ethdev.c +0
-0/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF drivers/net/intel/i40e/i40e_ethdev.h +3
-3@@ -24,7 +24,7 @@#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ -#define I40E_MAX_Q_PER_TC 64 +#define I40E_MAX_Q_PER_TC 64U#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024@@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw) hw->aq.asq_buf_size =I40E_AQ_BUF_SZ ; } -static inline int -i40e_align_floor (int n) +static inline uint32_t +i40e_align_floor (uint32_t n) {if (n ==0 )return 0 ;drivers/net/intel/i40e/i40e_hash.c +0
-0
drivers/net/intel/i40e/i40e_hash.c i40e_hash_parse_queues(const struct rte_eth_dev · line 953
Quoted 6 lines
drivers/net/intel/i40e/i40e_hash.c +1
-1@@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue;
Why not just unsigned int? size_t seems weird when not counting bytes.
Or uint16_t, like rss_act->queue[i].
But then I40E_MAX_Q_PER_TC should maybe also be defined as UINT16_C(64), and maybe more should be uint16_t too.
Quoted 15 lines
drivers/net/intel/i40e/i40e_hash.c +1
-2hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); if (!rss_act->queue_num ||@@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, max_queue =RTE_MIN (max_queue,I40E_MAX_Q_PER_TC );for (i =0 ; i < rss_act->queue_num; i++) { -if ((int )rss_act->queue[i] >= max_queue) +if (rss_act->queue[i] >= max_queue)break ; } --2.47.3
Re: [PATCH v3 03/27] net/ixgbe: split security and ntuple filters
In reply to Medvedkin, VladimirQuoted 139 lines · Vladimir
Quoted 100 lines · Anatoly Burakov
These filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
While we're at it, we're making checks more stringent (such as checking for NULL conf), and more type safe.
Signed-off-by Anatoly Burakov <[email protected]>---
drivers/net/intel/ixgbe/ixgbe_flow.c| 136 ++++++++++++++++++---------1 file changed, 91 insertions(+), 45 deletions(-)drivers/net/intel/ixgbe/ixgbe_flow.c +36
-35@@ -214,41 +214,6 @@ cons_parse_ntuple_filter(const structrte_flow_attr *attr, memset(ð_null, 0, sizeof(struct rte_flow_item_eth)); memset(&vlan_null, 0, sizeof(struct rte_flow_item_vlan)); - /** - * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY - */ - act = next_no_void_action(actions, NULL); - if (act->type == RTE_FLOW_ACTION_TYPE_SECURITY) { - const void *conf = act->conf; - /* check if the next not void item is END */ - act = next_no_void_action(actions, act); - if (act->type != RTE_FLOW_ACTION_TYPE_END) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, "Not supported action."); - return -rte_errno; - } - - /* get the IP pattern*/ - item = next_no_void_pattern(pattern, NULL); - while (item->type != RTE_FLOW_ITEM_TYPE_IPV4 && - item->type != RTE_FLOW_ITEM_TYPE_IPV6) { - if (item->last || - item->type == RTE_FLOW_ITEM_TYPE_END) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "IP pattern missing."); - return -rte_errno; - } - item = next_no_void_pattern(pattern, item); - } - - filter->proto = IPPROTO_ESP; - return ixgbe_crypto_add_ingress_sa_from_flow(conf, item->spec, - item->type == RTE_FLOW_ITEM_TYPE_IPV6); - } - /* the first not void item can be MAC or IPv4 */ item = next_no_void_pattern(pattern, NULL);@@ -607,6 +572,81 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return 0; } +static int +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], const structrte_flow_action actions[], + struct rte_flow_error *error) +{ + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data- >dev_private); + const struct rte_flow_action_security *security; + const struct rte_flow_item *item; + const struct rte_flow_action *act; + + if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) + return -ENOTSUP; + + if (pattern == NULL) { + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM, + NULL, "NULL pattern."); + return -rte_errno; + } + if (actions == NULL) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_NUM, + NULL, "NULL action."); + return -rte_errno; + } + if (attr == NULL) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR, + NULL, "NULL attribute."); + return -rte_errno; + }drivers/net/intel/ixgbe/ixgbe_flow.c cons_parse_ntuple_filter(const struct · line 623
Quoted 10 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +10
-0+ + /* check if next non-void action is security */ + act = next_no_void_action(actions, NULL); + if (act->type != RTE_FLOW_ACTION_TYPE_SECURITY) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, "Not supported action."); + } + security = act->conf; + if (security == NULL) {this looks like a bug fix. In a previous implementation it didn't check if
act->confis NULL and consequent calling forixgbe_crypto_add_ingress_sa_from_flow()immediately dereference it. Probably it would be great to backport this as a fix.Quoted 26 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +26
-0+ return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, act, + "NULL security action config."); + } + /* check if the next not void item is END */ + act = next_no_void_action(actions, act); + if (act->type != RTE_FLOW_ACTION_TYPE_END) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, "Not supported action."); + } + + /* get the IP pattern*/ + item = next_no_void_pattern(pattern, NULL); + while (item->type != RTE_FLOW_ITEM_TYPE_IPV4 && + item->type != RTE_FLOW_ITEM_TYPE_IPV6) { + if (item->last || item->type == RTE_FLOW_ITEM_TYPE_END) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, "IP pattern missing."); + return -rte_errno; + } + item = next_no_void_pattern(pattern, item); + } + + return ixgbe_crypto_add_ingress_sa_from_flow(security-
Quoted 2 lines
Quoted 1 line
Quoted 1 line
security_session,did you mean
&security->security_sessionhere?
No, this should be correct.
However, I now suspect the original code was a bug too.
Here's what the original code said:
``` return ixgbe_crypto_add_ingress_sa_from_flow(conf, ...); ```
The conf pointer points to action->conf, which in case of RTE_FLOW_ACTION_SECURITY translates to struct rte_flow_action_security structure.
However, the actual function we passed this to was doing this:
``` struct ixgbe_crypto_session *ic_session = (void *)(uintptr_t)((const struct rte_security_session *)sess)->driver_priv_data; ```
where sess is the conf, but it is treated as pointer to rte_security_session not rte_flow_action_security. So, this is actually a bug too, and it kinda feels like this never worked because this code has been here since the very beginning...
There's also no reason why *any* of this has to work with void pointers when this is the only user of this function, so I'll rewrite it and include it in the bugfix patchset, so that this patch arrives clean.
Quoted 2 lines
Quoted 1 line
+
item->spec,item->type==RTE_FLOW_ITEM_TYPE_IPV6);probably need to add check if
item->specis NULL
Yes, thanks for pointing that out. Will fix in bugfix patchset as well.
Quoted 7 lines
Quoted 5 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +2
-0+} +/* a specific function for ixgbe because the flags is specific */ static int
ixgbe_parse_ntuple_filter(structrte_eth_dev*dev,<snip>
Signature · 2 lines
Thanks, Anatoly
v4 cover Cleanups for ixgbe, i40e, iavf, and ice PMD's
In reply to Anatoly BurakovThis patchset is an assortment of cleanups for ixgbe, i40e, iavf, and ice PMD.
IXGBE:
- Remove unnecessary macros and #ifdef's
- Disentangle unrelated flow API code paths
I40E:
- Get rid of global variables and unnecessary allocations
- Reduce code duplication around default RSS keys
- Use more appropriate integer types and definitions
IAVF:
- Remove dead code
- Remove unnecessary allocations
- Separate RSS uninit from hash flow parser uninit
ICE:
- Remove unnecessary allocations
This is done in preparation for further rework.
Note that this patchset depends on driver bug fix patchset [1] (already integrated into next-net-intel).
[1] https://patches.dpdk.org/project/dpdk/list/?series=37350
v1 -> v2:
- Added more cleanups around rte_malloc usage
v2 -> v3:
- Reworded some commit messages
- Added a new patch for ICE
- Rebased on latest bug fix patches
v3 -> v4:
- Rebased on latest bugfix patchset
Anatoly Burakov (27):
net/ixgbe: remove MAC type check macros net/ixgbe: remove security-related ifdefery net/ixgbe: split security and ntuple filters net/i40e: get rid of global filter variables net/i40e: make default RSS key global net/i40e: use unsigned types for queue comparisons net/i40e: use proper flex len define net/i40e: remove global pattern variable net/i40e: avoid rte malloc in tunnel set net/i40e: avoid rte malloc in RSS RETA operations net/i40e: avoid rte malloc in MAC/VLAN filtering net/i40e: avoid rte malloc in VF resource queries net/i40e: avoid rte malloc in adminq operations net/i40e: avoid rte malloc in DDP package handling net/i40e: avoid rte malloc in DDP ptype handling net/iavf: remove remnants of pipeline mode net/iavf: avoid rte malloc in VF mailbox for IPsec net/iavf: decouple hash uninit from parser uninit net/iavf: avoid rte malloc in RSS configuration net/iavf: avoid rte malloc in MAC address operations net/iavf: avoid rte malloc in IPsec operations net/iavf: avoid rte malloc in queue operations net/iavf: avoid rte malloc in irq map config net/ice: avoid rte malloc in RSS RETA operations net/ice: avoid rte malloc in MAC address operations net/ice: avoid rte malloc in raw pattern parsing net/ice: avoid rte malloc in flow pattern match
drivers/net/intel/i40e/i40e_ethdev.c | 223 +++++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 24 +- drivers/net/intel/i40e/i40e_flow.c | 146 ++++++------ drivers/net/intel/i40e/i40e_hash.c | 27 ++- drivers/net/intel/i40e/i40e_hash.h | 3 + drivers/net/intel/i40e/i40e_pf.c | 26 +-- drivers/net/intel/i40e/rte_pmd_i40e.c | 59 ++--- drivers/net/intel/iavf/iavf_ethdev.c | 8 +- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 -- drivers/net/intel/iavf/iavf_hash.c | 14 +- drivers/net/intel/iavf/iavf_hash.h | 13 ++ drivers/net/intel/iavf/iavf_ipsec_crypto.c | 216 ++++++------------ drivers/net/intel/iavf/iavf_vchnl.c | 85 +++---- drivers/net/intel/ice/ice_acl_filter.c | 3 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 8 +- drivers/net/intel/ice/ice_ethdev.c | 8 +- drivers/net/intel/ice/ice_fdir_filter.c | 19 +- drivers/net/intel/ice/ice_generic_flow.c | 15 +- drivers/net/intel/ice/ice_hash.c | 13 +- drivers/net/intel/ice/ice_switch_filter.c | 5 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 - drivers/net/intel/ixgbe/ixgbe_ethdev.h | 16 -- drivers/net/intel/ixgbe/ixgbe_flow.c | 220 ++++++++++-------- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 --- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 - drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 - 28 files changed, 536 insertions(+), 674 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
Signature · 1 line
2.47.3
PATCH v4 1/27 net/ixgbe: remove MAC type check macros
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -12
@@ -137,18 +137,6 @@#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)#define IXGBE_MAX_L2_TN_FILTER_NUM 128 -#define MAC_TYPE_FILTER_SUP_EXT (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\ - return -ENOTSUP;\ -} while (0) - -#define MAC_TYPE_FILTER_SUP (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\ - (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\ - (type) != ixgbe_mac_X550EM_a && (type) != ixgbe_mac_E610)\ - return -ENOTSUP;\ -} while (0) -/* Link speed for X550 auto negotiation */ #define IXGBE_LINK_SPEED_X550_AUTONEG (IXGBE_LINK_SPEED_100_FULL | \ IXGBE_LINK_SPEED_1GB_FULL | \
drivers/net/intel/ixgbe/ixgbe_flow.c +17 -3
@@ -654,7 +654,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP_EXT (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540) +return -ENOTSUP ; ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error);
@@ -894,7 +896,13 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_ethertype_filter (attr, pattern, actions, filter, error);
@@ -1183,7 +1191,13 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev,int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -MAC_TYPE_FILTER_SUP (hw->mac.type); +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; ret =cons_parse_syn_filter (attr, pattern, actions, filter, error);
Signature · 1 line
2.47.3
PATCH v4 2/27 net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovThe security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
--- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 8 ------ drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 --- drivers/net/intel/ixgbe/ixgbe_flow.c | 6 ----- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 26 -------------------- drivers/net/intel/ixgbe/ixgbe_rxtx.h | 2 -- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 6 ----- 6 files changed, 52 deletions(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0 -8
@@ -32,9 +32,7 @@#include <rte_random.h> #include <dev_driver.h> #include <rte_hash_crc.h> -#ifdef RTE_LIB_SECURITY #include <rte_security_driver.h> -#endif #include <rte_os_shim.h> #include "ixgbe_logs.h"
@@ -1177,11 +1175,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)/* Unlock any pending hardware semaphore */ ixgbe_swfw_lock_reset (hw); -#ifdef RTE_LIB_SECURITY /* Initialize security_ctx only for primary process*/ if (ixgbe_ipsec_ctx_create (eth_dev))return -ENOMEM ; -#endif /* Initialize DCB configuration*/ memset (dcb_config,0 ,sizeof (struct ixgbe_dcb_config ));
@@ -1362,10 +1358,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)rte_free (eth_dev->data->hash_mac_addrs); eth_dev->data->hash_mac_addrs =NULL ; err_exit: -#ifdef RTE_LIB_SECURITY rte_free (eth_dev->security_ctx); eth_dev->security_ctx =NULL ; -#endif return ret; }
@@ -3148,10 +3142,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)/* Remove all Traffic Manager configuration */ ixgbe_tm_conf_uninit (dev); -#ifdef RTE_LIB_SECURITY rte_free (dev->security_ctx); dev->security_ctx =NULL ; -#endif return ret; }
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -4
@@ -14,9 +14,7 @@#include "base/ixgbe_dcb_82599.h" #include "base/ixgbe_dcb_82598.h" #include "ixgbe_bypass.h" -#ifdef RTE_LIB_SECURITY #include "ixgbe_ipsec.h" -#endif #include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h>
@@ -480,9 +478,7 @@ struct ixgbe_adapter {struct ixgbe_filter_info filter;struct ixgbe_l2_tn_info l2_tn;struct ixgbe_bw_conf bw_conf; -#ifdef RTE_LIB_SECURITY struct ixgbe_ipsec ipsec; -#endif bool rx_bulk_alloc_allowed;bool rx_vec_allowed;struct rte_timecounter systime_tc;
drivers/net/intel/ixgbe/ixgbe_flow.c +0 -6
@@ -214,7 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -#ifdef RTE_LIB_SECURITY /** * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY */
@@ -282,7 +281,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, session = RTE_CAST_PTR(struct rte_security_session *, sec_act->security_session);return ixgbe_crypto_add_ingress_sa_from_flow (session, &spec); } -#endif /* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -663,11 +661,9 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (filter->proto ==IPPROTO_ESP )return 0 ; -#endif /* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {
@@ -3107,7 +3103,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev, ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error); -#ifdef RTE_LIB_SECURITY /* ESP flow not really a flow*/ if (ntuple_filter.proto ==IPPROTO_ESP ) {if (ret !=0 )
@@ -3115,7 +3110,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev, flow->is_security = true;return flow; } -#endif if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -26
@@ -459,7 +459,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, seqnum_seed |= tx_offload.l2_len <<IXGBE_ADVTXD_TUNNEL_LEN ; } -#ifdef RTE_LIB_SECURITY if (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ) {union ixgbe_crypto_tx_desc_md *md = (union ixgbe_crypto_tx_desc_md *)mdata;
@@ -473,7 +472,6 @@ ixgbe_set_xmit_ctx(struct ci_tx_queue *txq, tx_offload_mask.sa_idx |= ~0 ; tx_offload_mask.sec_pad_len |= ~0 ; } -#endif txq->ctx_cache[ctx_idx].flags = ol_flags; txq->ctx_cache[ctx_idx].tx_offload.data[0] =
@@ -652,9 +650,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint32_t ctx =0 ;uint32_t new_ctx;union ixgbe_tx_offload tx_offload; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec; -#endif tx_offload.data[0 ] =0 ; tx_offload.data[1 ] =0 ;
@@ -682,9 +678,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,* are needed for offload functionality. */ ol_flags = tx_pkt->ol_flags; -#ifdef RTE_LIB_SECURITY use_ipsec = txq->using_ipsec && (ol_flags &RTE_MBUF_F_TX_SEC_OFFLOAD ); -#endif /* If hardware offload required */ tx_ol_req = ol_flags &IXGBE_TX_OFFLOAD_MASK ;
@@ -696,7 +690,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.tso_segsz = tx_pkt->tso_segsz; tx_offload.outer_l2_len = tx_pkt->outer_l2_len; tx_offload.outer_l3_len = tx_pkt->outer_l3_len; -#ifdef RTE_LIB_SECURITY if (use_ipsec) {union ixgbe_crypto_tx_desc_md *ipsec_mdata = (union ixgbe_crypto_tx_desc_md *)
@@ -704,7 +697,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, tx_offload.sa_idx = ipsec_mdata->sa_idx; tx_offload.sec_pad_len = ipsec_mdata->pad_len; } -#endif /* If new context need be built or reuse the exist ctx. */ ctx = what_advctx_update(txq, tx_ol_req,
@@ -896,10 +888,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, olinfo_status |= ctx <<IXGBE_ADVTXD_IDX_SHIFT ; } olinfo_status |= (pkt_len <<IXGBE_ADVTXD_PAYLEN_SHIFT ); -#ifdef RTE_LIB_SECURITY if (use_ipsec) olinfo_status |=IXGBE_ADVTXD_POPTS_IPSEC ; -#endif m_seg = tx_pkt; do {
@@ -1523,13 +1513,11 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status, uint16_t pkt_info, pkt_flags |=RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD ; } -#ifdef RTE_LIB_SECURITY if (rx_status &IXGBE_RXD_STAT_SECP ) { pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD ;if (rx_status &IXGBE_RXDADV_LNKSEC_ERROR_BAD_SIG ) pkt_flags |=RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED ; } -#endif return pkt_flags; }
@@ -2490,9 +2478,7 @@ ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) {struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;if (txq->offloads ==0 && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST ) { if (txq->tx_rs_thresh <= IXGBE_TX_MAX_FREE_BUF_SZ && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
@@ -2648,9 +2634,7 @@ ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ci_tx_queue *txq) {/* Use a simple Tx queue (no offloads, no multi segs) if possible */ if ((txq->offloads ==0 ) && -#ifdef RTE_LIB_SECURITY !(txq->using_ipsec) && -#endif (txq->tx_rs_thresh >=IXGBE_TX_MAX_BURST )) {PMD_INIT_LOG (DEBUG ,"Using simple tx code path" ); dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
@@ -2711,10 +2695,8 @@ ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) tx_offload_capa |=RTE_ETH_TX_OFFLOAD_SECURITY ; -#endif return tx_offload_capa; }
@@ -2884,10 +2866,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; -#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY ); -#endif /* * Modification to set VFTDT for virtual function if vf is detected
@@ -3171,10 +3151,8 @@ ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev) hw->mac.type == ixgbe_mac_E610) offloads |=RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM ; -#ifdef RTE_LIB_SECURITY if (dev->security_ctx) offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; -#endif return offloads; }
@@ -5102,10 +5080,8 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)struct ci_rx_queue *rxq = dev->data->rx_queues[i]; rxq->vector_rx = rx_using_sse; -#ifdef RTE_LIB_SECURITY rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ); -#endif } }
@@ -5611,7 +5587,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)ixgbe_setup_loopback_link_x540_x550 (hw, true); } -#ifdef RTE_LIB_SECURITY if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) || (dev->data->dev_conf.txmode.offloads &
@@ -5624,7 +5599,6 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)return ret; } } -#endif return 0 ; }
drivers/net/intel/ixgbe/ixgbe_rxtx.h +0 -2
@@ -99,11 +99,9 @@ union ixgbe_tx_offload {/* fields for TX offloading of tunnels */ uint64_t outer_l3_len:8; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:8; /**< Outer L2 (MAC) Hdr Length. */ -#ifdef RTE_LIB_SECURITY /* inline ipsec related*/ uint64_t sa_idx:8; /**< TX SA database entry index */ uint64_t sec_pad_len:4; /**< padding length */ -#endif }; };
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c +0 -6
@@ -21,7 +21,6 @@ ixgbe_rxq_rearm(struct ci_rx_queue *rxq)ci_rxq_rearm (rxq,CI_RX_VEC_LEVEL_SSE ); } -#ifdef RTE_LIB_SECURITY static inline void desc_to_olflags_v_ipsec (__m128i descs[4 ],struct rte_mbuf **rx_pkts) {
@@ -56,7 +55,6 @@ desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts) *rearm2 =_mm_extract_epi32 (rearm,2 ); *rearm3 =_mm_extract_epi32 (rearm,3 ); } -#endif static inline void desc_to_olflags_v(__m128i descs[4], __m128i mbuf_init, uint8_t vlan_flags,
@@ -265,9 +263,7 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,volatile union ixgbe_adv_rx_desc *rxdp;struct ci_rx_entry *sw_ring;uint16_t nb_pkts_recd; -#ifdef RTE_LIB_SECURITY uint8_t use_ipsec = rxq->using_ipsec; -#endif int pos;uint64_t var;__m128i shuf_msk;
@@ -444,10 +440,8 @@ _recv_raw_pkts_vec(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts,desc_to_olflags_v (descs, mbuf_init, vlan_flags, udp_p_flag, &rx_pkts[pos]); -#ifdef RTE_LIB_SECURITY if (unlikely (use_ipsec))desc_to_olflags_v_ipsec (descs, &rx_pkts[pos]); -#endif /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */ pkt_mb4 =_mm_add_epi16 (pkt_mb4, crc_adjust);
Signature · 1 line
2.47.3
PATCH v4 3/27 net/ixgbe: split security and ntuple filters
In reply to Anatoly BurakovThese filters are mashed together even though they almost do not share any code at all between each other. Separate security filter from ntuple filter and parse it separately.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++----------- 1 file changed, 114 insertions(+), 80 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +114 -80
@@ -214,74 +214,6 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));memset (&vlan_null,0 ,sizeof (struct rte_flow_item_vlan )); -/** -* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY -*/ - act =next_no_void_action (actions,NULL ); -if (act->type ==RTE_FLOW_ACTION_TYPE_SECURITY ) { -const void *conf = act->conf; -const struct rte_flow_action_security *sec_act; -struct rte_security_session *session; -struct ip_spec spec; - -if (conf ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION_CONF , - act,"NULL security conf." ); -return -rte_errno; - } -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -/* get the IP pattern*/ - item =next_no_void_pattern (pattern,NULL ); -while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { -if (item->last || - item->type ==RTE_FLOW_ITEM_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"IP pattern missing." ); -return -rte_errno; - } - item =next_no_void_pattern (pattern, item); - } -if (item->spec ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM_SPEC , item, -"NULL IP pattern." ); -return -rte_errno; - } - - filter->proto =IPPROTO_ESP ; - sec_act = (const struct rte_flow_action_security *)conf; - spec.is_ipv6 = item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ; -if (spec.is_ipv6) { -const struct rte_flow_item_ipv6 *ipv6 = item->spec; - spec.spec.ipv6 = *ipv6; - }else { -const struct rte_flow_item_ipv4 *ipv4 = item->spec; - spec.spec.ipv4 = *ipv4; - } - -/* -* we get pointer to security session from security action, -* which is const. however, we do need to act on the session, so -* either we do some kind of pointer based lookup to get session -* pointer internally (which quickly gets unwieldy for lots of -* flows case), or we simply cast away constness. -*/ - session = RTE_CAST_PTR(struct rte_security_session *, sec_act->security_session); -return ixgbe_crypto_add_ingress_sa_from_flow (session, &spec); - } -/* the first not void item can be MAC or IPv4 */ item =next_no_void_pattern (pattern,NULL );
@@ -640,6 +572,104 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,return 0 ; } +static int +ixgbe_parse_security_filter (struct rte_eth_dev *dev,const struct rte_flow_attr *attr, +const struct rte_flow_item pattern[],const struct rte_flow_action actions[], +struct rte_flow_error *error) +{ +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +const struct rte_flow_action_security *security; +struct rte_security_session *session; +const struct rte_flow_item *item; +const struct rte_flow_action *act; +struct ip_spec spec; + +if (hw->mac.type != ixgbe_mac_82599EB && + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610) +return -ENOTSUP ; + +if (pattern ==NULL ) { +rte_flow_error_set (error, +EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL ,"NULL pattern." ); +return -rte_errno; + } +if (actions ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_NUM , +NULL ,"NULL action." ); +return -rte_errno; + } +if (attr ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , +NULL ,"NULL attribute." ); +return -rte_errno; + } + +/* check if next non-void action is security */ + act =next_no_void_action (actions,NULL ); +if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + security = act->conf; +if (security ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"NULL security action config." ); + } +/* check if the next not void item is END */ + act =next_no_void_action (actions, act); +if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act,"Not supported action." ); + } + +/* get the IP pattern*/ + item =next_no_void_pattern (pattern,NULL ); +while (item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 ) { +if (item->last || item->type ==RTE_FLOW_ITEM_TYPE_END ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"IP pattern missing." ); +return -rte_errno; + } + item =next_no_void_pattern (pattern, item); + } +if (item->spec ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM_SPEC , item, +"NULL IP pattern." ); +return -rte_errno; + } + spec.is_ipv6 = item->type ==RTE_FLOW_ITEM_TYPE_IPV6 ; +if (spec.is_ipv6) { +const struct rte_flow_item_ipv6 *ipv6 = item->spec; + spec.spec.ipv6 = *ipv6; + }else { +const struct rte_flow_item_ipv4 *ipv4 = item->spec; + spec.spec.ipv4 = *ipv4; + } + +/* +* we get pointer to security session from security action, +* which is const. however, we do need to act on the session, so +* either we do some kind of pointer based lookup to get session +* pointer internally (which quickly gets unwieldy for lots of +* flows case), or we simply cast away constness. +*/ + session = RTE_CAST_PTR(struct rte_security_session *, security->security_session); +return ixgbe_crypto_add_ingress_sa_from_flow (session, &spec); +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -661,10 +691,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,if (ret)return ret; -/* ESP flow not really a flow*/ -if (filter->proto ==IPPROTO_ESP ) -return 0 ; -/* Ixgbe doesn't support tcp flags. */ if (filter->flags &RTE_NTUPLE_FLAGS_TCP_FLAG ) {memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter ));
@@ -3099,18 +3125,19 @@ ixgbe_flow_create(struct rte_eth_dev *dev,TAILQ_INSERT_TAIL (&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries); -memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); - ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, - actions, &ntuple_filter, error); - -/* ESP flow not really a flow*/ -if (ntuple_filter.proto ==IPPROTO_ESP ) { -if (ret !=0 ) - goto out; +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) { flow->is_security = true;return flow; } +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); + ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, + actions, &ntuple_filter, error); +if (!ret) { ret =ixgbe_add_del_ntuple_filter (dev, &ntuple_filter, TRUE);if (!ret) {
@@ -3334,6 +3361,13 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf rss_conf;int ret; +/** +* Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY +*/ + ret =ixgbe_parse_security_filter (dev, attr, pattern, actions, error); +if (!ret) +return 0 ; +memset (&ntuple_filter,0 ,sizeof (struct rte_eth_ntuple_filter )); ret =ixgbe_parse_ntuple_filter (dev, attr, pattern, actions, &ntuple_filter, error);
Signature · 1 line
2.47.3
PATCH v4 4/27 net/i40e: get rid of global filter variables
In reply to Anatoly BurakovCurrently, i40e driver relies on global state to work around the fact that rte_flow_validate() is being called directly from rte_flow_create(), and it not being possible to pass state between two functions. Fix that by making a small wrapper around validation that will create a dummy context.
Additionally, tunnel filter doesn't appear to be used by anything and so is omitted from the structure.
--- drivers/net/intel/i40e/i40e_ethdev.h | 16 ++-- drivers/net/intel/i40e/i40e_flow.c | 117 ++++++++++++++------------- 2 files changed, 68 insertions(+), 65 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +9 -7
@@ -1304,12 +1304,14 @@ struct i40e_vf_representor {extern const struct rte_flow_ops i40e_flow_ops; -union i40e_filter_t { -struct rte_eth_ethertype_filter ethertype_filter; -struct i40e_fdir_filter_conf fdir_filter; -struct rte_eth_tunnel_filter_conf tunnel_filter; -struct i40e_tunnel_filter_conf consistent_tunnel_filter; -struct i40e_rte_flow_rss_conf rss_conf; +struct i40e_filter_ctx { +union { +struct rte_eth_ethertype_filter ethertype_filter; +struct i40e_fdir_filter_conf fdir_filter; +struct i40e_tunnel_filter_conf consistent_tunnel_filter; +struct i40e_rte_flow_rss_conf rss_conf; + }; +enum rte_filter_type type; }; typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -1317,7 +1319,7 @@ typedef int (*parse_filter_t)(struct rte_eth_dev *dev,const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error, - union i40e_filter_t *filter); + struct i40e_filter_ctx *filter);struct i40e_valid_pattern {enum rte_flow_item_type *items;parse_filter_t parse_filter;
drivers/net/intel/i40e/i40e_flow.c +59 -58
351 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v4 5/27 net/i40e: make default RSS key global
In reply to Anatoly BurakovCurrently, there are multiple places where we need a default RSS key, but in each of those places we define it as a local variable. Make it global constant, and adjust all callers to use the global constant. When dealing with adminq, we cannot send down the constant because adminq commands do not guarantee const-ness, so copy RSS key into a local buffer before sending it down to hardware.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 ++++++++++------------ drivers/net/intel/i40e/i40e_hash.c | 23 +++++++++++++++++------ drivers/net/intel/i40e/i40e_hash.h | 3 +++ 3 files changed, 30 insertions(+), 18 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +10 -12
@@ -9082,23 +9082,21 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)int i40e_pf_reset_rss_key (struct i40e_pf *pf) { -const uint8_t key_len = (I40E_PFQF_HKEY_MAX_INDEX +1 ) * -sizeof (uint32_t ); -uint8_t *rss_key; +uint8_t key_buf[I40E_RSS_KEY_LEN ]; +const uint8_t *rss_key;/* Reset key */ rss_key = pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key; -if (!rss_key || - pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len < key_len) { -static uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; +if (!rss_key || pf->dev_data->dev_conf.rx_adv_conf.rss_conf.rss_key_len <sizeof (key_buf)) + rss_key = i40e_rss_key_default; - rss_key = (uint8_t *)rss_key_default; - } +/* +* adminq does not guarantee const-ness of RSS key once a command is sent down, so make a +* local copy. +*/ +memcpy (&key_buf, rss_key,sizeof (key_buf)); -return i40e_set_rss_key (pf->main_vsi, rss_key, key_len); +return i40e_set_rss_key (pf->main_vsi, key_buf,sizeof (key_buf)); } static int
drivers/net/intel/i40e/i40e_hash.c +17 -6
@@ -233,6 +233,22 @@ struct i40e_hash_match_pattern { RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) +const uint8_t i40e_rss_key_default[] = { +0x44 ,0x39 ,0x79 ,0x6b , +0xb5 ,0x4c ,0x50 ,0x23 , +0xb6 ,0x75 ,0xea ,0x5b , +0x12 ,0x4f ,0x9f ,0x30 , +0xb8 ,0xa2 ,0xc0 ,0x3d , +0xdf ,0xdc ,0x4d ,0x02 , +0xa0 ,0x8c ,0x9b ,0x33 , +0x4a ,0xf6 ,0x4a ,0x4c , +0x05 ,0xc6 ,0xfa ,0x34 , +0x39 ,0x58 ,0xd8 ,0x55 , +0x7d ,0x99 ,0x58 ,0x3a , +0xe1 ,0x38 ,0xc9 ,0x2e , +0x81 ,0x15 ,0x03 ,0x66 +}; +/* Current supported patterns and RSS types. * All items that have the same pattern types are together. */
@@ -910,17 +926,12 @@ i40e_hash_parse_key(const struct rte_flow_action_rss *rss_act,const uint8_t *key = rss_act->key;if (!key || rss_act->key_len !=sizeof (rss_conf->key)) { -const uint32_t rss_key_default[] = {0x6b793944 , -0x23504cb5 ,0x5bea75b6 ,0x309f4f12 ,0x3dc0a2b8 , -0x024ddcdf ,0x339b8ca0 ,0x4c4af64a ,0x34fac605 , -0x55d85839 ,0x3a58997d ,0x2ec938e1 ,0x66031581 }; -if (rss_act->key_len !=sizeof (rss_conf->key))PMD_DRV_LOG (WARNING ,"RSS key length invalid, must be %u bytes, now set key to default" , (uint32_t )sizeof (rss_conf->key)); -memcpy (rss_conf->key, rss_key_default,sizeof (rss_conf->key)); +memcpy (rss_conf->key, i40e_rss_key_default,sizeof (rss_conf->key)); }else {memcpy (rss_conf->key, key,sizeof (rss_conf->key)); }
drivers/net/intel/i40e/i40e_hash.h +3 -0
@@ -27,6 +27,9 @@ int i40e_hash_filter_destroy(struct i40e_pf *pf, const struct i40e_rss_filter *rss_filter);int i40e_hash_filter_flush (struct i40e_pf *pf); +#define I40E_RSS_KEY_LEN ((I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) +extern const uint8_t i40e_rss_key_default[I40E_RSS_KEY_LEN ]; + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH v4 6/27 net/i40e: use unsigned types for queue comparisons
In reply to Anatoly BurakovCurrently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare I40E_MAX_Q_PER_TC to an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence, i40e_align_floor now returns unsigned value as well - this is correct, because nothing about that function implies signed usage being a valid use case.
--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +1 -1
@@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
drivers/net/intel/i40e/i40e_ethdev.h +3 -3
@@ -24,7 +24,7 @@#define I40E_AQ_LEN 32#define I40E_AQ_BUF_SZ 4096/* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */ -#define I40E_MAX_Q_PER_TC 64 +#define I40E_MAX_Q_PER_TC 64U#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw) hw->aq.asq_buf_size =I40E_AQ_BUF_SZ ; } -static inline int -i40e_align_floor (int n) +static inline uint32_t +i40e_align_floor (uint32_t n) {if (n ==0 )return 0 ;
drivers/net/intel/i40e/i40e_hash.c +2 -2
@@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev,struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue; hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); if (!rss_act->queue_num ||
@@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev *dev, max_queue =RTE_MIN (max_queue,I40E_MAX_Q_PER_TC );for (i =0 ; i < rss_act->queue_num; i++) { -if ((int )rss_act->queue[i] >= max_queue) +if (rss_act->queue[i] >= max_queue)break ; }
Signature · 1 line
2.47.3
PATCH v4 7/27 net/i40e: use proper flex len define
In reply to Anatoly BurakovFor FDIR, we have byte arrays that are supposed to be limited to whatever the HW supports in terms of flex descriptor matching. However, in the structure definition, spec and mask bytes are using different array length defines, and the only reason why this works is because they evaluate to the same value.
Use the i40e-specific definition instead.
--- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -631,7 +631,7 @@ struct i40e_fdir_flex_pit {/* A structure used to contain extend input of flow */ struct i40e_fdir_flow_ext {uint16_t vlan_tci; -uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN ]; +uint8_t flexbytes[I40E_FDIR_MAX_FLEX_LEN ];/* It is filled by the flexible payload to match. */ uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN ];uint8_t raw_id;
Signature · 1 line
2.47.3
PATCH v4 8/27 net/i40e: remove global pattern variable
In reply to Anatoly BurakovWhen parsing flow patterns, current code cleans up the pattern list by removing void flow items, and copies the patterns into an array. That array, when dealing with under 32 flow items, is allocated on the stack, but when the pattern is big enough, a new list is dynamically allocated. This allocated list is a global variable, and is allocated using rte_zmalloc call which seems like overkill for this use case.
Remove the global variable, and replace the split behavior with unconditional allocation.
--- drivers/net/intel/i40e/i40e_flow.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +9 -20
@@ -145,9 +145,6 @@ const struct rte_flow_ops i40e_flow_ops = { .query = i40e_flow_query, }; -/* internal pattern w/o VOID items */ -struct rte_flow_item g_items[32 ]; -/* Pattern matched ethertype filter */ static enum rte_flow_item_type pattern_ethertype[] = {RTE_FLOW_ITEM_TYPE_ETH ,
@@ -3837,19 +3834,13 @@ i40e_flow_check(struct rte_eth_dev *dev, i++; } item_num++; - -if (item_num <=ARRAY_SIZE (g_items)) { - items = g_items; - }else { - items =rte_zmalloc ("i40e_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); -if (!items) { -rte_flow_error_set (error,ENOMEM , -RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL , -"No memory for PMD internal items." ); -return -ENOMEM ; - } + items =calloc (item_num,sizeof (struct rte_flow_item )); +if (items ==NULL ) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_ITEM_NUM , +NULL , +"No memory for PMD internal items." ); +return -ENOMEM ; }i40e_pattern_skip_void_item (items, pattern);
@@ -3862,8 +3853,7 @@ i40e_flow_check(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ITEM , pattern, "Unsupported pattern"); -if (items != g_items) -rte_free (items); +free (items);return -rte_errno; }
@@ -3873,8 +3863,7 @@ i40e_flow_check(struct rte_eth_dev *dev, flag = true; }while ((ret <0 ) && (i <RTE_DIM (i40e_supported_patterns))); -if (items != g_items) -rte_free (items); +free (items);return ret; }
Signature · 1 line
2.47.3
PATCH v4 9/27 net/i40e: avoid rte malloc in tunnel set
In reply to Anatoly BurakovCurrently, when setting tunnel configuration, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++--------------- 1 file changed, 53 insertions(+), 71 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +53 -71
@@ -8511,38 +8511,27 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,struct i40e_pf_vf *vf =NULL ;struct i40e_hw *hw =I40E_PF_TO_HW (pf);struct i40e_vsi *vsi; -struct i40e_aqc_cloud_filters_element_bb *cld_filter; -struct i40e_aqc_cloud_filters_element_bb *pfilter; +struct i40e_aqc_cloud_filters_element_bb cld_filter = {0 };struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; -struct i40e_tunnel_filter *tunnel, *node; +struct i40e_tunnel_filter *node;struct i40e_tunnel_filter check_filter;/* Check if filter exists */ uint32_t teid_le;bool big_buffer =0 ; - cld_filter =rte_zmalloc ("tunnel_filter" , -sizeof (struct i40e_aqc_add_rm_cloud_filt_elem_ext ), -0 ); - -if (cld_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -return -ENOMEM ; - } - pfilter = cld_filter; -rte_ether_addr_copy (&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&pfilter->element.outer_mac); + (struct rte_ether_addr *)&cld_filter.element.outer_mac);rte_ether_addr_copy (&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&pfilter->element.inner_mac); + (struct rte_ether_addr *)&cld_filter.element.inner_mac); - pfilter->element.inner_vlan = + cld_filter.element.inner_vlan =rte_cpu_to_le_16 (tunnel_filter->inner_vlan);if (tunnel_filter->ip_type ==I40E_TUNNEL_IPTYPE_IPV4 ) { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV4 ; ipv4_addr =rte_be_to_cpu_32 (tunnel_filter->ip_addr.ipv4_addr); ipv4_addr_le =rte_cpu_to_le_32 (ipv4_addr); -rte_memcpy (&pfilter->element.ipaddr.v4.data, +rte_memcpy (&cld_filter.element.ipaddr.v4.data, &ipv4_addr_le, -sizeof (pfilter->element.ipaddr.v4.data)); +sizeof (cld_filter.element.ipaddr.v4.data)); }else { ip_type =I40E_AQC_ADD_CLOUD_FLAGS_IPV6 ;for (i =0 ; i <4 ; i++) {
@@ -8550,9 +8539,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,rte_cpu_to_le_32 (rte_be_to_cpu_32 ( tunnel_filter->ip_addr.ipv6_addr[i])); } -rte_memcpy (&pfilter->element.ipaddr.v6.data, +rte_memcpy (&cld_filter.element.ipaddr.v6.data, &convert_ipv6, -sizeof (pfilter->element.ipaddr.v6.data)); +sizeof (cld_filter.element.ipaddr.v6.data)); }/* check tunneled type */
@@ -8573,11 +8562,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x40 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP ;
@@ -8589,11 +8578,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->mpls_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = teid_le >>4 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = (teid_le &0xF ) <<12 ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] =0x0 ; big_buffer =1 ; tun_type =I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE ;
@@ -8605,11 +8594,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8620,11 +8609,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->gtp_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0 ] = (teid_le >>16 ) &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1 ] = teid_le &0xFFFF ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2 ] =0x0 ; big_buffer =1 ;break ;
@@ -8641,8 +8630,8 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,* Big Buffer should be set, see changes in * i40e_aq_add_cloud_filters */ - pfilter->general_fields[0 ] = tunnel_filter->inner_vlan; - pfilter->general_fields[1 ] = tunnel_filter->outer_vlan; + cld_filter.general_fields[0 ] = tunnel_filter->inner_vlan; + cld_filter.general_fields[1 ] = tunnel_filter->outer_vlan; big_buffer =1 ;break ;case I40E_CLOUD_TYPE_UDP :
@@ -8657,20 +8646,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->sport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }else {
@@ -8682,20 +8671,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, pf->dport_replace_flag =1 ; } teid_le =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0 ] =I40E_DIRECTION_INGRESS_KEY ;if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_UDP ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP ) - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_TCP ;else - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1 ] =I40E_TR_L4_TYPE_SCTP ; - pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2 ] = (teid_le >>16 ) &0xFFFF ; big_buffer =1 ; }
@@ -8704,48 +8693,46 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,default :/* Other tunnel types is not supported. */ PMD_DRV_LOG (ERR ,"tunnel type is not supported." ); -rte_free (cld_filter);return -EINVAL ; }if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPC ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_GTPU ) - pfilter->element.flags = + cld_filter.element.flags =I40E_AQC_ADD_CLOUD_FILTER_0X12 ;else if (tunnel_filter->tunnel_type ==I40E_TUNNEL_TYPE_QINQ ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ;else if (tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_UDP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_TCP || tunnel_filter->tunnel_type ==I40E_CLOUD_TYPE_SCTP ) {if (tunnel_filter->l4_port_type ==I40E_L4_PORT_TYPE_SRC ) - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X11 ;else - pfilter->element.flags |= + cld_filter.element.flags |=I40E_AQC_ADD_CLOUD_FILTER_0X10 ; }else { val =i40e_dev_get_filter_type (tunnel_filter->filter_type, - &pfilter->element.flags); + &cld_filter.element.flags);if (val <0 ) { -rte_free (cld_filter);return -EINVAL ; } } - pfilter->element.flags |=rte_cpu_to_le_16 ( -I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | - ip_type | (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); - pfilter->element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); - pfilter->element.queue_number = + cld_filter.element.flags |= +rte_cpu_to_le_16 (I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type | + (tun_type <<I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT )); + cld_filter.element.tenant_id =rte_cpu_to_le_32 (tunnel_filter->tenant_id); + cld_filter.element.queue_number =rte_cpu_to_le_16 (tunnel_filter->queue_id);if (!tunnel_filter->is_to_vf)
@@ -8753,7 +8740,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,else {if (tunnel_filter->vf_id >= pf->vf_num) {PMD_DRV_LOG (ERR ,"Invalid argument." ); -rte_free (cld_filter);return -EINVAL ; } vf = &pf->vfs[tunnel_filter->vf_id];
@@ -8762,38 +8748,36 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,/* Check if there is the filter in SW list */ memset (&check_filter,0 ,sizeof (check_filter)); -i40e_tunnel_filter_convert (cld_filter, &check_filter); +i40e_tunnel_filter_convert (&cld_filter, &check_filter); check_filter.is_to_vf = tunnel_filter->is_to_vf; check_filter.vf_id = tunnel_filter->vf_id; node =i40e_sw_tunnel_filter_lookup (tunnel_rule, &check_filter.input);if (add && node) {PMD_DRV_LOG (ERR ,"Conflict with existing tunnel rules!" ); -rte_free (cld_filter);return -EINVAL ; }if (!add && !node) {PMD_DRV_LOG (ERR ,"There's no corresponding tunnel filter!" ); -rte_free (cld_filter);return -EINVAL ; }if (add) { +struct i40e_tunnel_filter *tunnel; +if (big_buffer) ret =i40e_aq_add_cloud_filters_bb (hw, - vsi->seid, cld_filter,1 ); + vsi->seid, &cld_filter,1 );else ret =i40e_aq_add_cloud_filters (hw, - vsi->seid, &cld_filter->element,1 ); + vsi->seid, &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to add a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } tunnel =rte_zmalloc ("tunnel_filter" ,sizeof (*tunnel),0 );if (tunnel ==NULL ) {PMD_DRV_LOG (ERR ,"Failed to alloc memory." ); -rte_free (cld_filter);return -ENOMEM ; }
@@ -8804,19 +8788,17 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf, }else {if (big_buffer) ret =i40e_aq_rem_cloud_filters_bb ( - hw, vsi->seid, cld_filter,1 ); + hw, vsi->seid, &cld_filter,1 );else ret =i40e_aq_rem_cloud_filters (hw, vsi->seid, - &cld_filter->element,1 ); + &cld_filter.element,1 );if (ret <0 ) {PMD_DRV_LOG (ERR ,"Failed to delete a tunnel filter." ); -rte_free (cld_filter);return -ENOTSUP ; } ret =i40e_sw_tunnel_filter_del (pf, &node->input); } -rte_free (cld_filter);return ret; }
Signature · 1 line
2.47.3
PATCH v4 10/27 net/i40e: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +4 -4
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4649,7 +4649,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev, pf->adapter->rss_reta_updated =1 ; out: -rte_free (lut); +free (lut);return ret; }
@@ -4673,7 +4673,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -4690,7 +4690,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v4 11/27 net/i40e: avoid rte malloc in MAC/VLAN filtering
In reply to Anatoly BurakovCurrently, when adding, removing, or configuring MAC and VLAN filters, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 38 +++++++++++++-------------- drivers/net/intel/i40e/rte_pmd_i40e.c | 16 +++++------ 2 files changed, 26 insertions(+), 28 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +18 -20
@@ -4165,8 +4165,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { i =0 ; num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -4206,7 +4205,7 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)if (ret)PMD_DRV_LOG (ERR ,"i40e vsi add mac fail." ); } -rte_free (mac_filter); +free (mac_filter); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -6231,8 +6230,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); + mac_filter =calloc (num,sizeof (*mac_filter));if (mac_filter ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -6264,7 +6262,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) } DONE: -rte_free (mac_filter); +free (mac_filter);return ret; }
@@ -7154,7 +7152,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_add" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7207,7 +7205,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7230,7 +7228,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, ele_num = hw->aq.asq_buf_size /sizeof (*req_list); ele_buff_size = hw->aq.asq_buf_size; - req_list =rte_zmalloc ("macvlan_remove" , ele_buff_size,0 ); + req_list =calloc (1 , ele_buff_size);if (req_list ==NULL ) {PMD_DRV_LOG (ERR ,"Fail to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7286,7 +7284,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, }while (num < total); DONE: -rte_free (req_list); +free (req_list);return ret; }
@@ -7455,7 +7453,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)else num = vsi->mac_num * vsi->vlan_num; - mv_f =rte_zmalloc ("macvlan_data" , num *sizeof (*mv_f),0 ); + mv_f =calloc (num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7484,7 +7482,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi) ret =i40e_remove_macvlan_filters (vsi, mv_f, num); DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7510,7 +7508,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7532,7 +7530,7 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num++; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7561,7 +7559,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)return I40E_ERR_PARAM ; } - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); + mv_f =calloc (mac_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );
@@ -7594,7 +7592,7 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan) vsi->vlan_num--; ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7626,7 +7624,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) mac_filter->filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7665,7 +7663,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
@@ -7696,7 +7694,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (mv_f ==NULL ) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -7725,7 +7723,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr) ret =I40E_SUCCESS ; DONE: -rte_free (mv_f); +free (mv_f);return ret; }
drivers/net/intel/i40e/rte_pmd_i40e.c +8 -8
@@ -233,7 +233,7 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -250,18 +250,18 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_remove_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
@@ -294,7 +294,7 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) f->mac_info.filter_type == I40E_MAC_HASH_MATCH) vlan_num =1 ; - mv_f =rte_zmalloc ("macvlan_data" , vlan_num *sizeof (*mv_f),0 ); + mv_f =calloc (vlan_num,sizeof (*mv_f));if (!mv_f) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return I40E_ERR_NO_MEMORY ;
@@ -312,18 +312,18 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi) ret =i40e_find_all_vlan_for_mac (vsi, mv_f, vlan_num, &f->mac_info.mac_addr);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } } ret =i40e_add_macvlan_filters (vsi, mv_f, vlan_num);if (ret !=I40E_SUCCESS ) { -rte_free (mv_f); +free (mv_f);return ret; } -rte_free (mv_f); +free (mv_f); ret =I40E_SUCCESS ; }
Signature · 1 line
2.47.3
PATCH v4 12/27 net/i40e: avoid rte malloc in VF resource queries
In reply to Anatoly BurakovCurrently, when responding to VF resource queries, we are dynamically allocating a temporary buffer with rte_zmalloc followed by an immediate rte_free. This is not needed as the response is only used temporarily, so replace it with a stack-allocated structure (the allocation is fixed in size and pretty small).
--- drivers/net/intel/i40e/i40e_pf.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/net/intel/i40e/i40e_pf.c +7 -19
@@ -309,9 +309,14 @@ static int i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg, bool b_op) { - struct virtchnl_vf_resource *vf_res = NULL; +/* only have 1 VSI by default */ +struct { +struct virtchnl_vf_resource vf_res; +struct virtchnl_vsi_resource vsi_res; + } res = {0 }; +struct virtchnl_vf_resource *vf_res = &res.vf_res; +uint32_t len =sizeof (res);struct i40e_hw *hw =I40E_PF_TO_HW (vf->pf); -uint32_t len =0 ;uint64_t default_hena =I40E_RSS_HENA_ALL ;int ret =I40E_SUCCESS ;
@@ -322,20 +327,6 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,return ret; } -/* only have 1 VSI by default */ - len =sizeof (struct virtchnl_vf_resource ) + -I40E_DEFAULT_VF_VSI_NUM * -sizeof (struct virtchnl_vsi_resource ); - - vf_res =rte_zmalloc ("i40e_vf_res" , len,0 ); -if (vf_res ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate mem" ); - ret =I40E_ERR_NO_MEMORY ; - vf_res =NULL ; - len =0 ; - goto send_msg; - } -if (VF_IS_V10 (&vf->version))/* doesn't support offload negotiate */ vf->request_caps =VIRTCHNL_VF_OFFLOAD_L2 |VIRTCHNL_VF_OFFLOAD_VLAN ;
@@ -377,11 +368,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,rte_ether_addr_copy (&vf->mac_addr, (struct rte_ether_addr *)vf_res->vsi_res[0 ].default_mac_addr); -send_msg:i40e_pf_host_send_msg_to_vf (vf,VIRTCHNL_OP_GET_VF_RESOURCES , ret, (uint8_t *)vf_res, len); -rte_free (vf_res); -return ret; }
Signature · 1 line
2.47.3
PATCH v4 13/27 net/i40e: avoid rte malloc in adminq operations
In reply to Anatoly BurakovCurrently, when processing admin queue messages, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as the message buffer is only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +2 -2
@@ -6896,7 +6896,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)int ret; info.buf_len =I40E_AQ_BUF_SZ ; - info.msg_buf =rte_zmalloc ("msg_buffer" , info.buf_len,0 ); + info.msg_buf =calloc (1 , info.buf_len);if (!info.msg_buf) {PMD_DRV_LOG (ERR ,"Failed to allocate mem" );return ;
@@ -6936,7 +6936,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)break ; } } -rte_free (info.msg_buf); +free (info.msg_buf); } static void
Signature · 1 line
2.47.3
PATCH v4 14/27 net/i40e: avoid rte malloc in DDP package handling
In reply to Anatoly BurakovCurrently, when processing Dynamic Driver Profile (DDP) packages and checking profile information, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily, so replace it with stack-allocated structures or regular malloc/free where appropriate.
--- drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++++++------------------ 1 file changed, 14 insertions(+), 29 deletions(-)
drivers/net/intel/i40e/rte_pmd_i40e.c +14 -29
@@ -1569,9 +1569,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)PMD_DRV_LOG (INFO ,"Read-only profile." );return 0 ; } - buff =rte_zmalloc ("pinfo_list" , - (I40E_PROFILE_INFO_SIZE *I40E_MAX_PROFILE_NUM +4 ), -0 ); + buff =calloc (I40E_MAX_PROFILE_NUM +4 ,I40E_PROFILE_INFO_SIZE );if (!buff) {PMD_DRV_LOG (ERR ,"failed to allocate memory" );return -1 ;
@@ -1583,7 +1581,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) 0, NULL);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get profile info list." ); -rte_free (buff); +free (buff);return -1 ; } p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1591,20 +1589,20 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) p = &p_list->p_info[i];if (pinfo->track_id == p->track_id) {PMD_DRV_LOG (INFO ,"Profile exists." ); -rte_free (buff); +free (buff);return 1 ; } }/* profile with group id 0xff is compatible with any other profile */ if ((pinfo->track_id & group_mask) == group_mask) { -rte_free (buff); +free (buff);return 0 ; }for (i =0 ; i < p_list->p_count; i++) { p = &p_list->p_info[i];if ((p->track_id & group_mask) ==0 ) {PMD_DRV_LOG (INFO ,"Profile of the group 0 exists." ); -rte_free (buff); +free (buff);return 2 ; } }
@@ -1615,12 +1613,12 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)if ((pinfo->track_id & group_mask) != (p->track_id & group_mask)) {PMD_DRV_LOG (INFO ,"Profile of different group exists." ); -rte_free (buff); +free (buff);return 3 ; } } -rte_free (buff); +free (buff);return 0 ; }
@@ -1636,7 +1634,10 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,struct i40e_generic_seg_header *profile_seg_hdr;struct i40e_generic_seg_header *metadata_seg_hdr;uint32_t track_id; -uint8_t *profile_info_sec; +struct { +struct i40e_profile_section_header sec; +struct i40e_profile_info info; + } profile_info_sec = {0 };int is_exist;enum i40e_status_code status =I40E_SUCCESS ;static const uint32_t type_mask =0xff000000 ;
@@ -1701,26 +1702,15 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,return -EINVAL ; } - profile_info_sec =rte_zmalloc ( -"i40e_profile_info" , -sizeof (struct i40e_profile_section_header ) + -sizeof (struct i40e_profile_info ), -0 ); -if (!profile_info_sec) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -return -EINVAL ; - } -/* Check if the profile already loaded */ i40e_generate_profile_info_sec ( ((struct i40e_profile_segment *)profile_seg_hdr)->name, &((struct i40e_profile_segment *)profile_seg_hdr)->version, - track_id, profile_info_sec, + track_id, (uint8_t * )&profile_info_sec, op ==RTE_PMD_I40E_PKG_OP_WR_ADD ); - is_exist =i40e_check_profile_info (port, profile_info_sec); + is_exist =i40e_check_profile_info (port, (uint8_t * )&profile_info_sec);if (is_exist <0 ) {PMD_DRV_LOG (ERR ,"Failed to check profile." ); -rte_free (profile_info_sec);return -EINVAL ; }
@@ -1733,13 +1723,11 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,else if (is_exist ==3 )PMD_DRV_LOG (ERR ,"Profile of different group already exists" );i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return -EEXIST ; } }else if (op ==RTE_PMD_I40E_PKG_OP_WR_DEL ) {if (is_exist !=1 ) {PMD_DRV_LOG (ERR ,"Profile does not exist." ); -rte_free (profile_info_sec);return -EACCES ; } }
@@ -1751,7 +1739,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, track_id);if (status) {PMD_DRV_LOG (ERR ,"Failed to write profile for delete." ); -rte_free (profile_info_sec);return status; } }else {
@@ -1764,14 +1751,13 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,PMD_DRV_LOG (ERR ,"Failed to write profile for add." ); else PMD_DRV_LOG(ERR, "Failed to write profile."); -rte_free (profile_info_sec);return status; } }if (track_id && (op !=RTE_PMD_I40E_PKG_OP_WR_ONLY )) {/* Modify loaded profiles info list */ - status =i40e_add_rm_profile_info (hw, profile_info_sec); + status =i40e_add_rm_profile_info (hw, (uint8_t * )&profile_info_sec);if (status) {if (op ==RTE_PMD_I40E_PKG_OP_WR_ADD )PMD_DRV_LOG (ERR ,"Failed to add profile to info list." );
@@ -1784,7 +1770,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff, op == RTE_PMD_I40E_PKG_OP_WR_DEL)i40e_update_customized_info (dev, buff, size, op); -rte_free (profile_info_sec);return status; }
Signature · 1 line
2.47.3
PATCH v4 15/27 net/i40e: avoid rte malloc in DDP ptype handling
In reply to Anatoly BurakovCurrently, when updating customized protocol and packet type information via DDP packages, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular malloc/free.
--- drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +12 -13
@@ -11787,7 +11787,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = pctype_num *sizeof (struct rte_pmd_i40e_proto_info ); - pctype =rte_zmalloc ("new_pctype" , buff_size,0 ); + pctype =calloc (pctype_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!pctype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11798,7 +11798,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get pctype list" ); -rte_free (pctype); +free (pctype);return -1 ; }
@@ -11879,7 +11879,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype); +free (pctype);return 0 ; }
@@ -11925,7 +11925,7 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_info ); - ptype =rte_zmalloc ("new_ptype" , buff_size,0 ); + ptype =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_info ));if (!ptype) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return -1 ;
@@ -11937,15 +11937,14 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get ptype list" ); -rte_free (ptype); +free (ptype);return ret; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_mapping ); - ptype_mapping =rte_zmalloc ("ptype_mapping" , buff_size,0 ); + ptype_mapping =calloc (ptype_num,sizeof (struct rte_pmd_i40e_ptype_mapping ));if (!ptype_mapping) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -rte_free (ptype); +free (ptype);return -1 ; }
@@ -12083,8 +12082,8 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (ERR ,"Failed to update ptype mapping table." ); -rte_free (ptype_mapping); -rte_free (ptype); +free (ptype_mapping); +free (ptype);return ret; }
@@ -12119,7 +12118,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, } buff_size = proto_num *sizeof (struct rte_pmd_i40e_proto_info ); - proto =rte_zmalloc ("new_proto" , buff_size,0 ); + proto =calloc (proto_num,sizeof (struct rte_pmd_i40e_proto_info ));if (!proto) {PMD_DRV_LOG (ERR ,"Failed to allocate memory" );return ;
@@ -12131,7 +12130,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg, RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);if (ret) {PMD_DRV_LOG (ERR ,"Failed to get protocol list" ); -rte_free (proto); +free (proto);return ; }
@@ -12169,7 +12168,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,if (ret)PMD_DRV_LOG (INFO ,"No ptype is updated." ); -rte_free (proto); +free (proto); }/* Create a QinQ cloud filter
Signature · 1 line
2.47.3
PATCH v4 16/27 net/iavf: remove remnants of pipeline mode
In reply to Anatoly BurakovWhen pipeline mode was removed, some of the things used by pipelines were left in the code. Remove them as they are unused.
--- drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.h | 15 --------------- drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_ipsec_crypto.c | 1 - 5 files changed, 19 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +0 -1
@@ -1632,7 +1632,6 @@ static struct iavf_flow_parser iavf_fdir_parser = { .array = iavf_fdir_pattern, .array_len = RTE_DIM(iavf_fdir_pattern), .parse_pattern_action = iavf_fdir_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fdir_engine_register)
drivers/net/intel/iavf/iavf_fsub.c +0 -1
@@ -814,7 +814,6 @@ iavf_flow_parser iavf_fsub_parser = { .array = iavf_fsub_pattern_list, .array_len = RTE_DIM(iavf_fsub_pattern_list), .parse_pattern_action = iavf_fsub_parse, - .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, };RTE_INIT (iavf_fsub_engine_init)
drivers/net/intel/iavf/iavf_generic_flow.h +0 -15
@@ -485,20 +485,6 @@ enum iavf_flow_engine_type { IAVF_FLOW_ENGINE_MAX, }; -/** -* classification stages. -* for non-pipeline mode, we have two classification stages: Distributor/RSS -* for pipeline-mode we have three classification stages: -* Permission/Distributor/RSS -*/ -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 , -}; -/* Struct to store engine created. */ struct iavf_flow_engine {TAILQ_ENTRY (iavf_flow_engine) node;
@@ -527,7 +513,6 @@ struct iavf_flow_parser {struct iavf_pattern_match_item *array;uint32_t array_len;parse_pattern_action_t parse_pattern_action; -enum iavf_flow_classification_stage stage; };/* Struct to store parser created. */
drivers/net/intel/iavf/iavf_hash.c +0 -1
@@ -691,7 +691,6 @@ static struct iavf_flow_parser iavf_hash_parser = { .array = iavf_hash_pattern_list, .array_len = RTE_DIM(iavf_hash_pattern_list), .parse_pattern_action = iavf_hash_parse_pattern_action, - .stage = IAVF_FLOW_STAGE_RSS, };int
drivers/net/intel/iavf/iavf_ipsec_crypto.c +0 -1
@@ -1983,7 +1983,6 @@ static struct iavf_flow_parser iavf_ipsec_flow_parser = { .array = iavf_ipsec_flow_pattern, .array_len = RTE_DIM(iavf_ipsec_flow_pattern), .parse_pattern_action = iavf_ipsec_flow_parse, - .stage = IAVF_FLOW_STAGE_IPSEC_CRYPTO, };RTE_INIT (iavf_ipsec_flow_engine_register)
Signature · 1 line
2.47.3
PATCH v4 17/27 net/iavf: avoid rte malloc in VF mailbox for IPsec
In reply to Anatoly BurakovCurrently, when calling down into the VF mailbox, IPsec code will use dynamic memory allocation (rte_malloc one at that!) to allocate VF message structures which are ~40 bytes in size, and then immediately frees them. This is wasteful and unnecessary, so use stack allocation instead.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 157 +++++++-------------- 1 file changed, 51 insertions(+), 106 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +51 -106
@@ -458,36 +458,24 @@ static uint32_t iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, struct rte_security_session_conf *conf) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -struct virtchnl_ipsec_sa_cfg *sa_cfg; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg sa_cfg; + } sa_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp; +struct inline_ipsec_msg *request = &sa_req.msg, *response = &sa_resp.msg; +struct virtchnl_ipsec_sa_cfg *sa_cfg = &sa_req.sa_cfg;int rc; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg ); - - request =rte_malloc ("iavf-sad-add-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_cfg_resp ); - response =rte_malloc ("iavf-sad-add-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;/* set SA configuration params */ - sa_cfg = (struct virtchnl_ipsec_sa_cfg *)(request +1 ); - sa_cfg->spi = conf->ipsec.spi; sa_cfg->virtchnl_protocol_type =VIRTCHNL_PROTO_ESP ; sa_cfg->virtchnl_direction =
@@ -541,10 +529,10 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sa_req), + (uint8_t *)response,sizeof (sa_resp));if (rc) - goto update_cleanup; +return rc;/* verify response id */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -552,9 +540,6 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, rc = -EFAULT ; else rc = response->ipsec_data.sa_cfg_resp->sa_handle; -update_cleanup: -rte_free (response); -rte_free (request);return rc; }
@@ -722,19 +707,18 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, bool is_udp, uint16_t udp_port) { -struct inline_ipsec_msg *request =NULL , *response =NULL ; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg sp_cfg; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg; +struct inline_ipsec_msg *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg ); - request =rte_malloc ("iavf-inbound-security-policy-add-request" , - request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_CREATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -768,21 +752,12 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter, request->ipsec_data.sp_cfg->is_udp = is_udp; request->ipsec_data.sp_cfg->udp_port =htons (udp_port); - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_cfg_resp ); - response =rte_malloc ("iavf-inbound-security-policy-add-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -791,10 +766,6 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,else rc = response->ipsec_data.sp_cfg_resp->rule_id; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -802,26 +773,17 @@ static uint32_t iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_update sa_update; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_update ); - request =rte_malloc ("iavf-sa-update-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sa-update-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_UPDATE ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -833,10 +795,10 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -845,10 +807,6 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,else rc = response->ipsec_data.ipsec_resp->resp; -update_cleanup: -rte_free (request); -rte_free (response); -return rc; }
@@ -899,26 +857,17 @@ int iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter, uint8_t is_v4, uint32_t flow_id) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_destroy sp_destroy; + } sp_req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp; +struct inline_ipsec_msg *request = &sp_req.msg, *response = &sp_resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sp_destroy ); - request =rte_malloc ("iavf-sp-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - response =rte_malloc ("iavf-sp-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -931,21 +880,17 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (sp_req), + (uint8_t *)response,sizeof (sp_resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode || response->req_id != request->req_id) rc = -EFAULT ;else -return response->ipsec_data.ipsec_status->status; - -update_cleanup: -rte_free (request); -rte_free (response); + rc = response->ipsec_data.ipsec_status->status;return rc; }
Signature · 1 line
2.47.3
PATCH v4 18/27 net/iavf: decouple hash uninit from parser uninit
In reply to Anatoly BurakovCurrently, parser deinitialization will trigger removal of current RSS configuration. This should not be done as part of parser deinitialization, but should rather be a separate step in dev close flow.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++++ drivers/net/intel/iavf/iavf_hash.c | 13 +++++++++---- drivers/net/intel/iavf/iavf_hash.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
drivers/net/intel/iavf/iavf_ethdev.c +4 -0
@@ -35,6 +35,7 @@#include "iavf_generic_flow.h" #include "rte_pmd_iavf.h" #include "iavf_ipsec_crypto.h" +#include "iavf_hash.h" /* devargs */ #define IAVF_PROTO_XTR_ARG "proto_xtr"
@@ -2972,6 +2973,9 @@ iavf_dev_close(struct rte_eth_dev *dev)/* free iAVF security device context all related resources */ iavf_security_ctx_destroy (adapter); +/* remove RSS configuration */ +iavf_hash_uninit (adapter); +iavf_flow_flush (dev,NULL );iavf_flow_uninit (adapter);
drivers/net/intel/iavf/iavf_hash.c +9 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "iavf_hash.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -77,7 +78,7 @@ static int iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow, struct rte_flow_error *error);static void -iavf_hash_uninit (struct iavf_adapter *ad); +iavf_hash_uninit_parser (struct iavf_adapter *ad);static void iavf_hash_free (struct rte_flow *flow); static int
@@ -680,7 +681,7 @@ static struct iavf_flow_engine iavf_hash_engine = { .init = iavf_hash_init, .create = iavf_hash_create, .destroy = iavf_hash_destroy, - .uninit = iavf_hash_uninit, + .uninit = iavf_hash_uninit_parser, .free = iavf_hash_free, .type = IAVF_FLOW_ENGINE_HASH, };
@@ -1641,6 +1642,12 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad, }static void +iavf_hash_uninit_parser (struct iavf_adapter *ad) +{ +iavf_unregister_parser (&iavf_hash_parser, ad); +} + +void iavf_hash_uninit (struct iavf_adapter *ad) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);
@@ -1658,8 +1665,6 @@ iavf_hash_uninit(struct iavf_adapter *ad) rss_conf = &ad->dev_data->dev_conf.rx_adv_conf.rss_conf;if (iavf_rss_hash_set (ad, rss_conf->rss_hf, false))PMD_DRV_LOG (ERR ,"fail to delete default RSS" ); - -iavf_unregister_parser (&iavf_hash_parser, ad); } static void
drivers/net/intel/iavf/iavf_hash.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */
Signature · 1 line
2.47.3
PATCH v4 19/27 net/iavf: avoid rte malloc in RSS configuration
In reply to Anatoly BurakovCurrently, when configuring RSS (redirection table, lookup table, and hash key), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_ethdev.c | 4 ++-- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/iavf/iavf_ethdev.c +2 -2
@@ -1554,7 +1554,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1574,7 +1574,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =iavf_configure_rss_lut (adapter);if (ret)/* revert back */ rte_memcpy (vf->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1159,7 +1159,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_lut) + vf->vf_res->rss_lut_size -1 ; - rss_lut =rte_zmalloc ("rss_lut" , len,0 ); + rss_lut =calloc (1 , len);if (!rss_lut)return -ENOMEM ;
@@ -1178,7 +1178,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_LUT" ); -rte_free (rss_lut); +free (rss_lut);return err; }
@@ -1191,7 +1191,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)int len, err =0 ; len =sizeof (*rss_key) + vf->vf_res->rss_key_size -1 ; - rss_key =rte_zmalloc ("rss_key" , len,0 ); + rss_key =calloc (1 , len);if (!rss_key)return -ENOMEM ;
@@ -1210,7 +1210,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_CONFIG_RSS_KEY" ); -rte_free (rss_key); +free (rss_key);return err; }
Signature · 1 line
2.47.3
PATCH v4 20/27 net/iavf: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +2 -2
@@ -1402,7 +1402,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) } } - list =rte_zmalloc ("iavf_del_mac_buffer" , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return ;
@@ -1434,7 +1434,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list); begin = next_begin; }while (begin <IAVF_NUM_MACADDR_MAX ); }
Signature · 1 line
2.47.3
PATCH v4 21/27 net/iavf: avoid rte malloc in IPsec operations
In reply to Anatoly BurakovCurrently, when performing IPsec security association operations and retrieving device capabilities, we are using rte_malloc followed by immediate rte_free. This is not needed as these structures are only used temporarily, so replace it with stack-allocated structures for small fixed-size messages and regular malloc/free for variable-sized buffers.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 58 ++++++++-------------- 1 file changed, 21 insertions(+), 37 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +21 -37
@@ -3,6 +3,7 @@*/ #include <stdalign.h> +#include <stdlib.h> #include <rte_cryptodev.h> #include <rte_ethdev.h>
@@ -899,29 +900,18 @@ static uint32_t iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, struct iavf_security_session *sess) { - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_destroy sa_destroy; + } req; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } resp; +struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;int rc =0 ; - request_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_sa_destroy ); - - request =rte_malloc ("iavf-sa-del-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_resp ); - - response =rte_malloc ("iavf-sa-del-response" , response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_DESTROY ; request->req_id = (uint16_t )0xDEADBEEF ;
@@ -939,10 +929,10 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,/* send virtual channel request to add SA to hardware database */ rc =iavf_ipsec_crypto_request (adapter, - (uint8_t *)request, request_len, - (uint8_t *)response, response_len); + (uint8_t *)request,sizeof (req), + (uint8_t *)response,sizeof (resp));if (rc) - goto update_cleanup; +return rc;/* verify response */ if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -957,10 +947,6 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter, response->ipsec_data.ipsec_status->status) rc = -EFAULT ; -update_cleanup: -rte_free (response); -rte_free (request); -return rc; }
@@ -1113,7 +1099,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-capability-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1121,8 +1107,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-capability-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1148,8 +1133,8 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,memcpy (capability, response->ipsec_data.ipsec_cap,sizeof (*capability)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
@@ -1538,7 +1523,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, request_len =sizeof (struct inline_ipsec_msg ); - request =rte_malloc ("iavf-device-status-request" , request_len,0 ); + request =calloc (1 , request_len);if (request ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1546,8 +1531,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, response_len =sizeof (struct inline_ipsec_msg ) +sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-status-response" , - response_len,0 ); + response =calloc (1 , response_len);if (response ==NULL ) { rc = -ENOMEM ; goto update_cleanup;
@@ -1573,8 +1557,8 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,memcpy (status, response->ipsec_data.ipsec_status,sizeof (*status)); update_cleanup: -rte_free (response); -rte_free (request); +free (response); +free (request);return rc; }
Signature · 1 line
2.47.3
PATCH v4 22/27 net/iavf: avoid rte malloc in queue operations
In reply to Anatoly BurakovCurrently, when enabling, disabling, or switching queues, we are using rte_malloc followed by an immediate rte_free. This is not needed as these structures are not being stored anywhere, so replace them with stack allocation or malloc/free where appropriate.
--- drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++++----------------- 1 file changed, 26 insertions(+), 39 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +26 -39
@@ -1020,19 +1020,15 @@ int iavf_enable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1048,7 +1044,7 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_ENABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1056,7 +1052,6 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_ENABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1064,19 +1059,15 @@ int iavf_disable_queues_lv(struct iavf_adapter *adapter) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req = {0 }; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ) + -sizeof (struct virtchnl_queue_chunk ) * - (IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =IAVF_RXTX_QUEUE_CHUNKS_NUM ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1092,7 +1083,7 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter) args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1100,7 +1091,6 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter)PMD_DRV_LOG (ERR ,"Failed to execute command of OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1109,17 +1099,15 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid, bool rx, bool on) {struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct virtchnl_del_ena_dis_queues *queue_select; -struct virtchnl_queue_chunk *queue_chunk; +struct { +struct virtchnl_del_ena_dis_queues msg; +struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM -1 ]; + } queue_req; +struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg; +struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;struct iavf_cmd_info args; -int err, len; +int err; - len =sizeof (struct virtchnl_del_ena_dis_queues ); - queue_select =rte_zmalloc ("queue_select" , len,0 ); -if (!queue_select) -return -ENOMEM ; - - queue_chunk = queue_select->chunks.chunks; queue_select->chunks.num_chunks =1 ; queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1138,7 +1126,7 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,else args.ops =VIRTCHNL_OP_DISABLE_QUEUES_V2 ; args.in_args = (u8 *)queue_select; - args.in_args_size = len; + args.in_args_size =sizeof (queue_req); args.out_buffer = vf->aq_resp; args.out_size =IAVF_AQ_BUF_SZ ; err =iavf_execute_vf_cmd_safe (adapter, &args,0 );
@@ -1146,7 +1134,6 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,PMD_DRV_LOG (ERR ,"Failed to execute command of %s" , on ?"OP_ENABLE_QUEUES_V2" :"OP_DISABLE_QUEUES_V2" ); -rte_free (queue_select);return err; }
@@ -1229,7 +1216,7 @@ iavf_configure_queues(struct iavf_adapter *adapter, size =sizeof (*vc_config) +sizeof (vc_config->qpair[0 ]) * num_queue_pairs; - vc_config =rte_zmalloc ("cfg_queue" , size,0 ); + vc_config =calloc (1 , size);if (!vc_config)return -ENOMEM ;
@@ -1292,7 +1279,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,PMD_DRV_LOG (ERR ,"Failed to execute command of" " VIRTCHNL_OP_CONFIG_VSI_QUEUES" ); -rte_free (vc_config); +free (vc_config);return err; }
Signature · 1 line
2.47.3
PATCH v4 23/27 net/iavf: avoid rte malloc in irq map config
In reply to Anatoly BurakovCurrently, when configuring IRQ maps, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +4 -4
@@ -1295,7 +1295,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter) len =sizeof (struct virtchnl_irq_map_info ) +sizeof (struct virtchnl_vector_map ) * vf->nb_msix; - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1319,7 +1319,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter)if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_CONFIG_IRQ_MAP" ); -rte_free (map_info); +free (map_info);return err; }
@@ -1337,7 +1337,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num, len =sizeof (struct virtchnl_queue_vector_maps ) +sizeof (struct virtchnl_queue_vector ) * (num -1 ); - map_info =rte_zmalloc ("map_info" , len,0 ); + map_info =calloc (1 , len);if (!map_info)return -ENOMEM ;
@@ -1360,7 +1360,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,if (err)PMD_DRV_LOG (ERR ,"fail to execute command OP_MAP_QUEUE_VECTOR" ); -rte_free (map_info); +free (map_info);return err; }
Signature · 1 line
2.47.3
PATCH v4 24/27 net/ice: avoid rte malloc in RSS RETA operations
In reply to Anatoly BurakovCurrently, when updating or querying RSS redirection table (RETA), we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_ethdev.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -1338,7 +1338,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -1358,7 +1358,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev, ret =ice_dcf_configure_rss_lut (hw);if (ret)/* revert back */ rte_memcpy (hw->rss_lut, lut, reta_size); -rte_free (lut); +free (lut);return ret; }
drivers/net/intel/ice/ice_ethdev.c +4 -4
@@ -5583,7 +5583,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,/* It MUST use the current LUT size to get the RSS lookup table, * otherwise if will fail with -100 error code. */ - lut =rte_zmalloc (NULL ,RTE_MAX (reta_size, lut_size),0 ); + lut =calloc (1 ,RTE_MAX (reta_size, lut_size));if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5607,7 +5607,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
@@ -5632,7 +5632,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc (NULL , reta_size,0 ); + lut =calloc (1 , reta_size);if (!lut) {PMD_DRV_LOG (ERR ,"No memory can be allocated" );return -ENOMEM ;
@@ -5650,7 +5650,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev, } out: -rte_free (lut); +free (lut);return ret; }
Signature · 1 line
2.47.3
PATCH v4 25/27 net/ice: avoid rte malloc in MAC address operations
In reply to Anatoly BurakovCurrently, when adding or deleting MAC addresses, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular calloc/free.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
@@ -936,7 +936,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw, len =sizeof (struct virtchnl_ether_addr_list ); len +=sizeof (struct virtchnl_ether_addr ) * mc_addrs_num; - list =rte_zmalloc (NULL , len,0 ); + list =calloc (1 , len);if (!list) {PMD_DRV_LOG (ERR ,"fail to allocate memory" );return -ENOMEM ;
@@ -961,7 +961,7 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); +free (list);return err; }
Signature · 1 line
2.47.3
PATCH v4 26/27 net/ice: avoid rte malloc in raw pattern parsing
In reply to Anatoly BurakovCurrently, when parsing raw flow patterns, we are using rte_zmalloc followed by an immediate rte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.
--- drivers/net/intel/ice/ice_fdir_filter.c | 14 +++++++------- drivers/net/intel/ice/ice_hash.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +7 -7
@@ -1879,13 +1879,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, pkt_len)return -rte_errno; - tmp_spec =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_spec =calloc (1 , pkt_len /2 );if (!tmp_spec)return -rte_errno; - tmp_mask =rte_zmalloc (NULL , pkt_len /2 ,0 ); + tmp_mask =calloc (1 , pkt_len /2 );if (!tmp_mask) { -rte_free (tmp_spec); +free (tmp_spec);return -rte_errno; }
@@ -1950,13 +1950,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, filter->parser_ena = true; -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);break ; raw_error: -rte_free (tmp_spec); -rte_free (tmp_mask); +free (tmp_spec); +free (tmp_mask);return ret_val; }
drivers/net/intel/ice/ice_hash.c +5 -5
@@ -676,13 +676,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, pkt_len = spec_len /2 ; - pkt_buf =rte_zmalloc (NULL , pkt_len,0 ); + pkt_buf =calloc (1 , pkt_len);if (!pkt_buf)return -ENOMEM ; - msk_buf =rte_zmalloc (NULL , pkt_len,0 ); + msk_buf =calloc (1 , pkt_len);if (!msk_buf) { -rte_free (pkt_buf); +free (pkt_buf);return -ENOMEM ; }
@@ -733,8 +733,8 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,rte_memcpy (&meta->raw.prof, &prof,sizeof (prof)); free_mem: -rte_free (pkt_buf); -rte_free (msk_buf); +free (pkt_buf); +free (msk_buf);return ret; }
Signature · 1 line
2.47.3
PATCH v4 27/27 net/ice: avoid rte malloc in flow pattern match
In reply to Anatoly BurakovCurrently, when allocating buffers for pattern match items and flow item storage, we are using rte_zmalloc followed by immediate rte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular calloc/free.
--- drivers/net/intel/ice/ice_acl_filter.c | 3 ++- drivers/net/intel/ice/ice_fdir_filter.c | 5 +++-- drivers/net/intel/ice/ice_generic_flow.c | 15 +++++++-------- drivers/net/intel/ice/ice_hash.c | 3 ++- drivers/net/intel/ice/ice_switch_filter.c | 5 +++-- 5 files changed, 17 insertions(+), 14 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +2 -1
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -1009,7 +1010,7 @@ ice_acl_parse(struct ice_adapter *ad, *meta = filter; error: -rte_free (item); +free (item);return ret; }
drivers/net/intel/ice/ice_fdir_filter.c +3 -2
@@ -3,6 +3,7 @@*/ #include <stdio.h> +#include <stdlib.h> #include <rte_flow.h> #include <rte_hash.h> #include <rte_hash_crc.h>
@@ -2504,11 +2505,11 @@ ice_fdir_parse(struct ice_adapter *ad,rte_free (filter->pkt_buf); } -rte_free (item); +free (item);return ret; error:rte_free (filter->pkt_buf); -rte_free (item); +free (item);return ret; }
drivers/net/intel/ice/ice_generic_flow.c +7 -8
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -2136,19 +2137,17 @@ ice_search_pattern_match_item(struct ice_adapter *ad, } item_num++; - items =rte_zmalloc ("ice_pattern" , - item_num *sizeof (struct rte_flow_item ),0 ); + items =calloc (item_num,sizeof (struct rte_flow_item ));if (!items) {rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ITEM_NUM ,NULL ,"No memory for PMD internal items." );return NULL ; } - pattern_match_item =rte_zmalloc ("ice_pattern_match_item" , -sizeof (struct ice_pattern_match_item ),0 ); + pattern_match_item =calloc (1 ,sizeof (struct ice_pattern_match_item ));if (!pattern_match_item) {rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL ,"Failed to allocate memory." ); -rte_free (items); +free (items);return NULL ; }
@@ -2167,7 +2166,7 @@ ice_search_pattern_match_item(struct ice_adapter *ad, pattern_match_item->pattern_list = array[i].pattern_list; pattern_match_item->meta = array[i].meta; -rte_free (items); +free (items);return pattern_match_item; } }
@@ -2175,8 +2174,8 @@ ice_search_pattern_match_item(struct ice_adapter *ad, unsupported:rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , pattern,"Unsupported pattern" ); -rte_free (items); -rte_free (pattern_match_item); +free (items); +free (pattern_match_item);return NULL ; }
drivers/net/intel/ice/ice_hash.c +2 -1
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h>
@@ -1211,7 +1212,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, *meta = rss_meta_ptr; elserte_free (rss_meta_ptr ); -rte_free (pattern_match_item); +free (pattern_match_item);return ret; }
drivers/net/intel/ice/ice_switch_filter.c +3 -2
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h> #include <ethdev_driver.h>
@@ -1877,14 +1878,14 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,rte_free (sw_meta_ptr); } -rte_free (pattern_match_item); +free (pattern_match_item);return 0 ; error:rte_free (list);rte_free (sw_meta_ptr); -rte_free (pattern_match_item); +free (pattern_match_item);return -rte_errno; }
Signature · 1 line
2.47.3
Re: [PATCH v3 06/27] net/i40e: use unsigned types for queue comparisons
In reply to Morten BrørupQuoted 43 lines · Morten Brørup
Quoted 23 lines
Currently, when we compare queue numbers against maximum traffic class value of 64, we do not use unsigned values, which results in compiler warning when attempting to compare
I40E_MAX_Q_PER_TCto an unsigned value. Make it unsigned, and adjust callers to use correct types. As a consequence,i40e_align_floornow returns unsigned value as well - this
is correct, because nothing about that function implies signed usage being
a valid use case.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 6 +++--- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)drivers/net/intel/i40e/i40e_ethdev.c +0
-0drivers/net/intel/i40e/i40e_ethdev.c i40e_pf_reset_rss_reta(struct i40e_pf *pf) · line 9061
Quoted 5 lines
drivers/net/intel/i40e/i40e_ethdev.c +1
-1@@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)struct i40e_hw *hw = &pf->adapter->hw;uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ];uint32_t i; -int num; +size_t num;Why not just unsigned int?
size_tseems weird when not counting bytes.Or
uint16_t, considering its use.drivers/net/intel/i40e/i40e_ethdev.c i40e_pf_reset_rss_reta(struct i40e_pf *pf)
Quoted 5 lines
drivers/net/intel/i40e/i40e_ethdev.c +1
-1struct i40e_pf *pf;struct i40e_hw *hw;uint16_t i; -int max_queue; +size_t max_queue;Why not just unsigned int?
size_tseems weird when not counting bytes.
Quoted 2 lines
Or
uint16_t, like rss_act->queue[i].
But thenI40E_MAX_Q_PER_TCshould maybe also be defined asUINT16_C(64), and maybe more should beuint16_ttoo.
Good points. Missed this in v4 respin so will address in v5. Thanks for the review!
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v4 01/27] net/ixgbe: remove MAC type check macros
In reply to Anatoly BurakovQuoted 5 lines · Anatoly Burakov
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
Signed-off-by Anatoly Burakov <[email protected]>---
Missed from v3
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v4 02/27] net/ixgbe: remove security-related ifdefery
In reply to Anatoly BurakovQuoted 6 lines · Anatoly Burakov
The security library is specified as explicit dependency for ixgbe, so there is no more need to gate features behind #ifdef blocks that depend on presence of this library.
Signed-off-by Anatoly Burakov <[email protected]>---
Missed from v3
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v4 01/27] net/ixgbe: remove MAC type check macros
In reply to Anatoly BurakovQuoted 19 lines · Anatoly Burakov
The macros used were not informative and did not add any value beyond code golf, so remove them and make MAC type checks explicit.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 12 ------------ drivers/net/intel/ixgbe/ixgbe_flow.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-)drivers/net/intel/ixgbe/ixgbe_ethdev.h +0
-2@@ -137,18 +137,6 @@#define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)#define IXGBE_MAX_L2_TN_FILTER_NUM 128 -#define MAC_TYPE_FILTER_SUP_EXT (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\
drivers/net/intel/ixgbe/ixgbe_ethdev.h line 151
Quoted 10 lines
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0
-10-return -ENOTSUP ;\ -} while (0) - -#define MAC_TYPE_FILTER_SUP (type) do {\ - if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\ - (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\ - (type) != ixgbe_mac_X550EM_a && (type) != ixgbe_mac_E610)\ - return -ENOTSUP;\ -} while (0) -
Ack for removing the former. For the latter, since the list is longer and the code is used twice, I'd be tempted to convert to an inline function taking in struct hw and returning type bool. WDYT?