small bug fixes from PVS studio bug list
Subsystems (2)
cover small bug fixes from PVS studio bug list
More bug fixes from PVS studio bug reports.
And one other fix to ptpclient.
Stephen Hemminger (16):
common/cnxk: remove duplicate condition net/cpfl: avoid calling log (printf) with null raw/cnxk_gpio: fix file descriptor leak net/ntnic: remove dead code
net/i40e: remove duplicate code
eal: fix out of bounds access in devargs net/qede: fix missing debug string examples/ptpclient: replace rte_memcpy with assignment examples/ptpclient: fix self memcmp net/octeon_ep: remove duplicate code net/hinic: fix flow type bitmask overflow crypto/dpaa2_sec: fix bitmask truncation crypto/dpaa_sec: fix bitmask truncation event/dpaa: fix bitmask truncation
net/dpaa: fix bitmask truncation
net/dpaa2: fix bitmask truncation
drivers/common/cnxk/cnxk_security.c | 16 ++++++++------ drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++---- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++--- drivers/event/dpaa/dpaa_eventdev.c | 10 ++++----- drivers/net/cpfl/cpfl_ethdev.c | 2 +- drivers/net/dpaa/dpaa_rxtx.c | 7 +++--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- drivers/net/hinic/hinic_pmd_flow.c | 14 ++++++------ drivers/net/i40e/i40e_fdir.c | 10 ++++----- drivers/net/ntnic/ntnic_ethdev.c | 8 ------- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------ drivers/net/qede/qede_debug.c | 3 +++ drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 +++++++++++++-------- examples/ptpclient/ptpclient.c | 10 +++------ lib/eal/common/eal_common_devargs.c | 2 +- 15 files changed, 64 insertions(+), 72 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/16 common/cnxk: remove duplicate condition
The same condition is checked twice in an if statement. Harmless, but redundant.
--- drivers/common/cnxk/cnxk_security.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/common/cnxk/cnxk_security.c +10 -6
@@ -174,9 +174,11 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, uint8_t *cipher_k }/* Set AES key length */ -if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || + w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (length) {case ROC_CPT_AES128_KEY_LEN : w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
@@ -879,9 +881,11 @@ on_ipsec_sa_ctl_set(struct rte_security_ipsec_xform *ipsec, }/* Set AES key length */ -if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || + ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || + ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (aes_key_len) {case 16 : ctl->aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
Signature · 1 line
2.45.2
RE: [EXTERNAL] [PATCH 01/16] common/cnxk: remove duplicate condition
Quoted 7 lines
The same condition is checked twice in an if statement. Harmless, but redundant.
WYLn1v9SyTMrT5EQqh2TU&m=tCMuFtN3iZvm6NW4QbOzKChuntNLulIgTuVpxYI9t8tfV9TfaTSFRx49kikIS84j&s=2cGhW06MxChL2e5aNV_DQOLM1lQUuNBQKHQeLsS3IdE&e=
Signed-off-by Stephen Hemminger <mailto:[email protected]>
PATCH 2/16 net/cpfl: avoid calling log (printf) with null
In reply to Stephen HemmingerThe log message would always refer to str variable which is NULL here. Looks like author intended to print original parameter.
--- drivers/net/cpfl/cpfl_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +1 -1
@@ -1580,7 +1580,7 @@ parse_repr(const char *key __rte_unused, const char *value, void *args) RTE_DIM(eth_da->representor_ports)); done:if (str ==NULL ) { -PMD_DRV_LOG (ERR ,"wrong representor format: %s" , str); +PMD_DRV_LOG (ERR ,"wrong representor format: %s" , value);return -1 ; }
Signature · 1 line
2.45.2
PATCH 3/16 raw/cnxk_gpio: fix file descriptor leak
In reply to Stephen HemmingerThe function would leak file if fscanf failed. There is a working version in other file, clone that.
--- drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c +15 -9
@@ -34,24 +34,30 @@ cnxk_gpio_attr_exists(const char *attr)static int cnxk_gpio_read_attr (char *attr,char *val) { +int ret, ret2;FILE *fp; -int ret; fp =fopen (attr,"r" );if (!fp)return -errno; ret =fscanf (fp,"%s" , val); -if (ret <0 ) -return -errno; -if (ret !=1 ) -return -EIO ; +if (ret <0 ) { + ret = -errno; + goto out; + } +if (ret !=1 ) { + ret = -EIO ; + goto out; + } - ret =fclose (fp); -if (ret) -return -errno; + ret =0 ; +out: + ret2 =fclose (fp); +if (!ret) + ret = ret2; -return 0 ; +return ret; }#define CNXK_GPIO_ERR_STR (err, str, ...) do { \
Signature · 1 line
2.45.2
PATCH 4/16 net/ntnic: remove dead code
In reply to Stephen HemmingerThe loop to update speed would not work because num_port_speeds was always zero so it did nothing. And the array of pls_mbps was only used inside the loop but never set.
--- drivers/net/ntnic/ntnic_ethdev.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +0 -8
@@ -2037,8 +2037,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)uint32_t exception_path =0 ;struct flow_queue_id_s queue_ids[MAX_QUEUES ];int n_phy_ports; -struct port_link_speed pls_mbps[NUM_ADAPTER_PORTS_MAX ] = {0 }; -int num_port_speeds =0 ;enum flow_eth_dev_profile profile =FLOW_ETH_DEV_PROFILE_INLINE ; NT_LOG_DBGX(DBG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i", pci_dev->name,
@@ -2178,12 +2176,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) p_nt_drv->b_shutdown = false; p_nt_drv->adapter_info.pb_shutdown = &p_nt_drv->b_shutdown; -for (int i =0 ; i < num_port_speeds; ++i) { -struct adapter_info_s *p_adapter_info = &p_nt_drv->adapter_info; -nt_link_speed_t link_speed =convert_link_speed (pls_mbps[i].link_speed); - port_ops->set_link_speed (p_adapter_info, i, link_speed); - } -/* store context */ store_pdrv (p_drv);
Signature · 1 line
2.45.2
PATCH 5/16 net/i40e: remove duplicate code
In reply to Stephen HemmingerThere are two branches in the cascading if/else that have same condition and code; remove one. Update the code to follow DPDK style where all statements in if should have brackets if any leg requires them.
--- drivers/net/i40e/i40e_fdir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_fdir.c +4 -6
@@ -599,18 +599,16 @@ i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf, }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { - len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , - len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_ESP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_L2TP , len, ether_type); + } }else {PMD_DRV_LOG (ERR ,"unknown pctype %u." , fdir_input->pctype);return -1 ;
Signature · 1 line
2.45.2
Re: [PATCH 05/16] net/i40e: remove duplicate code
Quoted 5 lines · Stephen Hemminger
There are two branches in the cascading if/else that have same condition and code; remove one. Update the code to follow DPDK style where all statements in if should have brackets if any leg requires them.
Not actually DPDK style, that is just something that checkpatch recommends because it is kernel style. DPDK style guide says[1] "Braces that are not necessary should be left out."
That said, most legs of this if-else block have it so ok to have that change included for consistency.
[1] https://doc.dpdk.org/guides/contributing/coding_style.html#control-statements-and-loops
Quoted 1 line
Quoted 36 lines
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/i40e/i40e_fdir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/net/i40e/i40e_fdir.c +4
-6@@ -599,18 +599,16 @@ i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf, }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { - len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , - len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_ESP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_L2TP , len, ether_type); + } }else {PMD_DRV_LOG (ERR ,"unknown pctype %u." , fdir_input->pctype);return -1 ;Signature · 1 line
2.45.2
PATCH 6/16 eal: fix out of bounds access in devargs
In reply to Stephen HemmingerThe code for parsing layers in devargs could reference past the end of layers[] array on stack.
--- lib/eal/common/eal_common_devargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_devargs.c +1 -1
@@ -88,7 +88,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, s = devargs->data;while (s !=NULL ) { -if (nblayer >RTE_DIM (layers)) { +if (nblayer >=RTE_DIM (layers)) { ret = -E2BIG ; goto get_out; }
Signature · 1 line
2.45.2
PATCH 7/16 net/qede: fix missing debug string
In reply to Stephen HemmingerThe array of debug status strings did not match possible enum values. Add the missing element and a static assert to make sure the table has all possible values.
For more complete description see.
--- drivers/net/qede/qede_debug.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/qede/qede_debug.c +3 -0
@@ -5614,6 +5614,8 @@ static const char * const s_status_str[] = {/* DBG_STATUS_INVALID_FILTER_TRIGGER_DWORDS */ "The filter/trigger constraint dword offsets are not enabled for recording" , +/* DBG_STATUS_NO_MATCHING_FRAMING_MODE */ +"No matching frame mode" ,/* DBG_STATUS_VFC_READ_ERROR */ "Error reading from VFC",
@@ -5759,6 +5761,7 @@ static const char * const s_status_str[] = {/* DBG_STATUS_MISSING_TRIGGER_STATE_STORM */ "When triggering on Storm data, the Storm to trigger on must be specified" }; +static_assert (MAX_DBG_STATUS ==RTE_DIM (s_status_str),"status string table mismatch" );/* Idle check severity names array */ static const char *const s_idle_chk_severity_str[] = {
Signature · 1 line
2.45.2
PATCH 8/16 examples/ptpclient: replace rte_memcpy with assignment
In reply to Stephen HemmingerDon't use rte_memcpy() when not necessary. Structure assignment is as fast and type safe.
--- examples/ptpclient/ptpclient.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
examples/ptpclient/ptpclient.c +2 -6
@@ -415,9 +415,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->seqID_SYNC =rte_be_to_cpu_16 (ptp_hdr->seq_id);if (ptp_data->ptpset ==0 ) { -rte_memcpy (&ptp_data->transmitter_clock_id, - &ptp_hdr->source_port_id.clock_id, -sizeof (struct clock_id )); + ptp_data->transmitter_clock_id = ptp_hdr->source_port_id.clock_id; ptp_data->ptpset =1 ; }
@@ -522,9 +520,7 @@ parse_fup(struct ptpv2_time_receiver_ordinary *ptp_data) client_clkid->id[6 ] = eth_hdr->src_addr.addr_bytes[4 ]; client_clkid->id[7 ] = eth_hdr->src_addr.addr_bytes[5 ]; -rte_memcpy (&ptp_data->client_clock_id, - client_clkid, -sizeof (struct clock_id )); + ptp_data->client_clock_id = *client_clkid;/* Enable flag for hardware timestamping. */ created_pkt->ol_flags |=RTE_MBUF_F_TX_IEEE1588_TMST ;
Signature · 1 line
2.45.2
PATCH 9/16 examples/ptpclient: fix self memcmp
In reply to Stephen HemmingerCalling memcmp on same structure will always be true. Replace with same conditional used elsewhere.
--- examples/ptpclient/ptpclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ptpclient/ptpclient.c +1 -1
@@ -419,7 +419,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->ptpset =1 ; } -if (memcmp (&ptp_hdr->source_port_id.clock_id, +if (memcmp (&ptp_data->transmitter_clock_id, &ptp_hdr->source_port_id.clock_id,sizeof (struct clock_id )) ==0 ) {
Signature · 1 line
2.45.2
PATCH 10/16 net/octeon_ep: remove duplicate code
In reply to Stephen HemmingerBoth sides of the if in uninit are using same code.
--- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/octeon_ep/otx_ep_ethdev.c +2 -7
@@ -721,14 +721,9 @@ static const struct eth_dev_ops otx_ep_eth_dev_ops = {static int otx_ep_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { - eth_dev->dev_ops =NULL ; - eth_dev->rx_pkt_burst =NULL ; - eth_dev->tx_pkt_burst =NULL ; -return 0 ; - } +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +otx_ep_mbox_uninit (eth_dev); -otx_ep_mbox_uninit (eth_dev); eth_dev->dev_ops =NULL ; eth_dev->rx_pkt_burst =NULL ; eth_dev->tx_pkt_burst =NULL ;
Signature · 1 line
2.45.2
PATCH 11/16 net/hinic: fix flow type bitmask overflow
In reply to Stephen HemmingerThe type mask is 64 bit value, doing a shift of literal 1 (32 bit) will result in int type (32 bit) and cause truncation.
--- drivers/net/hinic/hinic_pmd_flow.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/hinic/hinic_pmd_flow.c +7 -7
@@ -1979,8 +1979,8 @@ static int hinic_lookup_new_filter(struct hinic_5tuple_filter *filter,return -EINVAL ; } -if (!(filter_info->type_mask & (1 << type_id))) { - filter_info->type_mask |=1 << type_id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << type_id))) { + filter_info->type_mask |=UINT64_C (1 ) << type_id; filter->index = type_id; filter_info->pkt_filters[type_id].enable = true; filter_info->pkt_filters[type_id].pkt_proto =
@@ -2138,7 +2138,7 @@ static void hinic_remove_5tuple_filter(struct rte_eth_dev *dev, filter_info->pkt_type =0 ; filter_info->qid =0 ; filter_info->pkt_filters[filter->index].qid =0 ; - filter_info->type_mask &= ~(1 << (filter->index)); + filter_info->type_mask &= ~(UINT64_C (1 ) << filter->index);TAILQ_REMOVE (&filter_info->fivetuple_list, filter, entries);rte_free (filter);
@@ -2268,8 +2268,8 @@ hinic_ethertype_filter_insert(struct hinic_filter_info *filter_info,if (id <0 )return -EINVAL ; -if (!(filter_info->type_mask & (1 << id))) { - filter_info->type_mask |=1 << id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << id))) { + filter_info->type_mask |=UINT64_C (1 ) << id; filter_info->pkt_filters[id].pkt_proto = ethertype_filter->pkt_proto; filter_info->pkt_filters[id].enable = ethertype_filter->enable;
@@ -2289,7 +2289,7 @@ hinic_ethertype_filter_remove(struct hinic_filter_info *filter_info,return ; filter_info->pkt_type =0 ; - filter_info->type_mask &= ~(1 << idx); + filter_info->type_mask &= ~(UINT64_C (1 ) << idx); filter_info->pkt_filters[idx].pkt_proto = (uint16_t )0 ; filter_info->pkt_filters[idx].enable = FALSE; filter_info->pkt_filters[idx].qid =0 ;
@@ -2355,7 +2355,7 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev,if (i <0 )return -EINVAL ; -if ((filter_info->type_mask & (1 << i))) { +if ((filter_info->type_mask & (UINT64_C (1 ) << i))) { filter_info->pkt_filters[i].enable = FALSE; (void)hinic_set_fdir_filter(nic_dev->hwdev, filter_info->pkt_type,
Signature · 1 line
2.45.2
PATCH 12/16 crypto/dpaa2_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +4 -4
@@ -1491,8 +1491,8 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,if (*dpaa2_seqn ((*ops)->sym->m_src)) {if (*dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_ENQUEUE_FLAG_DCA ) {DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << - *dpaa2_seqn ((*ops)->sym->m_src) & +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << + *dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_EQCR_DCA_IDXMASK ); } flags[loop] = *dpaa2_seqn ((*ops)->sym->m_src);
@@ -1772,7 +1772,7 @@ dpaa2_sec_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -4055,7 +4055,7 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (crypto_op->sym->m_src) =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = crypto_op->sym->m_src; ev->event_ptr = crypto_op; }
Signature · 1 line
2.45.2
Re: [PATCH 12/16] crypto/dpaa2_sec: fix bitmask truncation
Quoted 40 lines · Stephen Hemminger
The
dqrr_heldmask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.Fixes a77db24643b7 ("crypto/dpaa2_sec: support atomic queues")Signed-off-by Stephen Hemminger <[email protected]>--- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +3
-3@@ -1491,8 +1491,8 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,if (*dpaa2_seqn ((*ops)->sym->m_src)) {if (*dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_ENQUEUE_FLAG_DCA ) {DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << - *dpaa2_seqn ((*ops)->sym->m_src) & +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << + *dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_EQCR_DCA_IDXMASK ); } flags[loop] = *dpaa2_seqn ((*ops)->sym->m_src);@@ -1772,7 +1772,7 @@ dpaa2_sec_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, · line 4061
Quoted 8 lines
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1
-1@@ -4055,7 +4055,7 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (crypto_op->sym->m_src) =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = crypto_op->sym->m_src; ev->event_ptr = crypto_op; }
PATCH 13/16 crypto/dpaa_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/dpaa_sec/dpaa_sec.c +3 -4
@@ -1907,13 +1907,12 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, op = *(ops++);if (*dpaa_seqn (op->sym->m_src) !=0 ) { index = *dpaa_seqn (op->sym->m_src) -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) {/* QM_EQCR_DCA_IDXMASK = 0x0f */ flags[loop] = ((index &0x0f ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
@@ -3500,7 +3499,7 @@ dpaa_sec_process_atomic_event(void *event,/* Save active dqrr entries */ index = ((uintptr_t )dqrr >>6 ) & (16 /*QM_DQRR_SIZE*/ -1 );DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = ctx->op->sym->m_src; ev->impl_opaque = index +1 ; *dpaa_seqn (ctx->op->sym->m_src) = (uint32_t )index +1 ;
Signature · 1 line
2.45.2
Re: [PATCH 13/16] crypto/dpaa_sec: fix bitmask truncation
Quoted 36 lines · Stephen Hemminger
The
dqrr_heldmask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.Fixes fe3688ba7950 ("crypto/dpaa_sec: support event crypto adapter")Signed-off-by Stephen Hemminger <[email protected]>--- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/crypto/dpaa_sec/dpaa_sec.c +2
-3@@ -1907,13 +1907,12 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, op = *(ops++);if (*dpaa_seqn (op->sym->m_src) !=0 ) { index = *dpaa_seqn (op->sym->m_src) -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) {/* QM_EQCR_DCA_IDXMASK = 0x0f */ flags[loop] = ((index &0x0f ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
drivers/crypto/dpaa_sec/dpaa_sec.c dpaa_sec_process_atomic_event(void *event, · line 3505
Quoted 8 lines
drivers/crypto/dpaa_sec/dpaa_sec.c +1
-1@@ -3500,7 +3499,7 @@ dpaa_sec_process_atomic_event(void *event,/* Save active dqrr entries */ index = ((uintptr_t )dqrr >>6 ) & (16 /*QM_DQRR_SIZE*/ -1 );DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = ctx->op->sym->m_src; ev->impl_opaque = index +1 ; *dpaa_seqn (ctx->op->sym->m_src) = (uint32_t )index +1 ;
PATCH 14/16 event/dpaa: fix bitmask truncation
In reply to Stephen HemmingerMore bitmask truncation from mask computation.
--- drivers/event/dpaa/dpaa_eventdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +5 -5
@@ -102,7 +102,7 @@ dpaa_event_enqueue_burst(void *port, const struct rte_event ev[],qman_dca_index (ev[i].impl_opaque,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --;break ;default :
@@ -199,11 +199,11 @@ dpaa_event_dequeue_burst(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
@@ -263,11 +263,11 @@ dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
Signature · 1 line
2.45.2
Re: [PATCH 14/16] event/dpaa: fix bitmask truncation
Quoted 42 lines · Stephen Hemminger
More bitmask truncation from mask computation.
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/event/dpaa/dpaa_eventdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/event/dpaa/dpaa_eventdev.c +3
-3@@ -102,7 +102,7 @@ dpaa_event_enqueue_burst(void *port, const struct rte_event ev[],qman_dca_index (ev[i].impl_opaque,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --;break ;default :@@ -199,11 +199,11 @@ dpaa_event_dequeue_burst(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;@@ -263,11 +263,11 @@ dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) {
drivers/event/dpaa/dpaa_eventdev.c dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[], · line 273
Quoted 10 lines
drivers/event/dpaa/dpaa_eventdev.c +2
-2-if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
PATCH 15/16 net/dpaa: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa/dpaa_rxtx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/dpaa/dpaa_rxtx.c +3 -4
@@ -842,7 +842,7 @@ dpaa_rx_cb_atomic(void *event,/* Save active dqrr entries */ index =DQRR_PTR2IDX (dqrr);DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = mbuf; ev->impl_opaque = index +1 ; *dpaa_seqn (mbuf) = (uint32_t )index +1 ;
@@ -1338,13 +1338,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) seqn = *dpaa_seqn (mbuf);if (seqn !=DPAA_INVALID_MBUF_SEQN ) { index = seqn -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) { flags[loop] = ((index &QM_EQCR_DCA_IDXMASK ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
Signature · 1 line
2.45.2
Re: [PATCH 15/16] net/dpaa: fix bitmask truncation
Quoted 44 lines · Stephen Hemminger
The
dqrr_heldmask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.Fixes 5e7455931442 ("net/dpaa: support Rx queue configurations with eventdev")Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/dpaa/dpaa_rxtx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/net/dpaa/dpaa_rxtx.c +3
-4@@ -842,7 +842,7 @@ dpaa_rx_cb_atomic(void *event,/* Save active dqrr entries */ index =DQRR_PTR2IDX (dqrr);DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = mbuf; ev->impl_opaque = index +1 ; *dpaa_seqn (mbuf) = (uint32_t )index +1 ;@@ -1338,13 +1338,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) seqn = *dpaa_seqn (mbuf);if (seqn !=DPAA_INVALID_MBUF_SEQN ) { index = seqn -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) { flags[loop] = ((index &QM_EQCR_DCA_IDXMASK ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
PATCH 16/16 net/dpaa2: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_rxtx.c +3 -3
@@ -933,7 +933,7 @@ dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (ev->mbuf) = dqrr_index +1 ;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = ev->mbuf; }
@@ -1317,7 +1317,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) flags[loop] =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dqrr_index); *dpaa2_seqn (*bufs) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -1575,7 +1575,7 @@ dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
Signature · 1 line
2.45.2
Re: [PATCH 16/16] net/dpaa2: fix bitmask truncation
Quoted 46 lines · Stephen Hemminger
The
dqrr_heldmask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/dpaa2/dpaa2_rxtx.c +3
-3@@ -933,7 +933,7 @@ dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (ev->mbuf) = dqrr_index +1 ;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = ev->mbuf; }@@ -1317,7 +1317,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) flags[loop] =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dqrr_index); *dpaa2_seqn (*bufs) =DPAA2_INVALID_MBUF_SEQN ; }@@ -1575,7 +1575,7 @@ dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
v2 cover minor fixes from PVS studio bug list
In reply to Stephen HemmingerMore bug fixes from PVS studio bug reports.
And one other fix to ptpclient.
Stephen Hemminger (19):
common/cnxk: remove duplicate condition net/cpfl: avoid calling log (printf) with null raw/cnxk_gpio: fix file descriptor leak net/ntnic: remove dead code
net/i40e: remove duplicate code
eal: fix out of bounds access in devargs net/qede: fix missing debug string examples/ptpclient: replace rte_memcpy with assignment examples/ptpclient: fix self memcmp net/octeon_ep: remove duplicate code net/hinic: fix flow type bitmask overflow crypto/dpaa2_sec: fix bitmask truncation crypto/dpaa_sec: fix bitmask truncation event/dpaa: fix bitmask truncation
net/dpaa: fix bitmask truncation
net/dpaa2: fix bitmask truncation
net/qede: don't use same loop variable twice examples/l3fwd: fix operator precedence bugs common/cnxk: fix null ptr check
v2 - add a few more fixes, and rebase
drivers/common/cnxk/cnxk_security.c | 16 ++++++++------ drivers/common/cnxk/roc_bphy_cgx.c | 12 +++++------ drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++---- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++--- drivers/event/dpaa/dpaa_eventdev.c | 10 ++++----- drivers/net/cpfl/cpfl_ethdev.c | 2 +- drivers/net/dpaa/dpaa_rxtx.c | 7 +++--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- drivers/net/hinic/hinic_pmd_flow.c | 14 ++++++------ drivers/net/i40e/i40e_fdir.c | 10 ++++----- drivers/net/ntnic/ntnic_ethdev.c | 8 ------- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------ drivers/net/qede/base/ecore_dcbx.c | 8 +++---- drivers/net/qede/qede_debug.c | 5 +++++ drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 +++++++++++++-------- examples/l3fwd-power/main.c | 4 ++-- examples/l3fwd/main.c | 5 +++-- examples/ptpclient/ptpclient.c | 10 +++------ lib/eal/common/eal_common_devargs.c | 2 +- 19 files changed, 81 insertions(+), 86 deletions(-)
Signature · 1 line
2.45.2
PATCH v2 1/19 common/cnxk: remove duplicate condition
The same condition is checked twice in an if statement. Harmless, but redundant.
--- drivers/common/cnxk/cnxk_security.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/common/cnxk/cnxk_security.c +10 -6
@@ -174,9 +174,11 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, uint8_t *cipher_k }/* Set AES key length */ -if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || + w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (length) {case ROC_CPT_AES128_KEY_LEN : w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
@@ -879,9 +881,11 @@ on_ipsec_sa_ctl_set(struct rte_security_ipsec_xform *ipsec, }/* Set AES key length */ -if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || + ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || + ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (aes_key_len) {case 16 : ctl->aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
Signature · 1 line
2.45.2
PATCH v2 2/19 net/cpfl: avoid calling log (printf) with null
In reply to Stephen HemmingerThe log message would always refer to str variable which is NULL here. Looks like author intended to print original parameter.
--- drivers/net/cpfl/cpfl_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +1 -1
@@ -1580,7 +1580,7 @@ parse_repr(const char *key __rte_unused, const char *value, void *args) RTE_DIM(eth_da->representor_ports)); done:if (str ==NULL ) { -PMD_DRV_LOG (ERR ,"wrong representor format: %s" , str); +PMD_DRV_LOG (ERR ,"wrong representor format: %s" , value);return -1 ; }
Signature · 1 line
2.45.2
PATCH v2 3/19 raw/cnxk_gpio: fix file descriptor leak
In reply to Stephen HemmingerThe function would leak file if fscanf failed. There is a working version in other file, clone that.
--- drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c +15 -9
@@ -34,24 +34,30 @@ cnxk_gpio_attr_exists(const char *attr)static int cnxk_gpio_read_attr (char *attr,char *val) { +int ret, ret2;FILE *fp; -int ret; fp =fopen (attr,"r" );if (!fp)return -errno; ret =fscanf (fp,"%s" , val); -if (ret <0 ) -return -errno; -if (ret !=1 ) -return -EIO ; +if (ret <0 ) { + ret = -errno; + goto out; + } +if (ret !=1 ) { + ret = -EIO ; + goto out; + } - ret =fclose (fp); -if (ret) -return -errno; + ret =0 ; +out: + ret2 =fclose (fp); +if (!ret) + ret = ret2; -return 0 ; +return ret; }#define CNXK_GPIO_ERR_STR (err, str, ...) do { \
Signature · 1 line
2.45.2
PATCH v2 4/19 net/ntnic: remove dead code
In reply to Stephen HemmingerThe loop to update speed would not work because num_port_speeds was always zero so it did nothing. And the array of pls_mbps was only used inside the loop but never set.
--- drivers/net/ntnic/ntnic_ethdev.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +0 -8
@@ -2037,8 +2037,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)uint32_t exception_path =0 ;struct flow_queue_id_s queue_ids[MAX_QUEUES ];int n_phy_ports; -struct port_link_speed pls_mbps[NUM_ADAPTER_PORTS_MAX ] = {0 }; -int num_port_speeds =0 ;enum flow_eth_dev_profile profile =FLOW_ETH_DEV_PROFILE_INLINE ; NT_LOG_DBGX(DBG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i", pci_dev->name,
@@ -2178,12 +2176,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) p_nt_drv->b_shutdown = false; p_nt_drv->adapter_info.pb_shutdown = &p_nt_drv->b_shutdown; -for (int i =0 ; i < num_port_speeds; ++i) { -struct adapter_info_s *p_adapter_info = &p_nt_drv->adapter_info; -nt_link_speed_t link_speed =convert_link_speed (pls_mbps[i].link_speed); - port_ops->set_link_speed (p_adapter_info, i, link_speed); - } -/* store context */ store_pdrv (p_drv);
Signature · 1 line
2.45.2
PATCH v2 5/19 net/i40e: remove duplicate code
In reply to Stephen HemmingerThere are two branches in the cascading if/else that have same condition and code; remove one. Update the code to follow DPDK style where all statements in if should have brackets if any leg requires them.
--- drivers/net/i40e/i40e_fdir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_fdir.c +4 -6
@@ -599,18 +599,16 @@ i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf, }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { - len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , - len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_ESP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_L2TP , len, ether_type); + } }else {PMD_DRV_LOG (ERR ,"unknown pctype %u." , fdir_input->pctype);return -1 ;
Signature · 1 line
2.45.2
PATCH v2 6/19 eal: fix out of bounds access in devargs
In reply to Stephen HemmingerThe code for parsing layers in devargs could reference past the end of layers[] array on stack.
--- lib/eal/common/eal_common_devargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_devargs.c +1 -1
@@ -88,7 +88,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, s = devargs->data;while (s !=NULL ) { -if (nblayer >RTE_DIM (layers)) { +if (nblayer >=RTE_DIM (layers)) { ret = -E2BIG ; goto get_out; }
Signature · 1 line
2.45.2
PATCH v2 7/19 net/qede: fix missing debug string
In reply to Stephen HemmingerThe array of debug status strings did not match possible enum values. Add the missing element and a static assert to make sure the table has all possible values.
For more complete description see.
--- drivers/net/qede/qede_debug.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/qede/qede_debug.c +5 -0
@@ -4,6 +4,7 @@* www.marvell.com */ +#include <assert.h> #include <rte_common.h> #include "base/bcm_osal.h" #include "base/ecore.h"
@@ -82,6 +83,7 @@ static const char * const s_mem_group_names[] = {"TM_MEM" ,"TASK_CFC_MEM" , }; +static_assert (RTE_DIM (s_mem_group_names) ==MEM_GROUPS_NUM ,"memory group string mismatch" );/* Idle check conditions */
@@ -5614,6 +5616,8 @@ static const char * const s_status_str[] = {/* DBG_STATUS_INVALID_FILTER_TRIGGER_DWORDS */ "The filter/trigger constraint dword offsets are not enabled for recording" , +/* DBG_STATUS_NO_MATCHING_FRAMING_MODE */ +"No matching frame mode" ,/* DBG_STATUS_VFC_READ_ERROR */ "Error reading from VFC",
@@ -5759,6 +5763,7 @@ static const char * const s_status_str[] = {/* DBG_STATUS_MISSING_TRIGGER_STATE_STORM */ "When triggering on Storm data, the Storm to trigger on must be specified" }; +static_assert (RTE_DIM (s_status_str) ==MAX_DBG_STATUS ,"status string table mismatch" );/* Idle check severity names array */ static const char *const s_idle_chk_severity_str[] = {
Signature · 1 line
2.45.2
PATCH v2 8/19 examples/ptpclient: replace rte_memcpy with assignment
In reply to Stephen HemmingerDon't use rte_memcpy() when not necessary. Structure assignment is as fast and type safe.
--- examples/ptpclient/ptpclient.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
examples/ptpclient/ptpclient.c +2 -6
@@ -415,9 +415,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->seqID_SYNC =rte_be_to_cpu_16 (ptp_hdr->seq_id);if (ptp_data->ptpset ==0 ) { -rte_memcpy (&ptp_data->transmitter_clock_id, - &ptp_hdr->source_port_id.clock_id, -sizeof (struct clock_id )); + ptp_data->transmitter_clock_id = ptp_hdr->source_port_id.clock_id; ptp_data->ptpset =1 ; }
@@ -522,9 +520,7 @@ parse_fup(struct ptpv2_time_receiver_ordinary *ptp_data) client_clkid->id[6 ] = eth_hdr->src_addr.addr_bytes[4 ]; client_clkid->id[7 ] = eth_hdr->src_addr.addr_bytes[5 ]; -rte_memcpy (&ptp_data->client_clock_id, - client_clkid, -sizeof (struct clock_id )); + ptp_data->client_clock_id = *client_clkid;/* Enable flag for hardware timestamping. */ created_pkt->ol_flags |=RTE_MBUF_F_TX_IEEE1588_TMST ;
Signature · 1 line
2.45.2
PATCH v2 9/19 examples/ptpclient: fix self memcmp
In reply to Stephen HemmingerCalling memcmp on same structure will always be true. Replace with same conditional used elsewhere.
--- examples/ptpclient/ptpclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ptpclient/ptpclient.c +1 -1
@@ -419,7 +419,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->ptpset =1 ; } -if (memcmp (&ptp_hdr->source_port_id.clock_id, +if (memcmp (&ptp_data->transmitter_clock_id, &ptp_hdr->source_port_id.clock_id,sizeof (struct clock_id )) ==0 ) {
Signature · 1 line
2.45.2
PATCH v2 10/19 net/octeon_ep: remove duplicate code
In reply to Stephen HemmingerBoth sides of the if in uninit are using same code.
--- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/octeon_ep/otx_ep_ethdev.c +2 -7
@@ -721,14 +721,9 @@ static const struct eth_dev_ops otx_ep_eth_dev_ops = {static int otx_ep_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { - eth_dev->dev_ops =NULL ; - eth_dev->rx_pkt_burst =NULL ; - eth_dev->tx_pkt_burst =NULL ; -return 0 ; - } +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +otx_ep_mbox_uninit (eth_dev); -otx_ep_mbox_uninit (eth_dev); eth_dev->dev_ops =NULL ; eth_dev->rx_pkt_burst =NULL ; eth_dev->tx_pkt_burst =NULL ;
Signature · 1 line
2.45.2
PATCH v2 11/19 net/hinic: fix flow type bitmask overflow
In reply to Stephen HemmingerThe type mask is 64 bit value, doing a shift of literal 1 (32 bit) will result in int type (32 bit) and cause truncation.
--- drivers/net/hinic/hinic_pmd_flow.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/hinic/hinic_pmd_flow.c +7 -7
@@ -1979,8 +1979,8 @@ static int hinic_lookup_new_filter(struct hinic_5tuple_filter *filter,return -EINVAL ; } -if (!(filter_info->type_mask & (1 << type_id))) { - filter_info->type_mask |=1 << type_id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << type_id))) { + filter_info->type_mask |=UINT64_C (1 ) << type_id; filter->index = type_id; filter_info->pkt_filters[type_id].enable = true; filter_info->pkt_filters[type_id].pkt_proto =
@@ -2138,7 +2138,7 @@ static void hinic_remove_5tuple_filter(struct rte_eth_dev *dev, filter_info->pkt_type =0 ; filter_info->qid =0 ; filter_info->pkt_filters[filter->index].qid =0 ; - filter_info->type_mask &= ~(1 << (filter->index)); + filter_info->type_mask &= ~(UINT64_C (1 ) << filter->index);TAILQ_REMOVE (&filter_info->fivetuple_list, filter, entries);rte_free (filter);
@@ -2268,8 +2268,8 @@ hinic_ethertype_filter_insert(struct hinic_filter_info *filter_info,if (id <0 )return -EINVAL ; -if (!(filter_info->type_mask & (1 << id))) { - filter_info->type_mask |=1 << id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << id))) { + filter_info->type_mask |=UINT64_C (1 ) << id; filter_info->pkt_filters[id].pkt_proto = ethertype_filter->pkt_proto; filter_info->pkt_filters[id].enable = ethertype_filter->enable;
@@ -2289,7 +2289,7 @@ hinic_ethertype_filter_remove(struct hinic_filter_info *filter_info,return ; filter_info->pkt_type =0 ; - filter_info->type_mask &= ~(1 << idx); + filter_info->type_mask &= ~(UINT64_C (1 ) << idx); filter_info->pkt_filters[idx].pkt_proto = (uint16_t )0 ; filter_info->pkt_filters[idx].enable = FALSE; filter_info->pkt_filters[idx].qid =0 ;
@@ -2355,7 +2355,7 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev,if (i <0 )return -EINVAL ; -if ((filter_info->type_mask & (1 << i))) { +if ((filter_info->type_mask & (UINT64_C (1 ) << i))) { filter_info->pkt_filters[i].enable = FALSE; (void)hinic_set_fdir_filter(nic_dev->hwdev, filter_info->pkt_type,
Signature · 1 line
2.45.2
PATCH v2 12/19 crypto/dpaa2_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +4 -4
@@ -1491,8 +1491,8 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,if (*dpaa2_seqn ((*ops)->sym->m_src)) {if (*dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_ENQUEUE_FLAG_DCA ) {DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << - *dpaa2_seqn ((*ops)->sym->m_src) & +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << + *dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_EQCR_DCA_IDXMASK ); } flags[loop] = *dpaa2_seqn ((*ops)->sym->m_src);
@@ -1772,7 +1772,7 @@ dpaa2_sec_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -4055,7 +4055,7 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (crypto_op->sym->m_src) =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = crypto_op->sym->m_src; ev->event_ptr = crypto_op; }
Signature · 1 line
2.45.2
PATCH v2 13/19 crypto/dpaa_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/dpaa_sec/dpaa_sec.c +3 -4
@@ -1907,13 +1907,12 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, op = *(ops++);if (*dpaa_seqn (op->sym->m_src) !=0 ) { index = *dpaa_seqn (op->sym->m_src) -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) {/* QM_EQCR_DCA_IDXMASK = 0x0f */ flags[loop] = ((index &0x0f ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
@@ -3500,7 +3499,7 @@ dpaa_sec_process_atomic_event(void *event,/* Save active dqrr entries */ index = ((uintptr_t )dqrr >>6 ) & (16 /*QM_DQRR_SIZE*/ -1 );DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = ctx->op->sym->m_src; ev->impl_opaque = index +1 ; *dpaa_seqn (ctx->op->sym->m_src) = (uint32_t )index +1 ;
Signature · 1 line
2.45.2
PATCH v2 14/19 event/dpaa: fix bitmask truncation
In reply to Stephen HemmingerMore bitmask truncation from mask computation.
--- drivers/event/dpaa/dpaa_eventdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +5 -5
@@ -102,7 +102,7 @@ dpaa_event_enqueue_burst(void *port, const struct rte_event ev[],qman_dca_index (ev[i].impl_opaque,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --;break ;default :
@@ -199,11 +199,11 @@ dpaa_event_dequeue_burst(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
@@ -263,11 +263,11 @@ dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
Signature · 1 line
2.45.2
PATCH v2 15/19 net/dpaa: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa/dpaa_rxtx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/dpaa/dpaa_rxtx.c +3 -4
@@ -842,7 +842,7 @@ dpaa_rx_cb_atomic(void *event,/* Save active dqrr entries */ index =DQRR_PTR2IDX (dqrr);DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = mbuf; ev->impl_opaque = index +1 ; *dpaa_seqn (mbuf) = (uint32_t )index +1 ;
@@ -1338,13 +1338,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) seqn = *dpaa_seqn (mbuf);if (seqn !=DPAA_INVALID_MBUF_SEQN ) { index = seqn -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) { flags[loop] = ((index &QM_EQCR_DCA_IDXMASK ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
Signature · 1 line
2.45.2
PATCH v2 16/19 net/dpaa2: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_rxtx.c +3 -3
@@ -933,7 +933,7 @@ dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (ev->mbuf) = dqrr_index +1 ;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = ev->mbuf; }
@@ -1317,7 +1317,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) flags[loop] =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dqrr_index); *dpaa2_seqn (*bufs) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -1575,7 +1575,7 @@ dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
Signature · 1 line
2.45.2
PATCH v2 17/19 net/qede: don't use same loop variable twice
In reply to Stephen HemmingerUsing variable in outer loop, and inner loop is obvious bug. This bug is in base code, so likely on other platforms as well.
--- drivers/net/qede/base/ecore_dcbx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/qede/base/ecore_dcbx.c +4 -4
@@ -1363,7 +1363,7 @@ ecore_lldp_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)struct ecore_dcbx_mib_meta_data data;enum _ecore_status_t rc =ECORE_SUCCESS ;struct lldp_received_tlvs_s tlvs; -int i; +int i, j;for (i =0 ; i <LLDP_MAX_LLDP_AGENTS ; i++) {OSAL_MEM_ZERO (&data,sizeof (data));
@@ -1381,9 +1381,9 @@ ecore_lldp_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)if (!tlvs.length)continue ; -for (i =0 ; i <MAX_TLV_BUFFER ; i++) - tlvs.tlvs_buffer[i] = -OSAL_CPU_TO_BE32 (tlvs.tlvs_buffer[i]); +for (j =0 ; j <MAX_TLV_BUFFER ; j++) + tlvs.tlvs_buffer[j] = +OSAL_CPU_TO_BE32 (tlvs.tlvs_buffer[j]);OSAL_LLDP_RX_TLVS (p_hwfn, tlvs.tlvs_buffer, tlvs.length); }
Signature · 1 line
2.45.2
PATCH v2 18/19 examples/l3fwd: fix operator precedence bugs
In reply to Stephen HemmingerThe expression:
if ((socketid = rte_lcore_to_socket_id(lcore) != 0) &&
gets evaluated as sockeid = (rte_lcore_to_socket_id(lcore) != 0) which is not what was intended. This is goes all the way back to first release.
--- examples/l3fwd-power/main.c | 4 ++-- examples/l3fwd/main.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
examples/l3fwd-power/main.c +2 -2
@@ -1412,8 +1412,8 @@ check_lcore_params(void) "mask\n", lcore);return -1 ; } -if ((socketid =rte_lcore_to_socket_id (lcore) !=0 ) && - (numa_on ==0 )) { + socketid =rte_lcore_to_socket_id (lcore); +if (socketid !=0 && numa_on ==0 ) {printf ("warning: lcore %u is on socket %d with numa " "off\n" , lcore, socketid); }
examples/l3fwd/main.c +3 -2
@@ -307,8 +307,9 @@ check_lcore_params(void)printf ("error: lcore %u is not enabled in lcore mask\n" , lcore);return -1 ; } -if ((socketid =rte_lcore_to_socket_id (lcore) !=0 ) && - (numa_on ==0 )) { + + socketid =rte_lcore_to_socket_id (lcore); +if (socketid !=0 && numa_on ==0 ) {printf ("warning: lcore %u is on socket %d with numa off\n" , lcore, socketid); }
Signature · 1 line
2.45.2
PATCH v2 19/19 common/cnxk: fix null ptr check
In reply to Stephen HemmingerThe pointer mode is used then checked which is a bug reported by PVS studio and Coverity.
--- drivers/common/cnxk/roc_bphy_cgx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +6 -6
@@ -369,20 +369,20 @@ roc_bphy_cgx_set_link_mode(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, {uint64_t scr1, scr0; +if (!mode) +return -EINVAL ; + +if (!roc_cgx) +return -EINVAL ; +if (roc_model_is_cn9k () && (mode->use_portm_idx || mode->portm_idx || mode->mode_group_idx)) {return -ENOTSUP ; } -if (!roc_cgx) -return -EINVAL ; -if (!roc_bphy_cgx_lmac_exists (roc_cgx, lmac))return -ENODEV ; -if (!mode) -return -EINVAL ; - scr1 =FIELD_PREP (SCR1_ETH_CMD_ID ,ETH_CMD_MODE_CHANGE ) |FIELD_PREP (SCR1_ETH_MODE_CHANGE_ARGS_SPEED , mode->speed) | FIELD_PREP(SCR1_ETH_MODE_CHANGE_ARGS_DUPLEX, mode->full_duplex) |
Signature · 1 line
2.45.2
Re: [PATCH v2 00/19] minor fixes from PVS studio bug list
In reply to Stephen Hemminger18/11/2024 19:20, Stephen Hemminger:
Quoted 1 line
v2 - add a few more fixes, and rebase
Please could you resend with "--cc-cmd devtools/get-maintainer.sh" ?
Given these patches are not critical I think we can wait for maintainers review, even if it means missing the 24.11 release?
v3 cover minor fixes from PVS studio bug list
In reply to Stephen HemmingerMore bug fixes from PVS studio bug reports.
And one other fix to ptpclient.
Stephen Hemminger (19):
common/cnxk: remove duplicate condition net/cpfl: avoid calling log (printf) with null raw/cnxk_gpio: fix file descriptor leak net/ntnic: remove dead code
net/i40e: remove duplicate code
eal: fix out of bounds access in devargs net/qede: fix missing debug string examples/ptpclient: replace rte_memcpy with assignment examples/ptpclient: fix self memcmp net/octeon_ep: remove duplicate code net/hinic: fix flow type bitmask overflow crypto/dpaa2_sec: fix bitmask truncation crypto/dpaa_sec: fix bitmask truncation event/dpaa: fix bitmask truncation
net/dpaa: fix bitmask truncation
net/dpaa2: fix bitmask truncation
net/qede: don't use same loop variable twice examples/l3fwd: fix operator precedence bugs common/cnxk: fix null ptr check
v3 - rebase; Intel drivers moved
Stephen Hemminger (19):
common/cnxk: remove duplicate condition net/cpfl: avoid calling log (printf) with null raw/cnxk_gpio: fix file descriptor leak net/ntnic: remove dead code
net/i40e: remove duplicate code
eal: fix out of bounds access in devargs net/qede: fix missing debug string examples/ptpclient: replace rte_memcpy with assignment examples/ptpclient: fix self memcmp net/octeon_ep: remove duplicate code net/hinic: fix flow type bitmask overflow crypto/dpaa2_sec: fix bitmask truncation crypto/dpaa_sec: fix bitmask truncation event/dpaa: fix bitmask truncation
net/dpaa: fix bitmask truncation
net/dpaa2: fix bitmask truncation
net/qede: don't use same loop variable twice examples/l3fwd: fix operator precedence bugs common/cnxk: fix null ptr check
drivers/common/cnxk/cnxk_security.c | 16 ++++++++------ drivers/common/cnxk/roc_bphy_cgx.c | 12 +++++------ drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++---- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++--- drivers/event/dpaa/dpaa_eventdev.c | 10 ++++----- drivers/net/dpaa/dpaa_rxtx.c | 7 +++--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- drivers/net/hinic/hinic_pmd_flow.c | 14 ++++++------ drivers/net/intel/cpfl/cpfl_ethdev.c | 2 +- drivers/net/intel/i40e/i40e_fdir.c | 10 ++++----- drivers/net/ntnic/ntnic_ethdev.c | 8 ------- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------ drivers/net/qede/base/ecore_dcbx.c | 8 +++---- drivers/net/qede/qede_debug.c | 5 +++++ drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 +++++++++++++-------- examples/l3fwd-power/main.c | 4 ++-- examples/l3fwd/main.c | 5 +++-- examples/ptpclient/ptpclient.c | 10 +++------ lib/eal/common/eal_common_devargs.c | 2 +- 19 files changed, 81 insertions(+), 86 deletions(-)
Signature · 1 line
2.47.2
PATCH v3 1/19 common/cnxk: remove duplicate condition
The same condition is checked twice in an if statement. Harmless, but redundant.
--- drivers/common/cnxk/cnxk_security.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/common/cnxk/cnxk_security.c +10 -6
@@ -174,9 +174,11 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, uint8_t *cipher_k }/* Set AES key length */ -if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || - w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (w2->s.enc_type ==ROC_IE_SA_ENC_AES_CBC || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CTR || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_GCM || + w2->s.enc_type ==ROC_IE_SA_ENC_AES_CCM || + w2->s.auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (length) {case ROC_CPT_AES128_KEY_LEN : w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
@@ -879,9 +881,11 @@ on_ipsec_sa_ctl_set(struct rte_security_ipsec_xform *ipsec, }/* Set AES key length */ -if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || - ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) { +if (ctl->enc_type ==ROC_IE_SA_ENC_AES_CBC || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CTR || + ctl->enc_type ==ROC_IE_SA_ENC_AES_GCM || + ctl->enc_type ==ROC_IE_SA_ENC_AES_CCM || + ctl->auth_type ==ROC_IE_SA_AUTH_AES_GMAC ) {switch (aes_key_len) {case 16 : ctl->aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;
Signature · 1 line
2.47.2
PATCH v3 2/19 net/cpfl: avoid calling log (printf) with null
In reply to Stephen HemmingerThe log message would always refer to str variable which is NULL here. Looks like author intended to print original parameter.
--- drivers/net/intel/cpfl/cpfl_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/cpfl/cpfl_ethdev.c +1 -1
@@ -1580,7 +1580,7 @@ parse_repr(const char *key __rte_unused, const char *value, void *args) RTE_DIM(eth_da->representor_ports)); done:if (str ==NULL ) { -PMD_DRV_LOG (ERR ,"wrong representor format: %s" , str); +PMD_DRV_LOG (ERR ,"wrong representor format: %s" , value);return -1 ; }
Signature · 1 line
2.47.2
PATCH v3 3/19 raw/cnxk_gpio: fix file descriptor leak
In reply to Stephen HemmingerThe function would leak file if fscanf failed. There is a working version in other file, clone that.
--- drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c +15 -9
@@ -34,24 +34,30 @@ cnxk_gpio_attr_exists(const char *attr)static int cnxk_gpio_read_attr (char *attr,char *val) { +int ret, ret2;FILE *fp; -int ret; fp =fopen (attr,"r" );if (!fp)return -errno; ret =fscanf (fp,"%s" , val); -if (ret <0 ) -return -errno; -if (ret !=1 ) -return -EIO ; +if (ret <0 ) { + ret = -errno; + goto out; + } +if (ret !=1 ) { + ret = -EIO ; + goto out; + } - ret =fclose (fp); -if (ret) -return -errno; + ret =0 ; +out: + ret2 =fclose (fp); +if (!ret) + ret = ret2; -return 0 ; +return ret; }#define CNXK_GPIO_ERR_STR (err, str, ...) do { \
Signature · 1 line
2.47.2
PATCH v3 4/19 net/ntnic: remove dead code
In reply to Stephen HemmingerThe loop to update speed would not work because num_port_speeds was always zero so it did nothing. And the array of pls_mbps was only used inside the loop but never set.
--- drivers/net/ntnic/ntnic_ethdev.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +0 -8
@@ -2037,8 +2037,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)uint32_t exception_path =0 ;struct flow_queue_id_s queue_ids[MAX_QUEUES ];int n_phy_ports; -struct port_link_speed pls_mbps[NUM_ADAPTER_PORTS_MAX ] = {0 }; -int num_port_speeds =0 ;enum flow_eth_dev_profile profile =FLOW_ETH_DEV_PROFILE_INLINE ; NT_LOG_DBGX(DBG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i", pci_dev->name,
@@ -2178,12 +2176,6 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) p_nt_drv->b_shutdown = false; p_nt_drv->adapter_info.pb_shutdown = &p_nt_drv->b_shutdown; -for (int i =0 ; i < num_port_speeds; ++i) { -struct adapter_info_s *p_adapter_info = &p_nt_drv->adapter_info; -nt_link_speed_t link_speed =convert_link_speed (pls_mbps[i].link_speed); - port_ops->set_link_speed (p_adapter_info, i, link_speed); - } -/* store context */ store_pdrv (p_drv);
Signature · 1 line
2.47.2
PATCH v3 5/19 net/i40e: remove duplicate code
In reply to Stephen HemmingerThere are two branches in the cascading if/else that have same condition and code; remove one. Update the code to follow DPDK style where all statements in if should have brackets if any leg requires them.
--- drivers/net/intel/i40e/i40e_fdir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_fdir.c +4 -6
@@ -599,18 +599,16 @@ i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf, }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV4_UDP ) { - len =fill_ip4_head (fdir_input, raw_pkt,IPPROTO_UDP , - len, ether_type); - }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_ESP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_ESP_IPV6_UDP ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_UDP , len, ether_type); -else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) + }else if (cus_pctype->index ==I40E_CUSTOMIZED_IPV6_L2TPV3 ) { len =fill_ip6_head (fdir_input, raw_pkt,IPPROTO_L2TP , len, ether_type); + } }else {PMD_DRV_LOG (ERR ,"unknown pctype %u." , fdir_input->pctype);return -1 ;
Signature · 1 line
2.47.2
PATCH v3 6/19 eal: fix out of bounds access in devargs
In reply to Stephen HemmingerThe code for parsing layers in devargs could reference past the end of layers[] array on stack.
--- lib/eal/common/eal_common_devargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_devargs.c +1 -1
@@ -88,7 +88,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, s = devargs->data;while (s !=NULL ) { -if (nblayer >RTE_DIM (layers)) { +if (nblayer >=RTE_DIM (layers)) { ret = -E2BIG ; goto get_out; }
Signature · 1 line
2.47.2
PATCH v3 7/19 net/qede: fix missing debug string
In reply to Stephen HemmingerThe array of debug status strings did not match possible enum values. Add the missing element and a static assert to make sure the table has all possible values.
For more complete description see.
--- drivers/net/qede/qede_debug.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/qede/qede_debug.c +5 -0
@@ -4,6 +4,7 @@* www.marvell.com */ +#include <assert.h> #include <rte_common.h> #include "base/bcm_osal.h" #include "base/ecore.h"
@@ -82,6 +83,7 @@ static const char * const s_mem_group_names[] = {"TM_MEM" ,"TASK_CFC_MEM" , }; +static_assert (RTE_DIM (s_mem_group_names) ==MEM_GROUPS_NUM ,"memory group string mismatch" );/* Idle check conditions */
@@ -5614,6 +5616,8 @@ static const char * const s_status_str[] = {/* DBG_STATUS_INVALID_FILTER_TRIGGER_DWORDS */ "The filter/trigger constraint dword offsets are not enabled for recording" , +/* DBG_STATUS_NO_MATCHING_FRAMING_MODE */ +"No matching frame mode" ,/* DBG_STATUS_VFC_READ_ERROR */ "Error reading from VFC",
@@ -5759,6 +5763,7 @@ static const char * const s_status_str[] = {/* DBG_STATUS_MISSING_TRIGGER_STATE_STORM */ "When triggering on Storm data, the Storm to trigger on must be specified" }; +static_assert (RTE_DIM (s_status_str) ==MAX_DBG_STATUS ,"status string table mismatch" );/* Idle check severity names array */ static const char *const s_idle_chk_severity_str[] = {
Signature · 1 line
2.47.2
PATCH v3 8/19 examples/ptpclient: replace rte_memcpy with assignment
In reply to Stephen HemmingerDon't use rte_memcpy() when not necessary. Structure assignment is as fast and type safe.
--- examples/ptpclient/ptpclient.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
examples/ptpclient/ptpclient.c +2 -6
@@ -363,9 +363,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->seqID_SYNC =rte_be_to_cpu_16 (ptp_hdr->seq_id);if (ptp_data->ptpset ==0 ) { -rte_memcpy (&ptp_data->transmitter_clock_id, - &ptp_hdr->source_port_id.clock_id, -sizeof (struct clock_id )); + ptp_data->transmitter_clock_id = ptp_hdr->source_port_id.clock_id; ptp_data->ptpset =1 ; }
@@ -470,9 +468,7 @@ parse_fup(struct ptpv2_time_receiver_ordinary *ptp_data) client_clkid->id[6 ] = eth_hdr->src_addr.addr_bytes[4 ]; client_clkid->id[7 ] = eth_hdr->src_addr.addr_bytes[5 ]; -rte_memcpy (&ptp_data->client_clock_id, - client_clkid, -sizeof (struct clock_id )); + ptp_data->client_clock_id = *client_clkid;/* Enable flag for hardware timestamping. */ created_pkt->ol_flags |=RTE_MBUF_F_TX_IEEE1588_TMST ;
Signature · 1 line
2.47.2
PATCH v3 9/19 examples/ptpclient: fix self memcmp
In reply to Stephen HemmingerCalling memcmp on same structure will always be true. Replace with same conditional used elsewhere.
--- examples/ptpclient/ptpclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ptpclient/ptpclient.c +1 -1
@@ -367,7 +367,7 @@ parse_sync(struct ptpv2_time_receiver_ordinary *ptp_data, uint16_t rx_tstamp_idx ptp_data->ptpset =1 ; } -if (memcmp (&ptp_hdr->source_port_id.clock_id, +if (memcmp (&ptp_data->transmitter_clock_id, &ptp_hdr->source_port_id.clock_id,sizeof (struct clock_id )) ==0 ) {
Signature · 1 line
2.47.2
PATCH v3 10/19 net/octeon_ep: remove duplicate code
In reply to Stephen HemmingerBoth sides of the if in uninit are using same code.
--- drivers/net/octeon_ep/otx_ep_ethdev.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/octeon_ep/otx_ep_ethdev.c +2 -7
@@ -721,14 +721,9 @@ static const struct eth_dev_ops otx_ep_eth_dev_ops = {static int otx_ep_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { - eth_dev->dev_ops =NULL ; - eth_dev->rx_pkt_burst =NULL ; - eth_dev->tx_pkt_burst =NULL ; -return 0 ; - } +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +otx_ep_mbox_uninit (eth_dev); -otx_ep_mbox_uninit (eth_dev); eth_dev->dev_ops =NULL ; eth_dev->rx_pkt_burst =NULL ; eth_dev->tx_pkt_burst =NULL ;
Signature · 1 line
2.47.2
PATCH v3 11/19 net/hinic: fix flow type bitmask overflow
In reply to Stephen HemmingerThe type mask is 64 bit value, doing a shift of literal 1 (32 bit) will result in int type (32 bit) and cause truncation.
--- drivers/net/hinic/hinic_pmd_flow.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/hinic/hinic_pmd_flow.c +7 -7
@@ -1979,8 +1979,8 @@ static int hinic_lookup_new_filter(struct hinic_5tuple_filter *filter,return -EINVAL ; } -if (!(filter_info->type_mask & (1 << type_id))) { - filter_info->type_mask |=1 << type_id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << type_id))) { + filter_info->type_mask |=UINT64_C (1 ) << type_id; filter->index = type_id; filter_info->pkt_filters[type_id].enable = true; filter_info->pkt_filters[type_id].pkt_proto =
@@ -2138,7 +2138,7 @@ static void hinic_remove_5tuple_filter(struct rte_eth_dev *dev, filter_info->pkt_type =0 ; filter_info->qid =0 ; filter_info->pkt_filters[filter->index].qid =0 ; - filter_info->type_mask &= ~(1 << (filter->index)); + filter_info->type_mask &= ~(UINT64_C (1 ) << filter->index);TAILQ_REMOVE (&filter_info->fivetuple_list, filter, entries);rte_free (filter);
@@ -2268,8 +2268,8 @@ hinic_ethertype_filter_insert(struct hinic_filter_info *filter_info,if (id <0 )return -EINVAL ; -if (!(filter_info->type_mask & (1 << id))) { - filter_info->type_mask |=1 << id; +if (!(filter_info->type_mask & (UINT64_C (1 ) << id))) { + filter_info->type_mask |=UINT64_C (1 ) << id; filter_info->pkt_filters[id].pkt_proto = ethertype_filter->pkt_proto; filter_info->pkt_filters[id].enable = ethertype_filter->enable;
@@ -2289,7 +2289,7 @@ hinic_ethertype_filter_remove(struct hinic_filter_info *filter_info,return ; filter_info->pkt_type =0 ; - filter_info->type_mask &= ~(1 << idx); + filter_info->type_mask &= ~(UINT64_C (1 ) << idx); filter_info->pkt_filters[idx].pkt_proto = (uint16_t )0 ; filter_info->pkt_filters[idx].enable = FALSE; filter_info->pkt_filters[idx].qid =0 ;
@@ -2355,7 +2355,7 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev,if (i <0 )return -EINVAL ; -if ((filter_info->type_mask & (1 << i))) { +if ((filter_info->type_mask & (UINT64_C (1 ) << i))) { filter_info->pkt_filters[i].enable = FALSE; (void)hinic_set_fdir_filter(nic_dev->hwdev, filter_info->pkt_type,
Signature · 1 line
2.47.2
PATCH v3 12/19 crypto/dpaa2_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +4 -4
@@ -1491,8 +1491,8 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,if (*dpaa2_seqn ((*ops)->sym->m_src)) {if (*dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_ENQUEUE_FLAG_DCA ) {DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << - *dpaa2_seqn ((*ops)->sym->m_src) & +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << + *dpaa2_seqn ((*ops)->sym->m_src) &QBMAN_EQCR_DCA_IDXMASK ); } flags[loop] = *dpaa2_seqn ((*ops)->sym->m_src);
@@ -1772,7 +1772,7 @@ dpaa2_sec_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -4055,7 +4055,7 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (crypto_op->sym->m_src) =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = crypto_op->sym->m_src; ev->event_ptr = crypto_op; }
Signature · 1 line
2.47.2
PATCH v3 13/19 crypto/dpaa_sec: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/dpaa_sec/dpaa_sec.c +3 -4
@@ -1907,13 +1907,12 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, op = *(ops++);if (*dpaa_seqn (op->sym->m_src) !=0 ) { index = *dpaa_seqn (op->sym->m_src) -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) {/* QM_EQCR_DCA_IDXMASK = 0x0f */ flags[loop] = ((index &0x0f ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
@@ -3500,7 +3499,7 @@ dpaa_sec_process_atomic_event(void *event,/* Save active dqrr entries */ index = ((uintptr_t )dqrr >>6 ) & (16 /*QM_DQRR_SIZE*/ -1 );DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = ctx->op->sym->m_src; ev->impl_opaque = index +1 ; *dpaa_seqn (ctx->op->sym->m_src) = (uint32_t )index +1 ;
Signature · 1 line
2.47.2
PATCH v3 14/19 event/dpaa: fix bitmask truncation
In reply to Stephen HemmingerMore bitmask truncation from mask computation.
--- drivers/event/dpaa/dpaa_eventdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +5 -5
@@ -102,7 +102,7 @@ dpaa_event_enqueue_burst(void *port, const struct rte_event ev[],qman_dca_index (ev[i].impl_opaque,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --;break ;default :
@@ -199,11 +199,11 @@ dpaa_event_dequeue_burst(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
@@ -263,11 +263,11 @@ dpaa_event_dequeue_burst_intr(void *port, struct rte_event ev[],/* Check if there are atomic contexts to be released */ i =0 ;while (DPAA_PER_LCORE_DQRR_SIZE ) { -if (DPAA_PER_LCORE_DQRR_HELD & (1 << i)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << i)) {qman_dca_index (i,0 ); mbuf =DPAA_PER_LCORE_DQRR_MBUF (i); *dpaa_seqn (mbuf) =DPAA_INVALID_MBUF_SEQN ; -DPAA_PER_LCORE_DQRR_HELD &= ~(1 << i); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << i);DPAA_PER_LCORE_DQRR_SIZE --; } i++;
Signature · 1 line
2.47.2
PATCH v3 15/19 net/dpaa: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa/dpaa_rxtx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/dpaa/dpaa_rxtx.c +3 -4
@@ -842,7 +842,7 @@ dpaa_rx_cb_atomic(void *event,/* Save active dqrr entries */ index =DQRR_PTR2IDX (dqrr);DPAA_PER_LCORE_DQRR_SIZE ++; -DPAA_PER_LCORE_DQRR_HELD |=1 << index; +DPAA_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << index;DPAA_PER_LCORE_DQRR_MBUF (index) = mbuf; ev->impl_opaque = index +1 ; *dpaa_seqn (mbuf) = (uint32_t )index +1 ;
@@ -1338,13 +1338,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) seqn = *dpaa_seqn (mbuf);if (seqn !=DPAA_INVALID_MBUF_SEQN ) { index = seqn -1 ; -if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) { +if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C (1 ) << index)) { flags[loop] = ((index &QM_EQCR_DCA_IDXMASK ) <<8 ); flags[loop] |=QMAN_ENQUEUE_FLAG_DCA ;DPAA_PER_LCORE_DQRR_SIZE --; -DPAA_PER_LCORE_DQRR_HELD &= - ~(1 << index); +DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << index); } }
Signature · 1 line
2.47.2
PATCH v3 16/19 net/dpaa2: fix bitmask truncation
In reply to Stephen HemmingerThe dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated.
--- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_rxtx.c +3 -3
@@ -933,7 +933,7 @@ dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (ev->mbuf) = dqrr_index +1 ;DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=1 << dqrr_index; +DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index;DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = ev->mbuf; }
@@ -1317,7 +1317,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) flags[loop] =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index;DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dqrr_index); *dpaa2_seqn (*bufs) =DPAA2_INVALID_MBUF_SEQN ; }
@@ -1575,7 +1575,7 @@ dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn (m) -1 ;qbman_eq_desc_set_dca (eqdesc,1 , dq_idx,0 );DPAA2_PER_LCORE_DQRR_SIZE --; -DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); +DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C (1 ) << dq_idx); } *dpaa2_seqn (m) =DPAA2_INVALID_MBUF_SEQN ; }
Signature · 1 line
2.47.2
PATCH v3 17/19 net/qede: don't use same loop variable twice
In reply to Stephen HemmingerUsing variable in outer loop, and inner loop is obvious bug. This bug is in base code, so likely on other platforms as well.
--- drivers/net/qede/base/ecore_dcbx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/qede/base/ecore_dcbx.c +4 -4
@@ -1363,7 +1363,7 @@ ecore_lldp_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)struct ecore_dcbx_mib_meta_data data;enum _ecore_status_t rc =ECORE_SUCCESS ;struct lldp_received_tlvs_s tlvs; -int i; +int i, j;for (i =0 ; i <LLDP_MAX_LLDP_AGENTS ; i++) {OSAL_MEM_ZERO (&data,sizeof (data));
@@ -1381,9 +1381,9 @@ ecore_lldp_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)if (!tlvs.length)continue ; -for (i =0 ; i <MAX_TLV_BUFFER ; i++) - tlvs.tlvs_buffer[i] = -OSAL_CPU_TO_BE32 (tlvs.tlvs_buffer[i]); +for (j =0 ; j <MAX_TLV_BUFFER ; j++) + tlvs.tlvs_buffer[j] = +OSAL_CPU_TO_BE32 (tlvs.tlvs_buffer[j]);OSAL_LLDP_RX_TLVS (p_hwfn, tlvs.tlvs_buffer, tlvs.length); }
Signature · 1 line
2.47.2
PATCH v3 18/19 examples/l3fwd: fix operator precedence bugs
In reply to Stephen HemmingerThe expression:
if ((socketid = rte_lcore_to_socket_id(lcore) != 0) &&
gets evaluated as sockeid = (rte_lcore_to_socket_id(lcore) != 0) which is not what was intended. This is goes all the way back to first release.
--- examples/l3fwd-power/main.c | 4 ++-- examples/l3fwd/main.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
examples/l3fwd-power/main.c +2 -2
@@ -1412,8 +1412,8 @@ check_lcore_params(void) "mask\n", lcore);return -1 ; } -if ((socketid =rte_lcore_to_socket_id (lcore) !=0 ) && - (numa_on ==0 )) { + socketid =rte_lcore_to_socket_id (lcore); +if (socketid !=0 && numa_on ==0 ) {printf ("warning: lcore %u is on socket %d with numa " "off\n" , lcore, socketid); }
examples/l3fwd/main.c +3 -2
@@ -311,8 +311,9 @@ check_lcore_params(void)printf ("error: lcore %u is not enabled in lcore mask\n" , lcore);return -1 ; } -if ((socketid =rte_lcore_to_socket_id (lcore) !=0 ) && - (numa_on ==0 )) { + + socketid =rte_lcore_to_socket_id (lcore); +if (socketid !=0 && numa_on ==0 ) {printf ("warning: lcore %u is on socket %d with numa off\n" , lcore, socketid); }
Signature · 1 line
2.47.2
PATCH v3 19/19 common/cnxk: fix null ptr check
In reply to Stephen HemmingerThe pointer mode is used then checked which is a bug reported by PVS studio.
--- drivers/common/cnxk/roc_bphy_cgx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +6 -6
@@ -366,20 +366,20 @@ roc_bphy_cgx_set_link_mode(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, {uint64_t scr1, scr0; +if (!mode) +return -EINVAL ; + +if (!roc_cgx) +return -EINVAL ; +if (roc_model_is_cn9k () && (mode->use_portm_idx || mode->portm_idx || mode->mode_group_idx)) {return -ENOTSUP ; } -if (!roc_cgx) -return -EINVAL ; -if (!roc_bphy_cgx_lmac_exists (roc_cgx, lmac))return -ENODEV ; -if (!mode) -return -EINVAL ; - scr1 =FIELD_PREP (SCR1_ETH_CMD_ID ,ETH_CMD_MODE_CHANGE ) |FIELD_PREP (SCR1_ETH_MODE_CHANGE_ARGS_SPEED , mode->speed) | FIELD_PREP(SCR1_ETH_MODE_CHANGE_ARGS_DUPLEX, mode->full_duplex) |
Signature · 1 line
2.47.2
Re: [PATCH v3 00/19] minor fixes from PVS studio bug list
In reply to Stephen HemmingerRecheck-request: iol-intel-Performance
Triggering a retest due to testbed instability yesterday.
Thomas Monjalon
AppliedRe: [PATCH v3 00/19] minor fixes from PVS studio bug list
In reply to Stephen HemmingerQuoted 12 lines
Stephen Hemminger (19):
common/cnxk: remove duplicate condition net/cpfl: avoid calling log (printf) with null raw/cnxk_gpio: fix file descriptor leak net/ntnic: remove dead code
net/i40e: remove duplicate code
eal: fix out of bounds access in devargs net/qede: fix missing debug string examples/ptpclient: replacerte_memcpywith assignment examples/ptpclient: fix self memcmpnet/octeon_ep: remove duplicate code net/hinic: fix flow type bitmask overflow
Quoted 8 lines
crypto/dpaa2_sec: fix bitmask truncation
crypto/dpaa_sec: fix bitmask truncation
event/dpaa: fix bitmask truncation
net/dpaa: fix bitmask truncation
net/dpaa2: fix bitmask truncation
net/qede: don't use same loop variable twice
examples/l3fwd: fix operator precedence bugs
common/cnxk: fix null ptr check
Applied, thanks.