Wed, Apr 17, 2024 at 04:20:26PM CEST, [email protected] wrote:
>From: Piotr Raczynski <[email protected]>

[...]


>+static int ice_sf_dev_probe(struct auxiliary_device *adev,
>+                          const struct auxiliary_device_id *id)
>+{
>+      struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev);
>+      struct ice_dynamic_port *dyn_port = sf_dev->dyn_port;
>+      struct ice_vsi_cfg_params params = {};
>+      struct ice_vsi *vsi = dyn_port->vsi;
>+      struct ice_pf *pf = dyn_port->pf;
>+      struct device *dev = &adev->dev;
>+      struct ice_sf_priv *priv;
>+      struct devlink *devlink;
>+      int err;
>+
>+      params.type = ICE_VSI_SF;
>+      params.pi = pf->hw.port_info;
>+      params.flags = ICE_VSI_FLAG_INIT;
>+
>+      priv = ice_allocate_sf(&adev->dev);
>+      if (!priv) {
>+              dev_err(dev, "Subfunction devlink alloc failed");
>+              return -ENOMEM;
>+      }
>+
>+      priv->dev = sf_dev;
>+      sf_dev->priv = priv;
>+      devlink = priv_to_devlink(priv);
>+
>+      devlink_register(devlink);

Do register at the very end. Btw, currently the error path seems to be
broken, leaving devlink instance allocated and registered.


>+      devl_lock(devlink);
>+
>+      err = ice_vsi_cfg(vsi, &params);
>+      if (err) {
>+              dev_err(dev, "Subfunction vsi config failed");
>+              goto err_devlink_unlock;
>+      }
>+
>+      err = ice_devlink_create_sf_dev_port(sf_dev);
>+      if (err) {
>+              dev_err(dev, "Cannot add ice virtual devlink port for 
>subfunction");
>+              goto err_vsi_decfg;
>+      }
>+
>+      err = ice_fltr_add_mac_and_broadcast(vsi, vsi->netdev->dev_addr,
>+                                           ICE_FWD_TO_VSI);
>+      if (err) {
>+              dev_err(dev, "can't add MAC filters %pM for VSI %d\n",
>+                      vsi->netdev->dev_addr, vsi->idx);
>+              goto err_devlink_destroy;
>+      }
>+
>+      ice_napi_add(vsi);
>+      devl_unlock(devlink);
>+
>+      return 0;
>+
>+err_devlink_destroy:
>+      ice_devlink_destroy_sf_dev_port(sf_dev);
>+err_vsi_decfg:
>+      ice_vsi_decfg(vsi);
>+err_devlink_unlock:
>+      devl_unlock(devlink);
>+      return err;

[...]

Reply via email to