Cleanups for ixgbe, i40e, and iavf PMD's
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
Re: [PATCH v4 18/27] net/iavf: decouple hash uninit from parser uninit
Quoted 96 lines · Anatoly Burakov
Currently, 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.
Signed-off-by Anatoly Burakov <[email protected]>--- 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.hdrivers/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 voiddrivers/net/intel/iavf/iavf_hash.h new file +3
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/
drivers/net/intel/iavf/iavf_hash.h line 13
Quoted 10 lines
drivers/net/intel/iavf/iavf_hash.h new file +10
-0+ +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */
While its primarily a matter of taste, do we really need to create a new header for this? For a single function prototype can it not just go in iavf.h directly itself?
Either way:
Re: [PATCH v4 18/27] net/iavf: decouple hash uninit from parser uninit
Quoted 112 lines · Bruce Richardson
Quoted 96 lines · Anatoly Burakov
Currently, 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.
Signed-off-by Anatoly Burakov <[email protected]>--- 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.hdrivers/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 voiddrivers/net/intel/iavf/iavf_hash.h new file +3
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ drivers/net/intel/iavf/iavf_hash.h line 13
Quoted 10 lines
drivers/net/intel/iavf/iavf_hash.h new file +10
-0+ +#ifndef _IAVF_HASH_H_ +#define _IAVF_HASH_H_ + +#include "iavf.h" + +void +iavf_hash_uninit (struct iavf_adapter *ad); + +#endif /* _IAVF_HASH_H_ */ While its primarily a matter of taste, do we really need to create a new header for this? For a single function prototype can it not just go in
iavf.hdirectly itself?
Quoted 3 lines
Either way:
Acked-by Bruce Richardson <[email protected]>
This code is not touched further down the line so yes, I can move it to iavf.h no problem.
Signature · 2 lines
Thanks, Anatoly
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
Re: [PATCH v4 19/27] net/iavf: avoid rte malloc in RSS configuration
Quoted 16 lines · Anatoly Burakov
Currently, when configuring RSS (redirection table, lookup table, and hash key), we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- 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 +0
-0
drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_rss_reta_update(struct rte_eth_dev *dev, · line 1557
Quoted 5 lines
drivers/net/intel/iavf/iavf_ethdev.c +1
-1@@ -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);
As with i40e, can we make this (and the key allocation below) static based on max sizes supported?
Quoted 55 lines
drivers/net/intel/iavf/iavf_ethdev.c +1
-1if (!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
Re: [PATCH v4 19/27] net/iavf: avoid rte malloc in RSS configuration
Quoted 20 lines · Bruce Richardson
Quoted 19 lines · Anatoly Burakov
Currently, when configuring RSS (redirection table, lookup table, and hash key), we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- 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 +0
-0@@ -1554,7 +1554,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; }
Quoted 6 lines
drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_rss_reta_update(struct rte_eth_dev *dev, · line 1557
Quoted 2 lines
drivers/net/intel/iavf/iavf_ethdev.c +1
-1- lut =rte_zmalloc ("rss_lut" , reta_size,0 ); + lut =calloc (1 , reta_size);As with i40e, can we make this (and the key allocation below) static based on max sizes supported?
It depends. Technically, IAVF does not specify "max size", it is whatever PF reports. In practice, the biggest we're going to get (i.e. the biggest supported by i40e and ice) is 512, so we could hardcode that.
Similarly for RSS key, technically we don't know how big an RSS key we can support. In practice, both ice and i40e only support 52-byte keys, so we could hardcode that.
So, on the one hand, hardcoding this goes against every fiber of my being because "IAVF doesn't know", but on the other we *know* these values in practice. Which voice should I be listening to? :)
Signature · 2 lines
Thanks, Anatoly
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
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
Quoted 15 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/intel/iavf/iavf_vchnl.c +0
-0
drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1405
Quoted 5 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -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);
Given the loop above has a threshold set for IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?
Also, that check itself seems a little off, since it allows buffers greater than the size, rather than ignoring the length of the address that pushes it over the limit.
Quoted 15 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1if (!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
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
Quoted 19 lines · Bruce Richardson
Quoted 18 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/intel/iavf/iavf_vchnl.c +0
-0@@ -1402,7 +1402,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) } }
Quoted 5 lines
drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1405
Quoted 2 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1- list =rte_zmalloc ("iavf_del_mac_buffer" , len,0 ); + list =calloc (1 , len);Given the loop above has a threshold set for
IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?
That size is 4 kilobytes, so I agree that we can use one buffer rather than constantly allocating/deallocating things, it'll still have to be dynamically allocated.
Quoted 4 lines
Also, that check itself seems a little off, since it allows buffers greater than the size, rather than ignoring the length of the address that pushes it over the limit.
Yes, this seems like an opportunity for a bugfix. I'll submit it separately.
Quoted 16 lines
Quoted 16 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1if (!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
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
Quoted 25 lines · Anatoly
Quoted 11 lines · Bruce Richardson
Quoted 10 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 12 lines
drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1404
Quoted 9 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -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);Given the loop above has a threshold set for
IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?
Quoted 4 lines
That size is 4 kilobytes, so I agree that we can use one buffer rather than constantly allocating/deallocating things, it'll still have to be dynamically allocated.
I still would use a stack variable myself. 4k really isn't that big nowadays.
/Bruce
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
Quoted 26 lines · Bruce Richardson
Quoted 25 lines · Anatoly
Quoted 23 lines · Bruce Richardson
Quoted 15 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/intel/iavf/iavf_vchnl.c +0
-0drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1404
Quoted 4 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -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);Given the loop above has a threshold set for
IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?
Quoted 7 lines
Quoted 4 lines
That size is 4 kilobytes, so I agree that we can use one buffer rather than constantly allocating/deallocating things, it'll still have to be dynamically allocated.
I still would use a stack variable myself. 4k really isn't that big nowadays.
4k is also PATH_MAX, and we use stack arrays of PATH_MAX size everywhere in DPDK, so I think we can assume that it's an ok size to use as a stack variable.
/Bruce
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
Quoted 31 lines · Bruce Richardson
Quoted 30 lines · Bruce Richardson
Quoted 29 lines · Anatoly
Quoted 11 lines · Bruce Richardson
Quoted 10 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 12 lines
drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1404
Quoted 9 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -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);Given the loop above has a threshold set for
IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?That size is 4 kilobytes, so I agree that we can use one buffer rather than constantly allocating/deallocating things, it'll still have to be dynamically allocated.
Quoted 8 lines
Quoted 3 lines
I still would use a stack variable myself. 4k really isn't that big nowadays.
4k is also
PATH_MAX, and we use stack arrays ofPATH_MAXsize everywhere in DPDK, so I think we can assume that it's an ok size to use as a stack variable./Bruce
Ack. While attempting to figure out this code I just uncovered a whole bunch of other places where we could replace things with a stack allocation :/
(not submitting them in this patchset, but there's gonna be more rework like this in the future)
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v4 20/27] net/iavf: avoid rte malloc in MAC address operations
In reply to Bruce RichardsonQuoted 25 lines · Bruce Richardson
Quoted 15 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/intel/iavf/iavf_vchnl.c +0
-0drivers/net/intel/iavf/iavf_vchnl.c iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) · line 1405
Quoted 5 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -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);Given the loop above has a threshold set for
IAVF_AQ_BUF_SZ, maybe a static buffer of that fixed size might be better?
Quoted 3 lines
Also, that check itself seems a little off, since it allows buffers greater than the size, rather than ignoring the length of the address that pushes it over the limit.
Fun fact: this entire thing is pointless, because sizeof() of MAC address structure is 8 bytes, there's max 64 addresses, and the buffer is 4K so it will *never* overflow and need to be split up. I'll remove that code.
Quoted 16 lines
Quoted 16 lines
drivers/net/intel/iavf/iavf_vchnl.c +1
-1if (!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
Signature · 2 lines
Thanks, Anatoly
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
Re: [PATCH v4 21/27] net/iavf: avoid rte malloc in IPsec operations
Quoted 7 lines · Anatoly Burakov
Currently, when performing IPsec security association operations and retrieving device capabilities, we are using
rte_mallocfollowed by immediaterte_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.
Quoted 5 lines
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 58 ++++++++-------------- 1 file changed, 21 insertions(+), 37 deletions(-)
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
Re: [PATCH v4 22/27] net/iavf: avoid rte malloc in queue operations
Quoted 10 lines · Anatoly Burakov
Currently, when enabling, disabling, or switching queues, we are using
rte_mallocfollowed by an immediaterte_free. This is not needed as these structures are not being stored anywhere, so replace them with stack allocation or malloc/free where appropriate.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++++----------------- 1 file changed, 26 insertions(+), 39 deletions(-)
Re: [PATCH v4 22/27] net/iavf: avoid rte malloc in queue operations
In reply to Anatoly BurakovQuoted 6 lines · On Fri, 13 Feb 2026 10:26:33 +0000 Anatoly Burakov <[email protected]>…
Currently, when enabling, disabling, or switching queues, we are using
rte_mallocfollowed by an immediaterte_free. This is not needed as these structures are not being stored anywhere, so replace them with stack allocation or malloc/free where appropriate.Signed-off-by Anatoly Burakov <[email protected]>
AI caught something here.
Patch 22/27 — net/iavf: avoid rte malloc in queue operations Error (Correctness — Uninitialized stack memory)
In iavf_switch_queue_lv(), the stack-allocated queue_req is not zero-initialized:

c
} queue_req; /* <-- no "= {0}" */The original code used rte_zmalloc which zeroes the buffer. The other two functions in this same patch (iavf_enable_queues_lv and iavf_disable_queues_lv) correctly use = {0}, but iavf_switch_queue_lv does not. The structure is then sent as a virtchnl message via args.in_args, meaning uninitialized stack bytes will be transmitted to the PF driver. While individual fields like num_chunks, vport_id, queue_type, start_queue_id, and num_queues are set explicitly, padding bytes and any other fields within the struct will contain garbage.
Additionally, this function previously allocated only sizeof(struct virtchnl_del_ena_dis_queues) (which includes exactly 1 chunk), but the new stack struct includes IAVF_RXTX_QUEUE_CHUNKS_NUM - 1 additional chunks. Since num_chunks is set to 1, the extra space is harmless — but passing sizeof(queue_req) as in_args_size now sends a larger buffer than before. Compare with the enable/disable functions which also have the extra chunks but actually use IAVF_RXTX_QUEUE_CHUNKS_NUM chunks. The size change is likely benign but worth noting.
Fix: Add = {0} to the declaration, matching the pattern in the sibling functions in the same patch:

