struct mlx5_devcom_component {
        struct {
                void *data;
-       } device[MLX5_MAX_PORTS];
+       } device[MLX5_DEVCOM_PORTS_SUPPORTED];
 
        mlx5_devcom_event_handler_t handler;
        struct rw_semaphore sem;
        struct list_head list;
 
        struct mlx5_devcom_component components[MLX5_DEVCOM_NUM_COMPONENTS];
-       struct mlx5_core_dev *devs[MLX5_MAX_PORTS];
+       struct mlx5_core_dev *devs[MLX5_DEVCOM_PORTS_SUPPORTED];
 };
 
 struct mlx5_devcom {
 
        if (!mlx5_core_is_pf(dev))
                return NULL;
+       if (MLX5_CAP_GEN(dev, num_lag_ports) != MLX5_DEVCOM_PORTS_SUPPORTED)
+               return NULL;
 
        sguid0 = mlx5_query_nic_system_image_guid(dev);
        list_for_each_entry(iter, &devcom_list, list) {
                struct mlx5_core_dev *tmp_dev = NULL;
 
                idx = -1;
-               for (i = 0; i < MLX5_MAX_PORTS; i++) {
+               for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++) {
                        if (iter->devs[i])
                                tmp_dev = iter->devs[i];
                        else
 
        kfree(devcom);
 
-       for (i = 0; i < MLX5_MAX_PORTS; i++)
+       for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
                if (priv->devs[i])
                        break;
 
-       if (i != MLX5_MAX_PORTS)
+       if (i != MLX5_DEVCOM_PORTS_SUPPORTED)
                return;
 
        list_del(&priv->list);
 
        comp = &devcom->priv->components[id];
        down_write(&comp->sem);
-       for (i = 0; i < MLX5_MAX_PORTS; i++)
+       for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
                if (i != devcom->idx && comp->device[i].data) {
                        err = comp->handler(event, comp->device[i].data,
                                            event_data);
                return NULL;
        }
 
-       for (i = 0; i < MLX5_MAX_PORTS; i++)
+       for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
                if (i != devcom->idx)
                        break;