bnxt patchset
PATCH 2/5 net/bnxt: fix to free allocated memory
In reply to Ajit KhapardeIn some cases we may not be freeing up memory allocated for certain NVM commands because the code might have bailed out before reaching rte_free(). This patch moves some code around to ensure the allocated memory is freed before exiting the function.
--- drivers/net/bnxt/bnxt_hwrm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +6 -6
@@ -3353,13 +3353,12 @@ int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data) req.host_dest_addr =rte_cpu_to_le_64 (dma_handle); rc =bnxt_hwrm_send_message (bp, &req,sizeof (req)); -HWRM_CHECK_RESULT (); -HWRM_UNLOCK (); -if (rc ==0 )memcpy (data, buf, len > buflen ? buflen : len);rte_free (buf); +HWRM_CHECK_RESULT (); +HWRM_UNLOCK ();return rc; }
@@ -3391,12 +3390,13 @@ int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index, req.offset =rte_cpu_to_le_32 (offset); req.len =rte_cpu_to_le_32 (length); rc =bnxt_hwrm_send_message (bp, &req,sizeof (req)); -HWRM_CHECK_RESULT (); -HWRM_UNLOCK ();if (rc ==0 )memcpy (data, buf, length);rte_free (buf); +HWRM_CHECK_RESULT (); +HWRM_UNLOCK (); +return rc; }
@@ -3451,10 +3451,10 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type, rc =bnxt_hwrm_send_message (bp, &req,sizeof (req)); +rte_free (buf);HWRM_CHECK_RESULT ();HWRM_UNLOCK (); -rte_free (buf);return rc; }
Signature · 1 line
2.15.2 (Apple Git-101.1)
PATCH 3/5 net/bnxt: fix to release lock when alloc fails in NVM write
In reply to Ajit KhapardeIn bnxt_hwrm_flash_nvram, before attempting to allocate a buffer we are grabbing the rte_spinlock. And if the allocation fails we are returning before releasing the spinlock. We avoid the situation by calling HWRM_PREP which grabs the lock after the buffer is allocated successfully.
--- drivers/net/bnxt/bnxt_hwrm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +8 -8
@@ -3427,14 +3427,6 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,rte_iova_t dma_handle;uint8_t *buf; -HWRM_PREP (req,NVM_WRITE ); - - req.dir_type =rte_cpu_to_le_16 (dir_type); - req.dir_ordinal =rte_cpu_to_le_16 (dir_ordinal); - req.dir_ext =rte_cpu_to_le_16 (dir_ext); - req.dir_attr =rte_cpu_to_le_16 (dir_attr); - req.dir_data_length =rte_cpu_to_le_32 (data_len); - buf =rte_malloc ("nvm_write" , data_len,0 );rte_mem_lock_page (buf);if (!buf)
@@ -3447,6 +3439,14 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,return -ENOMEM ; }memcpy (buf, data, data_len); + +HWRM_PREP (req,NVM_WRITE ); + + req.dir_type =rte_cpu_to_le_16 (dir_type); + req.dir_ordinal =rte_cpu_to_le_16 (dir_ordinal); + req.dir_ext =rte_cpu_to_le_16 (dir_ext); + req.dir_attr =rte_cpu_to_le_16 (dir_attr); + req.dir_data_length =rte_cpu_to_le_32 (data_len); req.host_src_addr =rte_cpu_to_le_64 (dma_handle); rc =bnxt_hwrm_send_message (bp, &req,sizeof (req));
Signature · 1 line
2.15.2 (Apple Git-101.1)
PATCH 4/5 net/bnxt: check access denied error for HWRM commands
In reply to Ajit KhapardeFirmware can restrict access to certain resources in the hardware depending on various factors. In such cases when the PMD tries to configure these resources the firmware will return HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED error. Parse this and return the standard EACCES error to the applications.
--- drivers/net/bnxt/bnxt_hwrm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +8 -0
@@ -182,6 +182,10 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,if (rc) { \PMD_DRV_LOG (ERR ,"failed rc:%d\n" , rc); \rte_spinlock_unlock (&bp->hwrm_lock); \ +if (rc ==HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED ) \ + rc = -EACCES ; \ +else if (rc >0 ) \ + rc = -EINVAL ; \return rc; \ } \if (resp->error_code) { \
@@ -200,6 +204,10 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,PMD_DRV_LOG (ERR ,"error %d\n" , rc); \ } \rte_spinlock_unlock (&bp->hwrm_lock); \ +if (rc ==HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED ) \ + rc = -EACCES ; \ +else if (rc >0 ) \ + rc = -EINVAL ; \return rc; \ } \ }while (0 )
Signature · 1 line
2.15.2 (Apple Git-101.1)
PATCH 5/5 net/bnxt: fix to set proper reta size
In reply to Ajit KhapardeThe reta_size being indicated in the bnxt_dev_info_get_op was incorrect. Set it to the value supported by the hardware.
--- drivers/net/bnxt/bnxt_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +1 -1
@@ -438,7 +438,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,/* For the sake of symmetry, max_rx_queues = max_tx_queues */ dev_info->max_rx_queues = max_rx_rings; dev_info->max_tx_queues = max_rx_rings; - dev_info->reta_size = bp->max_rsscos_ctx; + dev_info->reta_size =HW_HASH_INDEX_SIZE ; dev_info->hash_key_size =40 ; max_vnics = bp->max_vnics;
Signature · 1 line
2.15.2 (Apple Git-101.1)
cover bnxt patchset
This patchset against next-net fixes issues identified during QA testing. Please apply.
Ajit Khaparde (4):
net/bnxt: fix to free allocated memory
net/bnxt: fix to release lock when alloc fails in NVM write net/bnxt: check access denied error for HWRM commands net/bnxt: fix to set proper reta size
Somnath Kotur (1):
net/bnxt: fix to remove element from the vnic's filter list
drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/bnxt_hwrm.c | 37 +++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 15 deletions(-)
Signature · 1 line
2.15.2 (Apple Git-101.1)
PATCH 1/5 net/bnxt: fix to remove element from the vnic's filter list
From: Somnath Kotur <[email protected]>
bnxt_clear_hwrm_vnic_filters() was removing the created filter from HW, but not clearing the internal data structures by removing it from the struct bnxt_vnic_info->filter list.
--- drivers/net/bnxt/bnxt_hwrm.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt_hwrm.c +1 -0
@@ -2020,6 +2020,7 @@ int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) rc =bnxt_hwrm_clear_ntuple_filter (bp, filter); else rc =bnxt_hwrm_clear_l2_filter (bp, filter); +STAILQ_REMOVE (&vnic->filter, filter, bnxt_filter_info, next);//if (rc) //break; }
Signature · 1 line
2.15.2 (Apple Git-101.1)
26/07/2018 03:15, Ajit Khaparde:
Quoted 11 lines
This patchset against next-net fixes issues identified during QA testing. Please apply.
Ajit Khaparde (4):
net/bnxt: fix to free allocated memory
net/bnxt: fix to release lock when alloc fails in NVM write net/bnxt: check access denied error for HWRM commands net/bnxt: fix to set proper reta sizeSomnath Kotur (1):
net/bnxt: fix to remove element from the vnic's filter list
Applied with following titles (hopefully easier to read):
net/bnxt: fix filter freeing
net/bnxt: fix memory leaks in NVM commands net/bnxt: fix lock release on NVM write failure net/bnxt: check access denied for HWRM commands net/bnxt: fix RETA size
The Signed-off-by is also moved before Reviewed-by in order to reflect the chronological order.