c
} queue_req = {0};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
Re: [PATCH v4 23/27] net/iavf: avoid rte malloc in irq map config
Quoted 9 lines · Anatoly Burakov
Currently, when configuring IRQ maps, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
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
Re: [PATCH v4 24/27] net/ice: avoid rte malloc in RSS RETA operations
Quoted 11 lines · Anatoly Burakov
Currently, when updating or querying RSS redirection table (RETA), we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_ethdev.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
Same comment as with the other reta changes. With or without that taken into account:
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
Re: [PATCH v4 25/27] net/ice: avoid rte malloc in MAC address operations
Quoted 10 lines · Anatoly Burakov
Currently, when adding or deleting MAC addresses, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular calloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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
Re: [PATCH v4 26/27] net/ice: avoid rte malloc in raw pattern parsing
Quoted 10 lines · Anatoly Burakov
Currently, when parsing raw flow patterns, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with regular malloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ice/ice_fdir_filter.c | 14 +++++++------- drivers/net/intel/ice/ice_hash.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-)
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 v4 27/27] net/ice: avoid rte malloc in flow pattern match
Quoted 27 lines · Anatoly Burakov
Currently, when allocating buffers for pattern match items and flow item storage, we are using
rte_zmallocfollowed by immediaterte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular calloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- 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 +1
-0@@ -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>
drivers/net/intel/ice/ice_acl_filter.c ice_acl_parse(struct ice_adapter *ad, · line 1015
Quoted 7 lines
drivers/net/intel/ice/ice_acl_filter.c +1
-1@@ -1009,7 +1010,7 @@ ice_acl_parse(struct ice_adapter *ad, *meta = filter; error: -rte_free (item); +free (item);return ret; }
Should this code be reworked so that the error is propagated back to caller and the item freed there so as allocation and freeing occur together in the one function - or even in the same file?
Quoted 40 lines
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 +1
-0@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_ether.h> #include <ethdev_driver.h>
drivers/net/intel/ice/ice_generic_flow.c ice_search_pattern_match_item(struct ice_adapter *ad, · line 2141
Quoted 7 lines
drivers/net/intel/ice/ice_generic_flow.c +1
-2@@ -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) {
<snip for brevity>
Re: [PATCH v4 27/27] net/ice: avoid rte malloc in flow pattern match
Quoted 30 lines · Bruce Richardson
Quoted 29 lines · Anatoly Burakov
Currently, when allocating buffers for pattern match items and flow item storage, we are using
rte_zmallocfollowed by immediaterte_free. This is not needed as these buffers are only used temporarily within the function scope, so replace it with regular calloc/free.Signed-off-by Anatoly Burakov <[email protected]>--- 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 +1
-0@@ -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;
Quoted 10 lines
drivers/net/intel/ice/ice_acl_filter.c ice_acl_parse(struct ice_adapter *ad, · line 1015
Quoted 5 lines
drivers/net/intel/ice/ice_acl_filter.c +1
-1error: -rte_free (item); +free (item);return ret; }Should this code be reworked so that the error is propagated back to caller and the item freed there so as allocation and freeing occur together in the one function - or even in the same file?
It should, and in fact further rework is also about fixing quirks like these. With this patch though, I tried to minimize the changes and not touch logic, because untangling these allocations is not trivial.
Signature · 2 lines
Thanks, Anatoly
v5 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
v4 -> v5:
- Adjusted typing for queue size
- Fixed missing zero initializations for stack allocations
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 | 232 +++++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 26 ++- 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 | 84 +++---- 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, 541 insertions(+), 679 deletions(-) create mode 100644 drivers/net/intel/iavf/iavf_hash.h
Signature · 1 line
2.47.3
PATCH v5 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 v5 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 v5 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
Re: [PATCH v5 03/27] net/ixgbe: split security and ntuple filters
Quoted 9 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.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/ixgbe/ixgbe_flow.c | 194 ++++++++++++++++----------- 1 file changed, 114 insertions(+), 80 deletions(-)
<snip>
drivers/net/intel/ixgbe/ixgbe_flow.c cons_parse_ntuple_filter(const struct rte_flow_attr *attr, · line 670
Quoted 10 lines
drivers/net/intel/ixgbe/ixgbe_flow.c +10
-0+ +/* +* 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);
nit: I'd recommend to handle error here in the same way it is handled in this function, i.e. if (ret) {rte_flow_error_set() ... } apart from this
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
PATCH v5 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
Re: [PATCH v5 04/27] net/i40e: get rid of global filter variables
Quoted 14 lines · Anatoly Burakov
Currently, i40e driver relies on global state to work around the fact that
rte_flow_validate()is being called directly fromrte_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.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.h | 16 ++-- drivers/net/intel/i40e/i40e_flow.c | 117 ++++++++++++++------------- 2 files changed, 68 insertions(+), 65 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
PATCH v5 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
Re: [PATCH v5 05/27] net/i40e: make default RSS key global
Quoted 14 lines · Anatoly Burakov
Currently, 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.
Signed-off-by Anatoly Burakov <[email protected]>--- 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(-)
<snip>
Signature · 2 lines
Regards, Vladimir
PATCH v5 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 16-bit, 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 | 11 ++++++----- drivers/net/intel/i40e/i40e_ethdev.h | 8 ++++---- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +6 -5
@@ -8978,11 +8978,12 @@ i40e_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, }/* Calculate the maximum number of contiguous PF queues that are configured */ -int +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf) {struct rte_eth_dev_data *data = pf->dev_data; -int i, num; +int i; +uint16_t num;struct ci_rx_queue *rxq; num =0 ;
@@ -9058,7 +9059,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; +uint16_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
@@ -9074,7 +9075,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)return 0 ;for (i =0 ; i < hw->func_caps.rss_table_size; i++) - lut[i] = (uint8_t )(i % (uint32_t )num); + lut[i] = (uint8_t )(i % num);return i40e_set_rss_lut (pf->main_vsi, lut, (uint16_t )i); }
@@ -10771,7 +10772,7 @@ i40e_vsi_update_queue_mapping(struct i40e_vsi *vsi,PMD_INIT_LOG (ERR ," number of queues is less that tcs." );return I40E_ERR_INVALID_QP_ID ; } - qpnum_per_tc =RTE_MIN (i40e_align_floor (qpnum_per_tc), + qpnum_per_tc =RTE_MIN ((uint16_t )i40e_align_floor (qpnum_per_tc),I40E_MAX_Q_PER_TC ); bsf =rte_bsf32 (qpnum_per_tc);
drivers/net/intel/i40e/i40e_ethdev.h +4 -4
@@ -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 UINT16_C(64)#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1456,7 +1456,7 @@ int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,void i40e_init_queue_region_conf (struct rte_eth_dev *dev);void i40e_flex_payload_reg_set_default (struct i40e_hw *hw);void i40e_pf_disable_rss (struct i40e_pf *pf); -int i40e_pf_calc_configured_queues_num (struct i40e_pf *pf); +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf);int i40e_pf_reset_rss_reta (struct i40e_pf *pf);int i40e_pf_reset_rss_key (struct i40e_pf *pf);int i40e_pf_config_rss (struct i40e_pf *pf);
@@ -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; +uint16_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
Re: [PATCH v5 06/27] net/i40e: use unsigned types for queue comparisons
Quoted 15 lines · Anatoly Burakov
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 16-bit, 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 | 11 ++++++----- drivers/net/intel/i40e/i40e_ethdev.h | 8 ++++---- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
PATCH v5 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
Re: [PATCH v5 07/27] net/i40e: use proper flex len define
Quoted 26 lines · Anatoly Burakov
For 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.
Signed-off-by Anatoly Burakov <[email protected]>--- 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 · 2 lines
Regards, Vladimir
PATCH v5 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
Re: [PATCH v5 08/27] net/i40e: remove global pattern variable
Quoted 15 lines · Anatoly Burakov
When 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_zmalloccall which seems like overkill for this use case.Remove the global variable, and replace the split behavior with unconditional allocation.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/i40e/i40e_flow.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
PATCH v5 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
Re: [PATCH v5 09/27] net/i40e: avoid rte malloc in tunnel set
Quoted 9 lines · Anatoly Burakov
Currently, when setting tunnel configuration, we are using
rte_zmallocfollowed by an immediaterte_free. This is not needed as this memory is not being stored anywhere, so replace it with stack allocation.Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++--------------- 1 file changed, 53 insertions(+), 71 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
PATCH v5 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 v5 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 v5 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 v5 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 v5 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 v5 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
@@ -11788,7 +11788,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 ;
@@ -11799,7 +11799,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 ; }
@@ -11880,7 +11880,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype); +free (pctype);return 0 ; }
@@ -11926,7 +11926,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 ;
@@ -11938,15 +11938,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 ; }
@@ -12084,8 +12083,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; }
@@ -12120,7 +12119,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 ;
@@ -12132,7 +12131,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 ; }
@@ -12170,7 +12169,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 v5 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 v5 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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp = {0 }; +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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp = {0 }; +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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp = {0 }; +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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp = {0 }; +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 v5 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 v5 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 v5 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 v5 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 v5 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 | 64 +++++++++++------------------ 1 file changed, 25 insertions(+), 39 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +25 -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,14 @@ 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; + } 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 ); - 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 +1125,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 +1133,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 +1215,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 +1278,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 v5 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
@@ -1294,7 +1294,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 ;
@@ -1318,7 +1318,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; }
@@ -1336,7 +1336,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 ;
@@ -1359,7 +1359,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 v5 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 v5 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 v5 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 v5 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 v5 00/27] Cleanups for ixgbe, i40e, iavf, and ice PMD's
In reply to Anatoly BurakovQuoted 37 lines · Anatoly Burakov
This 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 pathsI40E:
- Get rid of global variables and unnecessary allocations
- Reduce code duplication around default RSS keys
- Use more appropriate integer types and definitionsIAVF:
- Remove dead code
- Remove unnecessary allocations
- Separate RSS uninit from hash flow parser uninitICE:
- 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 aroundrte_mallocusagev2 -> v3:
- Reworded some commit messages
- Added a new patch for ICE
- Rebased on latest bug fix patches
Quoted 7 lines
v3 -> v4:
- Rebased on latest bugfix patchsetv4 -> v5:
- Adjusted typing for queue size
- Fixed missing zero initializations for stack allocations
Due to Thunderbird mishap missed a bunch of feedback, so v6 will come.
Signature · 2 lines
Thanks, Anatoly
v6 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
v4 -> v5:
- Adjusted typing for queue size
- Fixed missing zero initializations for stack allocations
v5 -> v6:
- Addressed feedback for v3, v4, and v5
- Changed more allocations to be stack based
- Reworked queue and IRQ map related i40e patches for better logic
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: decouple hash uninit from parser uninit net/iavf: avoid rte malloc in VF mailbox for IPsec 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 | 370 +++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 26 +- drivers/net/intel/i40e/i40e_flow.c | 147 ++++--- 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 | 60 +-- drivers/net/intel/iavf/iavf.h | 7 +- drivers/net/intel/iavf/iavf_ethdev.c | 37 +- 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 | 13 +- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 283 +++++-------- drivers/net/intel/iavf/iavf_vchnl.c | 412 ++++++++++--------- drivers/net/intel/ice/ice_acl_filter.c | 3 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 26 +- drivers/net/intel/ice/ice_ethdev.c | 29 +- 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 | 228 ++++++---- 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, 783 insertions(+), 1041 deletions(-)
Signature · 1 line
2.47.3
PATCH v6 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 v6 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 v6 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 | 202 ++++++++++++++++----------- 1 file changed, 122 insertions(+), 80 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +122 -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,112 @@ 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; +int ret; + +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. the latter path was chosen. +*/ + session = RTE_CAST_PTR(struct rte_security_session *, security->security_session); + ret =ixgbe_crypto_add_ingress_sa_from_flow (session, &spec); +if (ret) { +rte_flow_error_set (error, -ret, +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Failed to add security session." ); +return -rte_errno; + } +return 0 ; +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -661,10 +699,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 +3133,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 +3369,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 v6 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 v6 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 v6 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 16-bit, 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 | 11 ++++++----- drivers/net/intel/i40e/i40e_ethdev.h | 8 ++++---- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +6 -5
@@ -8978,11 +8978,12 @@ i40e_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, }/* Calculate the maximum number of contiguous PF queues that are configured */ -int +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf) {struct rte_eth_dev_data *data = pf->dev_data; -int i, num; +int i; +uint16_t num;struct ci_rx_queue *rxq; num =0 ;
@@ -9058,7 +9059,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; +uint16_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
@@ -9074,7 +9075,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)return 0 ;for (i =0 ; i < hw->func_caps.rss_table_size; i++) - lut[i] = (uint8_t )(i % (uint32_t )num); + lut[i] = (uint8_t )(i % num);return i40e_set_rss_lut (pf->main_vsi, lut, (uint16_t )i); }
@@ -10771,7 +10772,7 @@ i40e_vsi_update_queue_mapping(struct i40e_vsi *vsi,PMD_INIT_LOG (ERR ," number of queues is less that tcs." );return I40E_ERR_INVALID_QP_ID ; } - qpnum_per_tc =RTE_MIN (i40e_align_floor (qpnum_per_tc), + qpnum_per_tc =RTE_MIN ((uint16_t )i40e_align_floor (qpnum_per_tc),I40E_MAX_Q_PER_TC ); bsf =rte_bsf32 (qpnum_per_tc);
drivers/net/intel/i40e/i40e_ethdev.h +4 -4
@@ -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 UINT16_C(64)#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1456,7 +1456,7 @@ int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,void i40e_init_queue_region_conf (struct rte_eth_dev *dev);void i40e_flex_payload_reg_set_default (struct i40e_hw *hw);void i40e_pf_disable_rss (struct i40e_pf *pf); -int i40e_pf_calc_configured_queues_num (struct i40e_pf *pf); +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf);int i40e_pf_reset_rss_reta (struct i40e_pf *pf);int i40e_pf_reset_rss_key (struct i40e_pf *pf);int i40e_pf_config_rss (struct i40e_pf *pf);
@@ -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; +uint16_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 v6 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 v6 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 | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +10 -20
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h>
@@ -145,9 +146,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 +3835,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 +3854,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 +3864,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 v6 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 memory does not need to be stored in hugepage memory and the allocation size is pretty small, 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 v6 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 memory does not need to be stored in hugepage memory and the maximum LUT size is 512 bytes, so replace it with stack-based allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +4 -21
@@ -4619,7 +4619,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ] = {0 };int ret; if (reta_size != lut_size ||
@@ -4630,14 +4630,9 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } ret =i40e_get_rss_lut (pf->main_vsi, lut, reta_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ;
@@ -4648,9 +4643,6 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev, pf->adapter->rss_reta_updated =1 ; -out: -rte_free (lut); -return ret; }
@@ -4662,7 +4654,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ] = {0 };int ret; if (reta_size != lut_size ||
@@ -4673,15 +4665,9 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } - ret =i40e_get_rss_lut (pf->main_vsi, lut, reta_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ;
@@ -4689,9 +4675,6 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev, reta_conf[idx].reta[shift] = lut[i]; } -out: -rte_free (lut); -return ret; }
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, so replace it with regular malloc/free or stack allocation where appropriate.
--- drivers/net/intel/i40e/i40e_ethdev.c | 135 +++++++++++--------------- drivers/net/intel/i40e/rte_pmd_i40e.c | 17 ++-- 2 files changed, 65 insertions(+), 87 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +56 -79
@@ -6,6 +6,7 @@#include <stdio.h> #include <errno.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdarg.h>
@@ -4128,7 +4129,6 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode;struct i40e_mac_filter *f;
@@ -4163,12 +4163,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { +struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX ] = {0 }; i =0 ; num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); -if (mac_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); + +if (num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Too many MAC addresses" );return I40E_ERR_NO_MEMORY ; }
@@ -4206,7 +4206,6 @@ 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); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -6200,7 +6199,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)int i, num;struct i40e_mac_filter *f;void *temp; -struct i40e_mac_filter_info *mac_filter; +struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX ] = {0 };enum i40e_mac_filter_type desired_filter;int ret =I40E_SUCCESS ;
@@ -6213,12 +6212,9 @@ 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 ); -if (mac_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Too many MAC addresses" ); +return -1 ; } i =0 ;
@@ -6230,7 +6226,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)if (ret) {PMD_DRV_LOG (ERR ,"Update VSI failed to %s vlan filter" , on ?"enable" :"disable" ); - goto DONE; +return ret; } i++; }
@@ -6242,13 +6238,11 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)if (ret) {PMD_DRV_LOG (ERR ,"Update VSI failed to %s vlan filter" , on ?"enable" :"disable" ); - goto DONE; +return ret; } } -DONE: -rte_free (mac_filter); -return ret; +return 0 ; }/* Configure vlan stripping on or off */
@@ -7130,19 +7124,20 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,uint16_t flags;int ret =I40E_SUCCESS ;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi); -struct i40e_aqc_add_macvlan_element_data *req_list; +uint8_t aq_buff[I40E_AQ_BUF_SZ ] = {0 }; +struct i40e_aqc_add_macvlan_element_data *req_list = + (struct i40e_aqc_add_macvlan_element_data *)aq_buff; + +if (hw->aq.asq_buf_size >I40E_AQ_BUF_SZ ) { +PMD_DRV_LOG (ERR ,"AdminQ size biffer than max" ); +return I40E_ERR_NO_MEMORY ; + }if (filter ==NULL || total ==0 )return I40E_ERR_PARAM ; 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 ); -if (req_list ==NULL ) { -PMD_DRV_LOG (ERR ,"Fail to allocate memory" ); -return I40E_ERR_NO_MEMORY ; - } - num =0 ; do { actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7171,8 +7166,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,break ;default :PMD_DRV_LOG (ERR ,"Invalid MAC match type" ); - ret =I40E_ERR_PARAM ; - goto DONE; +return I40E_ERR_PARAM ; } req_list[i].queue_number =0 ;
@@ -7184,14 +7178,11 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, actual_num, NULL);if (ret !=I40E_SUCCESS ) {PMD_DRV_LOG (ERR ,"Failed to add macvlan filter" ); - goto DONE; +return ret; } num += actual_num; }while (num < total); - -DONE: -rte_free (req_list); -return ret; +return I40E_SUCCESS ; }int
@@ -7204,21 +7195,22 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,uint16_t flags;int ret =I40E_SUCCESS ;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi); -struct i40e_aqc_remove_macvlan_element_data *req_list; +uint8_t aq_buff[I40E_AQ_BUF_SZ ] = {0 }; +struct i40e_aqc_remove_macvlan_element_data *req_list = + (struct i40e_aqc_remove_macvlan_element_data *)aq_buff;enum i40e_admin_queue_err aq_status;if (filter ==NULL || total ==0 )return I40E_ERR_PARAM ; - 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 ); -if (req_list ==NULL ) { -PMD_DRV_LOG (ERR ,"Fail to allocate memory" ); +if (hw->aq.asq_buf_size >I40E_AQ_BUF_SZ ) { +PMD_DRV_LOG (ERR ,"AdminQ size biffer than max" );return I40E_ERR_NO_MEMORY ; } + ele_num = hw->aq.asq_buf_size /sizeof (*req_list); + ele_buff_size = hw->aq.asq_buf_size; + num =0 ; do { actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7247,8 +7239,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,break ;default :PMD_DRV_LOG (ERR ,"Invalid MAC filter type" ); - ret =I40E_ERR_PARAM ; - goto DONE; +return I40E_ERR_PARAM ; } req_list[i].flags =rte_cpu_to_le_16 (flags); }
@@ -7262,15 +7253,13 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, ret =I40E_SUCCESS ; }else {PMD_DRV_LOG (ERR ,"Failed to remove macvlan filter" ); - goto DONE; +return ret; } } num += actual_num; }while (num < total); -DONE: -rte_free (req_list); -return ret; +return I40E_SUCCESS ; }/* Find out specific MAC filter */
@@ -7438,7 +7427,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 ;
@@ -7467,7 +7456,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; }
@@ -7475,7 +7464,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)int i40e_vsi_add_vlan (struct i40e_vsi *vsi,uint16_t vlan) { -struct i40e_macvlan_filter *mv_f; +struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX ] = {0 };int mac_num;int ret =I40E_SUCCESS ;
@@ -7492,37 +7481,31 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)PMD_DRV_LOG (ERR ,"Error! VSI doesn't have a mac addr" );return I40E_ERR_PARAM ; } - - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); - -if (mv_f ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (mac_num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Error! Too many MAC addresses" ); +return I40E_ERR_PARAM ; } ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num, vlan);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_add_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret;i40e_set_vlan_filter (vsi, vlan,1 ); vsi->vlan_num++; - ret =I40E_SUCCESS ; -DONE: -rte_free (mv_f); -return ret; +return I40E_SUCCESS ; }int i40e_vsi_delete_vlan (struct i40e_vsi *vsi,uint16_t vlan) { -struct i40e_macvlan_filter *mv_f; +struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX ] = {0 };int mac_num;int ret =I40E_SUCCESS ;
@@ -7543,42 +7526,36 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)PMD_DRV_LOG (ERR ,"Error! VSI doesn't have a mac addr" );return I40E_ERR_PARAM ; } - - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); - -if (mv_f ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (mac_num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Error! Too many MAC addresses" ); +return I40E_ERR_PARAM ; } ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num, vlan);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_remove_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret;/* This is last vlan to remove, replace all mac filter with vlan 0 */ if (vsi->vlan_num ==1 ) { ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num,0 );if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_add_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; }i40e_set_vlan_filter (vsi, vlan,0 ); vsi->vlan_num--; - ret =I40E_SUCCESS ; -DONE: -rte_free (mv_f); -return ret; +return I40E_SUCCESS ; }int
@@ -7609,7 +7586,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 ;
@@ -7648,7 +7625,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; }
@@ -7679,7 +7656,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 ;
@@ -7708,7 +7685,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 +9 -8
@@ -2,6 +2,7 @@* Copyright(c) 2010-2017 Intel Corporation */ +#include <stdlib.h> #include <eal_export.h> #include <rte_string_fns.h> #include <rte_malloc.h>
@@ -233,7 +234,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 +251,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 +295,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 +313,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 v6 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 memory does not need to be stored in hugepage memory and the allocation size is pretty small, so replace it with stack allocation.
--- 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;struct i40e_hw *hw =I40E_PF_TO_HW (vf->pf); -uint32_t len =0 ; +uint32_t len =sizeof (res);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 v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +3 -7
@@ -6872,14 +6872,11 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct i40e_arq_event_info info;uint16_t pending, opcode; +uint8_t msg_buf[I40E_AQ_BUF_SZ ] = {0 };int ret; - info.buf_len =I40E_AQ_BUF_SZ ; - info.msg_buf =rte_zmalloc ("msg_buffer" , info.buf_len,0 ); -if (!info.msg_buf) { -PMD_DRV_LOG (ERR ,"Failed to allocate mem" ); -return ; - } + info.buf_len =sizeof (msg_buf); + info.msg_buf = msg_buf; pending =1 ;while (pending) {
@@ -6915,7 +6912,6 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)break ; } } -rte_free (info.msg_buf); } static void
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++---------------------- 1 file changed, 8 insertions(+), 35 deletions(-)
drivers/net/intel/i40e/rte_pmd_i40e.c +8 -35
@@ -1557,7 +1557,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) {struct rte_eth_dev *dev = &rte_eth_devices[port];struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); -uint8_t *buff; +uint8_t buff[(I40E_MAX_PROFILE_NUM +4 ) *I40E_PROFILE_INFO_SIZE ] = {0 };struct rte_pmd_i40e_profile_list *p_list;struct rte_pmd_i40e_profile_info *pinfo, *p;uint32_t i;
@@ -1570,13 +1570,6 @@ 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 ); -if (!buff) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return -1 ; - } ret = i40e_aq_get_ddp_list( hw, (void *)buff,
@@ -1584,7 +1577,6 @@ 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);return -1 ; } p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1592,20 +1584,17 @@ 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);return 1 ; } }/* profile with group id 0xff is compatible with any other profile */ if ((pinfo->track_id & group_mask) == group_mask) { -rte_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);return 2 ; } }
@@ -1616,12 +1605,9 @@ 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);return 3 ; } } - -rte_free (buff);return 0 ; }
@@ -1637,7 +1623,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 ;
@@ -1702,26 +1691,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 ; }
@@ -1734,13 +1712,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 ; } }
@@ -1752,7 +1728,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 {
@@ -1765,14 +1740,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." );
@@ -1785,7 +1759,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 v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation or regular calloc/free as appropriate.
--- drivers/net/intel/i40e/i40e_ethdev.c | 43 ++++++++-------------------- 1 file changed, 12 insertions(+), 31 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +12 -31
@@ -11718,8 +11718,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint32_t pctype_num; -struct rte_pmd_i40e_ptype_info *pctype; -uint32_t buff_size; +struct rte_pmd_i40e_ptype_info pctype[I40E_CUSTOMIZED_MAX ] = {0 };struct i40e_customized_pctype *new_pctype =NULL ;uint8_t proto_id;uint8_t pctype_value;
@@ -11745,19 +11744,16 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg,return -1 ; } - buff_size = pctype_num *sizeof (struct rte_pmd_i40e_proto_info ); - pctype =rte_zmalloc ("new_pctype" , buff_size,0 ); -if (!pctype) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); +if (pctype_num >RTE_DIM (pctype)) { +PMD_DRV_LOG (ERR ,"Pctype number exceeds maximum supported" );return -1 ; }/* get information about new pctype list */ ret =rte_pmd_i40e_get_ddp_info (pkg, pkg_size, - (uint8_t *)pctype, buff_size, + (uint8_t *)pctype,sizeof (pctype),RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST );if (ret) {PMD_DRV_LOG (ERR ,"Failed to get pctype list" ); -rte_free (pctype);return -1 ; }
@@ -11838,7 +11834,6 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype);return 0 ; }
@@ -11848,11 +11843,10 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, struct rte_pmd_i40e_proto_info *proto, enum rte_pmd_i40e_package_op op) { -struct rte_pmd_i40e_ptype_mapping *ptype_mapping; +struct rte_pmd_i40e_ptype_mapping ptype_mapping[I40E_MAX_PKT_TYPE ] = {0 };uint16_t port_id = dev->data->port_id;uint32_t ptype_num; -struct rte_pmd_i40e_ptype_info *ptype; -uint32_t buff_size; +struct rte_pmd_i40e_ptype_info ptype[I40E_MAX_PKT_TYPE ] = {0 };uint8_t proto_id;char name[RTE_PMD_I40E_DDP_NAME_SIZE ];uint32_t i, j, n;
@@ -11883,31 +11877,20 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,return -1 ; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_info ); - ptype =rte_zmalloc ("new_ptype" , buff_size,0 ); -if (!ptype) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); +if (ptype_num >RTE_DIM (ptype)) { +PMD_DRV_LOG (ERR ,"Too many ptypes" );return -1 ; }/* get information about new ptype list */ ret =rte_pmd_i40e_get_ddp_info (pkg, pkg_size, - (uint8_t *)ptype, buff_size, + (uint8_t *)ptype,sizeof (ptype),RTE_PMD_I40E_PKG_INFO_PTYPE_LIST );if (ret) {PMD_DRV_LOG (ERR ,"Failed to get ptype list" ); -rte_free (ptype);return ret; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_mapping ); - ptype_mapping =rte_zmalloc ("ptype_mapping" , buff_size,0 ); -if (!ptype_mapping) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -rte_free (ptype); -return -1 ; - } -/* Update ptype mapping table. */ for (i =0 ; i < ptype_num; i++) { ptype_mapping[i].hw_ptype = ptype[i].ptype_id;
@@ -12042,8 +12025,6 @@ 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);return ret; }
@@ -12078,7 +12059,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 ;
@@ -12090,7 +12071,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 ; }
@@ -12128,7 +12109,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 v6 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 v6 17/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.h | 1 + drivers/net/intel/iavf/iavf_ethdev.c | 3 +++ drivers/net/intel/iavf/iavf_hash.c | 12 ++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/intel/iavf/iavf.h +1 -0
@@ -566,4 +566,5 @@ void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);void iavf_handle_hw_reset (struct rte_eth_dev *dev,bool vf_initiated_reset);void iavf_set_no_poll (struct iavf_adapter *adapter,bool link_change);bool is_iavf_supported (struct rte_eth_dev *dev); +void iavf_hash_uninit (struct iavf_adapter *ad);#endif /* _IAVF_ETHDEV_H_ */
drivers/net/intel/iavf/iavf_ethdev.c +3 -0
@@ -2972,6 +2972,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 +8 -4
@@ -77,7 +77,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 +680,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 +1641,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 +1664,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
Signature · 1 line
2.47.3
PATCH v6 18/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 rte_malloc to allocate VF message structures. This memory does not need to be stored in hugepage memory and the allocation size is pretty small, so replace it with stack allocation.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 160 +++++++-------------- 1 file changed, 54 insertions(+), 106 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +54 -106
@@ -458,36 +458,25 @@ 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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp; + } sa_resp = {0 }; +struct inline_ipsec_msg *request = &sa_req.msg; +struct inline_ipsec_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 +530,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 +541,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 +708,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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp; + } sp_resp = {0 }; +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 +753,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 +767,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 +774,18 @@ 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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp ipsec_resp; + } sp_resp = {0 }; +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_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 +797,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 +809,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 +859,18 @@ 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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } sp_resp = {0 }; +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_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 +883,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 v6 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 memory does not need to be stored in hugepage memory, and in context of IAVF we do not define how big these structures can be, so replace the allocations 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
@@ -1553,7 +1553,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 ;
@@ -1573,7 +1573,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 v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
The original code also had a loop attempting to split up sending MAC address list into multiple virtchnl messages. However, maximum number of MAC addresses is 64, sizeof() each MAC address is 8 bytes, and maximum virtchnl message size is 4K, so splitting it up is actually unnecessary. This loop has been removed.
--- drivers/net/intel/iavf/iavf_vchnl.c | 82 ++++++++++------------------- 1 file changed, 29 insertions(+), 53 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +29 -53
@@ -1380,63 +1380,39 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,void iavf_add_del_all_mac_addr (struct iavf_adapter *adapter,bool add) { -struct virtchnl_ether_addr_list *list; +struct { +struct virtchnl_ether_addr_list list; +struct virtchnl_ether_addr addr[IAVF_NUM_MACADDR_MAX ]; + } list_req = {0 }; +struct virtchnl_ether_addr_list *list = &list_req.list;struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct rte_ether_addr *addr; -struct iavf_cmd_info args; -int len, err, i, j; -int next_begin =0 ; -int begin =0 ; +struct iavf_cmd_info args = {0 }; +int err, i; -do { - j =0 ; - len =sizeof (struct virtchnl_ether_addr_list ); -for (i = begin; i <IAVF_NUM_MACADDR_MAX ; i++, next_begin++) { - addr = &adapter->dev_data->mac_addrs[i]; -if (rte_is_zero_ether_addr (addr)) -continue ; - len +=sizeof (struct virtchnl_ether_addr ); -if (len >=IAVF_AQ_BUF_SZ ) { - next_begin = i +1 ; -break ; - } - } +for (i =0 ; i <IAVF_NUM_MACADDR_MAX ; i++) { +struct rte_ether_addr *addr = &adapter->dev_data->mac_addrs[i]; +struct virtchnl_ether_addr *vc_addr = &list->list[list->num_elements]; - list =rte_zmalloc ("iavf_del_mac_buffer" , len,0 ); -if (!list) { -PMD_DRV_LOG (ERR ,"fail to allocate memory" ); -return ; - } +/* ignore empty addresses */ +if (rte_is_zero_ether_addr (addr)) +continue ; + list->num_elements++; -for (i = begin; i < next_begin; i++) { - addr = &adapter->dev_data->mac_addrs[i]; -if (rte_is_zero_ether_addr (addr)) -continue ; -rte_memcpy (list->list[j].addr, addr->addr_bytes, -sizeof (addr->addr_bytes)); - list->list[j].type = (j ==0 ? -VIRTCHNL_ETHER_ADDR_PRIMARY : -VIRTCHNL_ETHER_ADDR_EXTRA ); -PMD_DRV_LOG (DEBUG ,"add/rm mac:" RTE_ETHER_ADDR_PRT_FMT , -RTE_ETHER_ADDR_BYTES (addr)); - j++; - } - list->vsi_id = vf->vsi_res->vsi_id; - list->num_elements = j; - args.ops = add ?VIRTCHNL_OP_ADD_ETH_ADDR : -VIRTCHNL_OP_DEL_ETH_ADDR ; - args.in_args = (uint8_t *)list; - args.in_args_size = len; - args.out_buffer = vf->aq_resp; - args.out_size =IAVF_AQ_BUF_SZ ; - err =iavf_execute_vf_cmd_safe (adapter, &args,0 ); -if (err) -PMD_DRV_LOG (ERR ,"fail to execute command %s" , - add ?"OP_ADD_ETHER_ADDRESS" : -"OP_DEL_ETHER_ADDRESS" ); -rte_free (list); - begin = next_begin; - }while (begin <IAVF_NUM_MACADDR_MAX ); +memcpy (vc_addr->addr, addr->addr_bytes,sizeof (addr->addr_bytes)); + vc_addr->type = (list->num_elements ==1 ) ? +VIRTCHNL_ETHER_ADDR_PRIMARY : +VIRTCHNL_ETHER_ADDR_EXTRA ; + } + list->vsi_id = vf->vsi_res->vsi_id; + args.ops = add ?VIRTCHNL_OP_ADD_ETH_ADDR :VIRTCHNL_OP_DEL_ETH_ADDR ; + args.in_args = (uint8_t *)list; + args.in_args_size =sizeof (list_req); + args.out_buffer = vf->aq_resp; + args.out_size =IAVF_AQ_BUF_SZ ; + err =iavf_execute_vf_cmd_safe (adapter, &args,0 ); +if (err) +PMD_DRV_LOG (ERR ,"fail to execute command %s" , + add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); }int
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory and the allocation size can be pretty small, so replace with stack allocation.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 122 +++++++-------------- 1 file changed, 38 insertions(+), 84 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +38 -84
@@ -3,6 +3,7 @@*/ #include <stdalign.h> +#include <stdlib.h> #include <rte_cryptodev.h> #include <rte_ethdev.h>
@@ -902,29 +903,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 = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_resp resp; + } resp = {0 }; +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 ;
@@ -942,10 +932,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 ||
@@ -960,10 +950,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; }
@@ -1109,51 +1095,35 @@ static int iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter, struct virtchnl_ipsec_cap *capability) { +struct { +struct inline_ipsec_msg msg; + } req = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_cap cap; + } resp = {0 };/* Perform pf-vf comms */ - struct inline_ipsec_msg *request = NULL, *response = NULL; -size_t request_len, response_len; +struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;int rc; - request_len =sizeof (struct inline_ipsec_msg ); - - request =rte_malloc ("iavf-device-capability-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-capability-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_GET_CAP ; request->req_id = (uint16_t )0xDEADBEEF ;/* 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 id */ if (response->ipsec_opcode != request->ipsec_opcode || response->req_id != request->req_id){ - rc = -EFAULT ; - goto update_cleanup; +return -EFAULT ; }memcpy (capability, response->ipsec_data.ipsec_cap,sizeof (*capability)); -update_cleanup: -rte_free (response); -rte_free (request); -return rc; }
@@ -1535,50 +1505,34 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter, struct virtchnl_ipsec_status *status) {/* Perform pf-vf comms */ -struct inline_ipsec_msg *request =NULL , *response =NULL ; -size_t request_len, response_len; +struct { +struct inline_ipsec_msg msg; + } req = {0 }; +struct { +struct inline_ipsec_msg msg; +struct virtchnl_ipsec_cap cap; + } resp = {0 }; +struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;int rc; - request_len =sizeof (struct inline_ipsec_msg ); - - request =rte_malloc ("iavf-device-status-request" , request_len,0 ); -if (request ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } - - response_len =sizeof (struct inline_ipsec_msg ) + -sizeof (struct virtchnl_ipsec_cap ); - response =rte_malloc ("iavf-device-status-response" , - response_len,0 ); -if (response ==NULL ) { - rc = -ENOMEM ; - goto update_cleanup; - } -/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_GET_STATUS ; request->req_id = (uint16_t )0xDEADBEEF ;/* 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 id */ if (response->ipsec_opcode != request->ipsec_opcode || - response->req_id != request->req_id){ - rc = -EFAULT ; - goto update_cleanup; + response->req_id != request->req_id){ +return -EFAULT ; }memcpy (status, response->ipsec_data.ipsec_status,sizeof (*status)); -update_cleanup: -rte_free (response); -rte_free (request); -return rc; }
Signature · 1 line
2.47.3
PATCH v6 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.
The original code did not check maximum queue number, because the design was built around an anti-pattern of caller having to chunk the queue configuration. This has now been corrected as well.
--- drivers/net/intel/iavf/iavf.h | 3 +- drivers/net/intel/iavf/iavf_ethdev.c | 15 +- drivers/net/intel/iavf/iavf_vchnl.c | 212 ++++++++++++++------------- 3 files changed, 115 insertions(+), 115 deletions(-)
drivers/net/intel/iavf/iavf.h +1 -2
@@ -503,8 +503,7 @@ int iavf_disable_queues(struct iavf_adapter *adapter);int iavf_disable_queues_lv (struct iavf_adapter *adapter);int iavf_configure_rss_lut (struct iavf_adapter *adapter);int iavf_configure_rss_key (struct iavf_adapter *adapter); -int iavf_configure_queues (struct iavf_adapter *adapter, -uint16_t num_queue_pairs,uint16_t index); +int iavf_configure_queues (struct iavf_adapter *adapter,uint16_t num_queue_pairs);int iavf_get_supported_rxdid (struct iavf_adapter *adapter);int iavf_config_vlan_strip_v2 (struct iavf_adapter *adapter,bool enable);int iavf_config_vlan_insert_v2 (struct iavf_adapter *adapter,bool enable);
drivers/net/intel/iavf/iavf_ethdev.c +1 -14
@@ -1036,20 +1036,7 @@ iavf_dev_start(struct rte_eth_dev *dev)if (iavf_set_vf_quanta_size (adapter, index, num_queue_pairs) !=0 )PMD_DRV_LOG (WARNING ,"configure quanta size failed" ); -/* If needed, send configure queues msg multiple times to make the -* adminq buffer length smaller than the 4K limitation. -*/ -while (num_queue_pairs >IAVF_CFG_Q_NUM_PER_BUF ) { -if (iavf_configure_queues (adapter, -IAVF_CFG_Q_NUM_PER_BUF , index) !=0 ) { -PMD_DRV_LOG (ERR ,"configure queues failed" ); - goto error; - } - num_queue_pairs -=IAVF_CFG_Q_NUM_PER_BUF ; - index +=IAVF_CFG_Q_NUM_PER_BUF ; - } - -if (iavf_configure_queues (adapter, num_queue_pairs, index) !=0 ) { +if (iavf_configure_queues (adapter, num_queue_pairs) !=0 ) {PMD_DRV_LOG (ERR ,"configure queues failed" ); goto error; }
drivers/net/intel/iavf/iavf_vchnl.c +113 -99
298 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
The original code did not check maximum IRQ map size, because the design was built around an anti-pattern of caller having to chunk the IRQ map calls. This has now been corrected as well.
--- drivers/net/intel/iavf/iavf.h | 3 +- drivers/net/intel/iavf/iavf_ethdev.c | 15 +--- drivers/net/intel/iavf/iavf_vchnl.c | 110 +++++++++++++++++---------- 3 files changed, 72 insertions(+), 56 deletions(-)
drivers/net/intel/iavf/iavf.h +1 -2
@@ -511,8 +511,7 @@ int iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add);int iavf_get_vlan_offload_caps_v2 (struct iavf_adapter *adapter);int iavf_config_irq_map (struct iavf_adapter *adapter); -int iavf_config_irq_map_lv (struct iavf_adapter *adapter,uint16_t num, -uint16_t index); +int iavf_config_irq_map_lv (struct iavf_adapter *adapter,uint16_t num);void iavf_add_del_all_mac_addr (struct iavf_adapter *adapter,bool add);int iavf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete);
drivers/net/intel/iavf/iavf_ethdev.c +1 -14
@@ -919,20 +919,7 @@ static int iavf_config_rx_queues_irqs(struct rte_eth_dev *dev, goto config_irq_map_err; } }else { -uint16_t num_qv_maps = dev->data->nb_rx_queues; -uint16_t index =0 ; - -while (num_qv_maps >IAVF_IRQ_MAP_NUM_PER_BUF ) { -if (iavf_config_irq_map_lv (adapter, -IAVF_IRQ_MAP_NUM_PER_BUF , index)) { -PMD_DRV_LOG (ERR ,"config interrupt mapping for large VF failed" ); - goto config_irq_map_err; - } - num_qv_maps -=IAVF_IRQ_MAP_NUM_PER_BUF ; - index +=IAVF_IRQ_MAP_NUM_PER_BUF ; - } - -if (iavf_config_irq_map_lv (adapter, num_qv_maps, index)) { +if (iavf_config_irq_map_lv (adapter, dev->data->nb_rx_queues)) {PMD_DRV_LOG (ERR ,"config interrupt mapping for large VF failed" ); goto config_irq_map_err; }
drivers/net/intel/iavf/iavf_vchnl.c +70 -40
151 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_ethdev.c | 29 ++++++-------------------- 2 files changed, 8 insertions(+), 25 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 +6 -23
@@ -5566,7 +5566,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,struct ice_pf *pf =ICE_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K ] = {0 };int ret; if (reta_size != ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128 &&
@@ -5583,14 +5583,9 @@ 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 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } ret =ice_get_rss_lut (pf->main_vsi, lut, lut_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ;
@@ -5606,10 +5601,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev, pf->hash_lut_size = reta_size; } -out: -rte_free (lut); - -return ret; +return 0 ; } static int
@@ -5620,7 +5612,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,struct ice_pf *pf =ICE_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K ] = {0 };int ret;if (reta_size != lut_size) {
@@ -5632,15 +5624,9 @@ ice_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc (NULL , reta_size,0 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } - ret =ice_get_rss_lut (pf->main_vsi, lut, reta_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ;
@@ -5649,10 +5635,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev, reta_conf[idx].reta[shift] = lut[i]; } -out: -rte_free (lut); - -return ret; +return 0 ; } static int
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/ice/ice_dcf_ethdev.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/net/intel/ice/ice_dcf_ethdev.c +8 -14
@@ -928,19 +928,14 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw, struct rte_ether_addr *mc_addrs, uint32_t mc_addrs_num, bool add) { - struct virtchnl_ether_addr_list *list; -struct dcf_virtchnl_cmd args; +struct { +struct virtchnl_ether_addr_list list; +struct virtchnl_ether_addr addr[DCF_NUM_MACADDR_MAX ]; + } list_req = {0 }; +struct virtchnl_ether_addr_list *list = &list_req.list; +struct dcf_virtchnl_cmd args = {0 };uint32_t i; -int len, err =0 ; - - len =sizeof (struct virtchnl_ether_addr_list ); - len +=sizeof (struct virtchnl_ether_addr ) * mc_addrs_num; - - list =rte_zmalloc (NULL , len,0 ); -if (!list) { -PMD_DRV_LOG (ERR ,"fail to allocate memory" ); -return -ENOMEM ; - } +int err =0 ;for (i =0 ; i < mc_addrs_num; i++) { memcpy(list->list[i].addr, mc_addrs[i].addr_bytes,
@@ -955,13 +950,12 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw, args.v_op = add ?VIRTCHNL_OP_ADD_ETH_ADDR :VIRTCHNL_OP_DEL_ETH_ADDR ; args.req_msg = (uint8_t *)list; - args.req_msglen = len; + args.req_msglen =sizeof (list_req); err =ice_dcf_execute_virtchnl_cmd (hw, &args);if (err)PMD_DRV_LOG (ERR ,"fail to execute command %s" , add ?"OP_ADD_ETHER_ADDRESS" :"OP_DEL_ETHER_ADDRESS" ); -rte_free (list);return err; }
Signature · 1 line
2.47.3
PATCH v6 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 memory does not need to be stored in hugepage memory, 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 v6 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 memory does not need to be stored in hugepage memory, so replace it with regular malloc/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 v6 00/27] Cleanups for ixgbe, i40e, iavf, and ice PMD's
In reply to Anatoly BurakovQuoted 1 line · On Thu, 19 Feb 2026 16:22:43 +0000 Anatoly Burakov <[email protected]>…
This patchset is an assortment of cleanups for ixgbe, i40e, iavf, and ice PMD.
AI review had some observations here:
Patch 20/27: net/iavf: avoid rte malloc in MAC address operations
in_args_size is always sizeof(list_req) (full 64-entry struct) regardless of how many addresses are populated. The old code computed an exact-fit length. Probably harmless since num_elements governs PF-side parsing, but worth verifying.
Patch 21/27: net/iavf: avoid rte malloc in IPsec operations
Pre-existing: iavf_ipsec_crypto_status_get() response struct uses struct virtchnl_ipsec_cap but the function reads ipsec_status. The old code had the same mismatch. Since you're refactoring this function, consider fixing the response type to struct virtchnl_ipsec_status.
Patch 23/27: net/iavf: avoid rte malloc in irq map config
iavf_config_irq_map_lv_chunk(): double-offset bug. The loop runs for (i = chunk_start; i < chunk_end; i++) but then indexes map_info->qv_maps[i] (should be [i - chunk_start]) and vf->qv_map[chunk_start + i] (should be [i]). For the second chunk, this writes past the local array and reads the wrong qv_map entries. iavf_config_irq_map(): the num_vectors counting via if (vmi > max_vmi) only works if vector IDs are assigned in monotonically increasing order across the queue iteration. If not (e.g., round-robin where a lower vmi appears after a higher one), the count will be too low. The old code simply used vf->nb_msix which is always correct.
Re: [PATCH v6 00/27] Cleanups for ixgbe, i40e, iavf, and ice PMD's
Quoted 6 lines · Stephen Hemminger
Quoted 1 line · On Thu, 19 Feb 2026 16:22:43 +0000 Anatoly Burakov <[email protected]>…
This patchset is an assortment of cleanups for ixgbe, i40e, iavf, and ice PMD.
AI review had some observations here:
Thanks Stephen!
Quoted 5 lines
Patch 20/27: net/iavf: avoid rte malloc in MAC address operations
in_args_sizeis alwayssizeof(list_req)(full 64-entry struct) regardless of how many addresses are populated. The old code computed an exact-fit length. Probably harmless sincenum_elementsgoverns PF-side parsing, but worth verifying.
This is intentional.
Quoted 3 lines
Patch 21/27: net/iavf: avoid rte malloc in IPsec operations
Pre-existing:
iavf_ipsec_crypto_status_get()response struct uses structvirtchnl_ipsec_capbut the function readsipsec_status. The old code had the same mismatch. Since you're refactoring this function, consider fixing the response type to structvirtchnl_ipsec_status.
Since this is a pre-existing bug, we need to fix it and backport it separately. Good find!
Quoted 4 lines
Patch 23/27: net/iavf: avoid rte malloc in irq map config
iavf_config_irq_map_lv_chunk(): double-offset bug. The loop runs for (i =chunk_start; i <chunk_end; i++) but then indexes map_info->qv_maps[i] (should be [i -chunk_start]) and vf->qv_map[chunk_start + i] (should be [i]). For the second chunk, this writes past the local array and reads the wrongqv_mapentries.
Good catch, will fix.
Quoted 1 line
iavf_config_irq_map(): thenum_vectorscounting via if (vmi >max_vmi) only works if vector IDs are assigned in monotonically increasing order across the queue iteration. If not (e.g., round-robin where a lower vmi appears after a higher one), the count will be too low. The old code simply usedvf->nb_msixwhich is always correct.
That is how it happens. The reason I changed it in the first place is because *technically* there is no "max value" we can use here that would be suitable to use because nb_msix comes from VF mailbox. We do, however, know that vector ID's *are* assigned monotonically and in a round-robin fashion, and in fact code comments indicate that this is the assumption.
Signature · 2 lines
Thanks, Anatoly
v7 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) as well as an IPsec struct fix [2].
[1] https://patches.dpdk.org/project/dpdk/list/?series=37350
[2] https://patches.dpdk.org/project/dpdk/patch/c87355f75826ec90a506dc8d4548e3f6af2b7e93.1771581658.git.anatoly.burakov@intel.com/
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
v4 -> v5:
- Adjusted typing for queue size
- Fixed missing zero initializations for stack allocations
v5 -> v6:
- Addressed feedback for v3, v4, and v5
- Changed more allocations to be stack based
- Reworked queue and IRQ map related i40e patches for better logic
v6 -> v7:
- Fixed offset logic in IRQ map
- (Hopefully) fixed zero-sized array initialization error for MSVC
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: decouple hash uninit from parser uninit net/iavf: avoid rte malloc in VF mailbox for IPsec 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 | 370 +++++++---------- drivers/net/intel/i40e/i40e_ethdev.h | 26 +- drivers/net/intel/i40e/i40e_flow.c | 147 ++++--- 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 | 60 +-- drivers/net/intel/iavf/iavf.h | 7 +- drivers/net/intel/iavf/iavf_ethdev.c | 37 +- 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 | 13 +- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 320 ++++++-------- drivers/net/intel/iavf/iavf_vchnl.c | 413 ++++++++++--------- drivers/net/intel/ice/ice_acl_filter.c | 3 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 26 +- drivers/net/intel/ice/ice_ethdev.c | 29 +- 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 | 228 ++++++---- 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, 826 insertions(+), 1036 deletions(-)
Signature · 1 line
2.47.3
PATCH v7 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 v7 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
@@ -460,7 +460,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;
@@ -474,7 +473,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] =
@@ -631,9 +629,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 ;
@@ -661,9 +657,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 ;
@@ -675,7 +669,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 *)
@@ -683,7 +676,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,
@@ -871,10 +863,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 {
@@ -1505,13 +1495,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; }
@@ -2472,9 +2460,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 &&
@@ -2629,9 +2615,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;
@@ -2692,10 +2676,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; }
@@ -2873,10 +2855,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
@@ -3170,10 +3150,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; }
@@ -5101,10 +5079,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 } }
@@ -5610,7 +5586,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 &
@@ -5623,7 +5598,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 v7 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 | 202 ++++++++++++++++----------- 1 file changed, 122 insertions(+), 80 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +122 -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,112 @@ 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; +int ret; + +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. the latter path was chosen. +*/ + session = RTE_CAST_PTR(struct rte_security_session *, security->security_session); + ret =ixgbe_crypto_add_ingress_sa_from_flow (session, &spec); +if (ret) { +rte_flow_error_set (error, -ret, +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Failed to add security session." ); +return -rte_errno; + } +return 0 ; +} +/* a specific function for ixgbe because the flags is specific */ static int ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
@@ -661,10 +699,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 +3133,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 +3369,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 v7 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 v7 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
@@ -9080,23 +9080,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 v7 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 16-bit, 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 | 11 ++++++----- drivers/net/intel/i40e/i40e_ethdev.h | 8 ++++---- drivers/net/intel/i40e/i40e_hash.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +6 -5
@@ -8976,11 +8976,12 @@ i40e_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, }/* Calculate the maximum number of contiguous PF queues that are configured */ -int +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf) {struct rte_eth_dev_data *data = pf->dev_data; -int i, num; +int i; +uint16_t num;struct ci_rx_queue *rxq; num =0 ;
@@ -9056,7 +9057,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; +uint16_t num;/* If both VMDQ and RSS enabled, not all of PF queues are * configured. It's necessary to calculate the actual PF
@@ -9072,7 +9073,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)return 0 ;for (i =0 ; i < hw->func_caps.rss_table_size; i++) - lut[i] = (uint8_t )(i % (uint32_t )num); + lut[i] = (uint8_t )(i % num);return i40e_set_rss_lut (pf->main_vsi, lut, (uint16_t )i); }
@@ -10769,7 +10770,7 @@ i40e_vsi_update_queue_mapping(struct i40e_vsi *vsi,PMD_INIT_LOG (ERR ," number of queues is less that tcs." );return I40E_ERR_INVALID_QP_ID ; } - qpnum_per_tc =RTE_MIN (i40e_align_floor (qpnum_per_tc), + qpnum_per_tc =RTE_MIN ((uint16_t )i40e_align_floor (qpnum_per_tc),I40E_MAX_Q_PER_TC ); bsf =rte_bsf32 (qpnum_per_tc);
drivers/net/intel/i40e/i40e_ethdev.h +4 -4
@@ -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 UINT16_C(64)#define I40E_NUM_DESC_DEFAULT 512#define I40E_NUM_DESC_ALIGN 32#define I40E_BUF_SIZE_MIN 1024
@@ -1456,7 +1456,7 @@ int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,void i40e_init_queue_region_conf (struct rte_eth_dev *dev);void i40e_flex_payload_reg_set_default (struct i40e_hw *hw);void i40e_pf_disable_rss (struct i40e_pf *pf); -int i40e_pf_calc_configured_queues_num (struct i40e_pf *pf); +uint16_t i40e_pf_calc_configured_queues_num (struct i40e_pf *pf);int i40e_pf_reset_rss_reta (struct i40e_pf *pf);int i40e_pf_reset_rss_key (struct i40e_pf *pf);int i40e_pf_config_rss (struct i40e_pf *pf);
@@ -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; +uint16_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 v7 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 v7 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 | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +10 -20
@@ -9,6 +9,7 @@#include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <rte_debug.h> #include <rte_ether.h>
@@ -145,9 +146,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 +3835,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 +3854,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 +3864,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 v7 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 memory does not need to be stored in hugepage memory and the allocation size is pretty small, 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
@@ -8509,38 +8509,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++) {
@@ -8548,9 +8537,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 */
@@ -8571,11 +8560,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 ;
@@ -8587,11 +8576,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 ;
@@ -8603,11 +8592,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 ;
@@ -8618,11 +8607,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 ;
@@ -8639,8 +8628,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 :
@@ -8655,20 +8644,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 {
@@ -8680,20 +8669,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 ; }
@@ -8702,48 +8691,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)
@@ -8751,7 +8738,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];
@@ -8760,38 +8746,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 ; }
@@ -8802,19 +8786,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 v7 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 memory does not need to be stored in hugepage memory and the maximum LUT size is 512 bytes, so replace it with stack-based allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +4 -21
@@ -4619,7 +4619,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ] = {0 };int ret; if (reta_size != lut_size ||
@@ -4630,14 +4630,9 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } ret =i40e_get_rss_lut (pf->main_vsi, lut, reta_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ;
@@ -4648,9 +4643,6 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev, pf->adapter->rss_reta_updated =1 ; -out: -rte_free (lut); -return ret; }
@@ -4662,7 +4654,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint16_t i, lut_size = pf->hash_lut_size;uint16_t idx, shift; -uint8_t *lut; +uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512 ] = {0 };int ret; if (reta_size != lut_size ||
@@ -4673,15 +4665,9 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,return -EINVAL ; } - lut =rte_zmalloc ("i40e_rss_lut" , reta_size,0 ); -if (!lut) { -PMD_DRV_LOG (ERR ,"No memory can be allocated" ); -return -ENOMEM ; - } - ret =i40e_get_rss_lut (pf->main_vsi, lut, reta_size);if (ret) - goto out; +return ret;for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ;
@@ -4689,9 +4675,6 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev, reta_conf[idx].reta[shift] = lut[i]; } -out: -rte_free (lut); -return ret; }
Signature · 1 line
2.47.3
PATCH v7 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 memory does not need to be stored in hugepage memory, so replace it with regular malloc/free or stack allocation where appropriate.
--- drivers/net/intel/i40e/i40e_ethdev.c | 135 +++++++++++--------------- drivers/net/intel/i40e/rte_pmd_i40e.c | 17 ++-- 2 files changed, 65 insertions(+), 87 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +56 -79
@@ -6,6 +6,7 @@#include <stdio.h> #include <errno.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdarg.h>
@@ -4128,7 +4129,6 @@ static int i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -struct i40e_mac_filter_info *mac_filter;struct i40e_vsi *vsi = pf->main_vsi;struct rte_eth_rxmode *rxmode;struct i40e_mac_filter *f;
@@ -4163,12 +4163,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) }if (mask &RTE_ETH_VLAN_EXTEND_MASK ) { +struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX ] = {0 }; i =0 ; num = vsi->mac_num; - mac_filter =rte_zmalloc ("mac_filter_info_data" , - num *sizeof (*mac_filter),0 ); -if (mac_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); + +if (num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Too many MAC addresses" );return I40E_ERR_NO_MEMORY ; }
@@ -4206,7 +4206,6 @@ 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); }if (mask &RTE_ETH_QINQ_STRIP_MASK ) {
@@ -6198,7 +6197,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)int i, num;struct i40e_mac_filter *f;void *temp; -struct i40e_mac_filter_info *mac_filter; +struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX ] = {0 };enum i40e_mac_filter_type desired_filter;int ret =I40E_SUCCESS ;
@@ -6211,12 +6210,9 @@ 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 ); -if (mac_filter ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Too many MAC addresses" ); +return -1 ; } i =0 ;
@@ -6228,7 +6224,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)if (ret) {PMD_DRV_LOG (ERR ,"Update VSI failed to %s vlan filter" , on ?"enable" :"disable" ); - goto DONE; +return ret; } i++; }
@@ -6240,13 +6236,11 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)if (ret) {PMD_DRV_LOG (ERR ,"Update VSI failed to %s vlan filter" , on ?"enable" :"disable" ); - goto DONE; +return ret; } } -DONE: -rte_free (mac_filter); -return ret; +return 0 ; }/* Configure vlan stripping on or off */
@@ -7128,19 +7122,20 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,uint16_t flags;int ret =I40E_SUCCESS ;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi); -struct i40e_aqc_add_macvlan_element_data *req_list; +uint8_t aq_buff[I40E_AQ_BUF_SZ ] = {0 }; +struct i40e_aqc_add_macvlan_element_data *req_list = + (struct i40e_aqc_add_macvlan_element_data *)aq_buff; + +if (hw->aq.asq_buf_size >I40E_AQ_BUF_SZ ) { +PMD_DRV_LOG (ERR ,"AdminQ size biffer than max" ); +return I40E_ERR_NO_MEMORY ; + }if (filter ==NULL || total ==0 )return I40E_ERR_PARAM ; 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 ); -if (req_list ==NULL ) { -PMD_DRV_LOG (ERR ,"Fail to allocate memory" ); -return I40E_ERR_NO_MEMORY ; - } - num =0 ; do { actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7169,8 +7164,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,break ;default :PMD_DRV_LOG (ERR ,"Invalid MAC match type" ); - ret =I40E_ERR_PARAM ; - goto DONE; +return I40E_ERR_PARAM ; } req_list[i].queue_number =0 ;
@@ -7182,14 +7176,11 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi, actual_num, NULL);if (ret !=I40E_SUCCESS ) {PMD_DRV_LOG (ERR ,"Failed to add macvlan filter" ); - goto DONE; +return ret; } num += actual_num; }while (num < total); - -DONE: -rte_free (req_list); -return ret; +return I40E_SUCCESS ; }int
@@ -7202,21 +7193,22 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,uint16_t flags;int ret =I40E_SUCCESS ;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi); -struct i40e_aqc_remove_macvlan_element_data *req_list; +uint8_t aq_buff[I40E_AQ_BUF_SZ ] = {0 }; +struct i40e_aqc_remove_macvlan_element_data *req_list = + (struct i40e_aqc_remove_macvlan_element_data *)aq_buff;enum i40e_admin_queue_err aq_status;if (filter ==NULL || total ==0 )return I40E_ERR_PARAM ; - 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 ); -if (req_list ==NULL ) { -PMD_DRV_LOG (ERR ,"Fail to allocate memory" ); +if (hw->aq.asq_buf_size >I40E_AQ_BUF_SZ ) { +PMD_DRV_LOG (ERR ,"AdminQ size biffer than max" );return I40E_ERR_NO_MEMORY ; } + ele_num = hw->aq.asq_buf_size /sizeof (*req_list); + ele_buff_size = hw->aq.asq_buf_size; + num =0 ; do { actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7245,8 +7237,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,break ;default :PMD_DRV_LOG (ERR ,"Invalid MAC filter type" ); - ret =I40E_ERR_PARAM ; - goto DONE; +return I40E_ERR_PARAM ; } req_list[i].flags =rte_cpu_to_le_16 (flags); }
@@ -7260,15 +7251,13 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi, ret =I40E_SUCCESS ; }else {PMD_DRV_LOG (ERR ,"Failed to remove macvlan filter" ); - goto DONE; +return ret; } } num += actual_num; }while (num < total); -DONE: -rte_free (req_list); -return ret; +return I40E_SUCCESS ; }/* Find out specific MAC filter */
@@ -7436,7 +7425,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 ;
@@ -7465,7 +7454,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; }
@@ -7473,7 +7462,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)int i40e_vsi_add_vlan (struct i40e_vsi *vsi,uint16_t vlan) { -struct i40e_macvlan_filter *mv_f; +struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX ] = {0 };int mac_num;int ret =I40E_SUCCESS ;
@@ -7490,37 +7479,31 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)PMD_DRV_LOG (ERR ,"Error! VSI doesn't have a mac addr" );return I40E_ERR_PARAM ; } - - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); - -if (mv_f ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (mac_num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Error! Too many MAC addresses" ); +return I40E_ERR_PARAM ; } ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num, vlan);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_add_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret;i40e_set_vlan_filter (vsi, vlan,1 ); vsi->vlan_num++; - ret =I40E_SUCCESS ; -DONE: -rte_free (mv_f); -return ret; +return I40E_SUCCESS ; }int i40e_vsi_delete_vlan (struct i40e_vsi *vsi,uint16_t vlan) { -struct i40e_macvlan_filter *mv_f; +struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX ] = {0 };int mac_num;int ret =I40E_SUCCESS ;
@@ -7541,42 +7524,36 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)PMD_DRV_LOG (ERR ,"Error! VSI doesn't have a mac addr" );return I40E_ERR_PARAM ; } - - mv_f =rte_zmalloc ("macvlan_data" , mac_num *sizeof (*mv_f),0 ); - -if (mv_f ==NULL ) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return I40E_ERR_NO_MEMORY ; +if (mac_num >I40E_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR ,"Error! Too many MAC addresses" ); +return I40E_ERR_PARAM ; } ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num, vlan);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_remove_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret;/* This is last vlan to remove, replace all mac filter with vlan 0 */ if (vsi->vlan_num ==1 ) { ret =i40e_find_all_mac_for_vlan (vsi, mv_f, mac_num,0 );if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; ret =i40e_add_macvlan_filters (vsi, mv_f, mac_num);if (ret !=I40E_SUCCESS ) - goto DONE; +return ret; }i40e_set_vlan_filter (vsi, vlan,0 ); vsi->vlan_num--; - ret =I40E_SUCCESS ; -DONE: -rte_free (mv_f); -return ret; +return I40E_SUCCESS ; }int
@@ -7607,7 +7584,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 ;
@@ -7646,7 +7623,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; }
@@ -7677,7 +7654,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 ;
@@ -7706,7 +7683,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 +9 -8
@@ -2,6 +2,7 @@* Copyright(c) 2010-2017 Intel Corporation */ +#include <stdlib.h> #include <eal_export.h> #include <rte_string_fns.h> #include <rte_malloc.h>
@@ -233,7 +234,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 +251,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 +295,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 +313,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 v7 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 memory does not need to be stored in hugepage memory and the allocation size is pretty small, so replace it with stack allocation.
--- 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;struct i40e_hw *hw =I40E_PF_TO_HW (vf->pf); -uint32_t len =0 ; +uint32_t len =sizeof (res);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 v7 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/i40e/i40e_ethdev.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +3 -7
@@ -6870,14 +6870,11 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct i40e_arq_event_info info;uint16_t pending, opcode; +uint8_t msg_buf[I40E_AQ_BUF_SZ ] = {0 };int ret; - info.buf_len =I40E_AQ_BUF_SZ ; - info.msg_buf =rte_zmalloc ("msg_buffer" , info.buf_len,0 ); -if (!info.msg_buf) { -PMD_DRV_LOG (ERR ,"Failed to allocate mem" ); -return ; - } + info.buf_len =sizeof (msg_buf); + info.msg_buf = msg_buf; pending =1 ;while (pending) {
@@ -6913,7 +6910,6 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)break ; } } -rte_free (info.msg_buf); } static void
Signature · 1 line
2.47.3
PATCH v7 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation.
--- drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++---------------------- 1 file changed, 8 insertions(+), 35 deletions(-)
drivers/net/intel/i40e/rte_pmd_i40e.c +8 -35
@@ -1557,7 +1557,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) {struct rte_eth_dev *dev = &rte_eth_devices[port];struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); -uint8_t *buff; +uint8_t buff[(I40E_MAX_PROFILE_NUM +4 ) *I40E_PROFILE_INFO_SIZE ] = {0 };struct rte_pmd_i40e_profile_list *p_list;struct rte_pmd_i40e_profile_info *pinfo, *p;uint32_t i;
@@ -1570,13 +1570,6 @@ 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 ); -if (!buff) { -PMD_DRV_LOG (ERR ,"failed to allocate memory" ); -return -1 ; - } ret = i40e_aq_get_ddp_list( hw, (void *)buff,
@@ -1584,7 +1577,6 @@ 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);return -1 ; } p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1592,20 +1584,17 @@ 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);return 1 ; } }/* profile with group id 0xff is compatible with any other profile */ if ((pinfo->track_id & group_mask) == group_mask) { -rte_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);return 2 ; } }
@@ -1616,12 +1605,9 @@ 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);return 3 ; } } - -rte_free (buff);return 0 ; }
@@ -1637,7 +1623,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 ;
@@ -1702,26 +1691,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 ; }
@@ -1734,13 +1712,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 ; } }
@@ -1752,7 +1728,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 {
@@ -1765,14 +1740,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." );
@@ -1785,7 +1759,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 v7 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 memory does not need to be stored in hugepage memory, so replace it with stack allocation or regular calloc/free as appropriate.
--- drivers/net/intel/i40e/i40e_ethdev.c | 43 ++++++++-------------------- 1 file changed, 12 insertions(+), 31 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +12 -31
@@ -11716,8 +11716,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);uint32_t pctype_num; -struct rte_pmd_i40e_ptype_info *pctype; -uint32_t buff_size; +struct rte_pmd_i40e_ptype_info pctype[I40E_CUSTOMIZED_MAX ] = {0 };struct i40e_customized_pctype *new_pctype =NULL ;uint8_t proto_id;uint8_t pctype_value;
@@ -11743,19 +11742,16 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg,return -1 ; } - buff_size = pctype_num *sizeof (struct rte_pmd_i40e_proto_info ); - pctype =rte_zmalloc ("new_pctype" , buff_size,0 ); -if (!pctype) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); +if (pctype_num >RTE_DIM (pctype)) { +PMD_DRV_LOG (ERR ,"Pctype number exceeds maximum supported" );return -1 ; }/* get information about new pctype list */ ret =rte_pmd_i40e_get_ddp_info (pkg, pkg_size, - (uint8_t *)pctype, buff_size, + (uint8_t *)pctype,sizeof (pctype),RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST );if (ret) {PMD_DRV_LOG (ERR ,"Failed to get pctype list" ); -rte_free (pctype);return -1 ; }
@@ -11836,7 +11832,6 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, } } -rte_free (pctype);return 0 ; }
@@ -11846,11 +11841,10 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, struct rte_pmd_i40e_proto_info *proto, enum rte_pmd_i40e_package_op op) { -struct rte_pmd_i40e_ptype_mapping *ptype_mapping; +struct rte_pmd_i40e_ptype_mapping ptype_mapping[I40E_MAX_PKT_TYPE ] = {0 };uint16_t port_id = dev->data->port_id;uint32_t ptype_num; -struct rte_pmd_i40e_ptype_info *ptype; -uint32_t buff_size; +struct rte_pmd_i40e_ptype_info ptype[I40E_MAX_PKT_TYPE ] = {0 };uint8_t proto_id;char name[RTE_PMD_I40E_DDP_NAME_SIZE ];uint32_t i, j, n;
@@ -11881,31 +11875,20 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,return -1 ; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_info ); - ptype =rte_zmalloc ("new_ptype" , buff_size,0 ); -if (!ptype) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); +if (ptype_num >RTE_DIM (ptype)) { +PMD_DRV_LOG (ERR ,"Too many ptypes" );return -1 ; }/* get information about new ptype list */ ret =rte_pmd_i40e_get_ddp_info (pkg, pkg_size, - (uint8_t *)ptype, buff_size, + (uint8_t *)ptype,sizeof (ptype),RTE_PMD_I40E_PKG_INFO_PTYPE_LIST );if (ret) {PMD_DRV_LOG (ERR ,"Failed to get ptype list" ); -rte_free (ptype);return ret; } - buff_size = ptype_num *sizeof (struct rte_pmd_i40e_ptype_mapping ); - ptype_mapping =rte_zmalloc ("ptype_mapping" , buff_size,0 ); -if (!ptype_mapping) { -PMD_DRV_LOG (ERR ,"Failed to allocate memory" ); -rte_free (ptype); -return -1 ; - } -/* Update ptype mapping table. */ for (i =0 ; i < ptype_num; i++) { ptype_mapping[i].hw_ptype = ptype[i].ptype_id;
@@ -12040,8 +12023,6 @@ 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);return ret; }
@@ -12076,7 +12057,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 ;
@@ -12088,7 +12069,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 ; }
@@ -12126,7 +12107,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 v7 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 v7 17/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.h | 1 + drivers/net/intel/iavf/iavf_ethdev.c | 3 +++ drivers/net/intel/iavf/iavf_hash.c | 12 ++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/intel/iavf/iavf.h +1 -0
@@ -566,4 +566,5 @@ void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);void iavf_handle_hw_reset (struct rte_eth_dev *dev,bool vf_initiated_reset);void iavf_set_no_poll (struct iavf_adapter *adapter,bool link_change);bool is_iavf_supported (struct rte_eth_dev *dev); +void iavf_hash_uninit (struct iavf_adapter *ad);#endif /* _IAVF_ETHDEV_H_ */
drivers/net/intel/iavf/iavf_ethdev.c +3 -0
@@ -2977,6 +2977,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 +8 -4
@@ -77,7 +77,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 +680,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 +1641,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 +1664,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
Signature · 1 line
2.47.3
PATCH v7 18/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 rte_malloc to allocate VF message structures. This memory does not need to be stored in hugepage memory and the allocation size is pretty small, so replace it with stack allocation.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 181 +++++++++------------ 1 file changed, 78 insertions(+), 103 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +78 -103
@@ -458,36 +458,31 @@ 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; +struct inline_ipsec_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; - } +/* +* MSVC doesn't allow inline initialization of structs with zero-sized +* members so we have to memset them instead. +*/ +memset (&sa_req,0 ,sizeof (sa_req)); +memset (&sa_resp,0 ,sizeof (sa_resp));/* 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 +536,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 +547,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,18 +714,24 @@ 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; - } +/* +* MSVC doesn't allow inline initialization of structs with zero-sized +* members so we have to memset them instead. +*/ +memset (&sp_req,0 ,sizeof (sp_req)); +memset (&sp_resp,0 ,sizeof (sp_resp));/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_CREATE ;
@@ -768,21 +766,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 +780,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,25 +787,24 @@ 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; +struct inline_ipsec_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; - } +/* +* MSVC doesn't allow inline initialization of structs with zero-sized +* members so we have to memset them instead. +*/ +memset (&sp_req,0 ,sizeof (sp_req)); +memset (&sp_resp,0 ,sizeof (sp_resp));/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SA_UPDATE ;
@@ -833,10 +817,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 +829,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,25 +879,24 @@ 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; +struct inline_ipsec_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; - } +/* +* MSVC doesn't allow inline initialization of structs with zero-sized +* members so we have to memset them instead. +*/ +memset (&sp_req,0 ,sizeof (sp_req)); +memset (&sp_resp,0 ,sizeof (sp_resp));/* set msg header params */ request->ipsec_opcode =INLINE_IPSEC_OP_SP_DESTROY ;
@@ -931,21 +910,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