net/nfp: fix the initialization of physical representors
Checks
Commit Message
From: Zerun Fu <zerun.fu@corigine.com>
The former logic of initializing the array of physical port
representors is according to 'nfp_idx', but referencing based
on 'port_id'. This is a potential bug and will cause segment
fault when these two values are not equal. Fix it by using the
'port_id' as index at all time.
Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org
Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_representor.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Comments
On 10/10/2023 7:03 AM, Chaoyong He wrote:
> From: Zerun Fu <zerun.fu@corigine.com>
>
> The former logic of initializing the array of physical port
> representors is according to 'nfp_idx', but referencing based
> on 'port_id'. This is a potential bug and will cause segment
> fault when these two values are not equal. Fix it by using the
> 'port_id' as index at all time.
>
> Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework")
> Cc: chaoyong.he@corigine.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
>
Applied to dpdk-next-net/main, thanks.
@@ -646,6 +646,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
void *init_params)
{
int ret;
+ uint16_t index;
unsigned int numa_node;
char ring_name[RTE_ETH_NAME_MAX_LEN];
struct nfp_app_fw_flower *app_fw_flower;
@@ -719,10 +720,13 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
}
/* Add repr to correct array */
- if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT)
- app_fw_flower->phy_reprs[repr->nfp_idx] = repr;
- else
- app_fw_flower->vf_reprs[repr->vf_id] = repr;
+ if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT) {
+ index = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(repr->port_id);
+ app_fw_flower->phy_reprs[index] = repr;
+ } else {
+ index = repr->vf_id;
+ app_fw_flower->vf_reprs[index] = repr;
+ }
return 0;