Commit ef825bdb authored by Przemek Kitszel's avatar Przemek Kitszel Committed by Tony Nguyen
Browse files

ice: move ice_init_pf() out of ice_init_dev()



Move ice_init_pf() out of ice_init_dev().
Do the same for deinit counterpart.

Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent e3bf1cdd
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -459,6 +459,7 @@ static void ice_devlink_reinit_down(struct ice_pf *pf)
	rtnl_lock();
	ice_vsi_decfg(ice_get_main_vsi(pf));
	rtnl_unlock();
	ice_deinit_pf(pf);
	ice_deinit_dev(pf);
}

@@ -1231,11 +1232,12 @@ static void ice_set_min_max_msix(struct ice_pf *pf)
static int ice_devlink_reinit_up(struct ice_pf *pf)
{
	struct ice_vsi *vsi = ice_get_main_vsi(pf);
	struct device *dev = ice_pf_to_dev(pf);
	int err;

	err = ice_init_hw(&pf->hw);
	if (err) {
		dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err);
		dev_err(dev, "ice_init_hw failed: %d\n", err);
		return err;
	}

@@ -1246,13 +1248,19 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
	if (err)
		goto unroll_hw_init;

	err = ice_init_pf(pf);
	if (err) {
		dev_err(dev, "ice_init_pf failed: %d\n", err);
		goto unroll_dev_init;
	}

	vsi->flags = ICE_VSI_FLAG_INIT;

	rtnl_lock();
	err = ice_vsi_cfg(vsi);
	rtnl_unlock();
	if (err)
		goto err_vsi_cfg;
		goto unroll_pf_init;

	/* No need to take devl_lock, it's already taken by devlink API */
	err = ice_load(pf);
@@ -1265,7 +1273,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
	rtnl_lock();
	ice_vsi_decfg(vsi);
	rtnl_unlock();
err_vsi_cfg:
unroll_pf_init:
	ice_deinit_pf(pf);
unroll_dev_init:
	ice_deinit_dev(pf);
unroll_hw_init:
	ice_deinit_hw(&pf->hw);
+2 −0
Original line number Diff line number Diff line
@@ -1035,6 +1035,8 @@ void ice_unload(struct ice_pf *pf);
void ice_adv_lnk_speed_maps_init(void);
int ice_init_dev(struct ice_pf *pf);
void ice_deinit_dev(struct ice_pf *pf);
int ice_init_pf(struct ice_pf *pf);
void ice_deinit_pf(struct ice_pf *pf);
int ice_change_mtu(struct net_device *netdev, int new_mtu);
void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue);
int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp);
+16 −16
Original line number Diff line number Diff line
@@ -3949,7 +3949,7 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf)
 * ice_deinit_pf - Unrolls initialziations done by ice_init_pf
 * @pf: board private structure to initialize
 */
static void ice_deinit_pf(struct ice_pf *pf)
void ice_deinit_pf(struct ice_pf *pf)
{
	/* note that we unroll also on ice_init_pf() failure here */

@@ -4045,8 +4045,9 @@ void ice_start_service_task(struct ice_pf *pf)
/**
 * ice_init_pf - Initialize general software structures (struct ice_pf)
 * @pf: board private structure to initialize
 * Return: 0 on success, negative errno otherwise.
 */
static int ice_init_pf(struct ice_pf *pf)
int ice_init_pf(struct ice_pf *pf)
{
	struct udp_tunnel_nic_info *udp_tunnel_nic = &pf->hw.udp_tunnel_nic;
	struct device *dev = ice_pf_to_dev(pf);
@@ -4772,23 +4773,12 @@ int ice_init_dev(struct ice_pf *pf)
	}

	ice_start_service_task(pf);
	err = ice_init_pf(pf);
	if (err) {
		dev_err(dev, "ice_init_pf failed: %d\n", err);
		goto unroll_irq_scheme_init;
	}

	return 0;

unroll_irq_scheme_init:
	ice_service_task_stop(pf);
	ice_clear_interrupt_scheme(pf);
	return err;
}

void ice_deinit_dev(struct ice_pf *pf)
{
	ice_deinit_pf(pf);
	ice_deinit_hw(&pf->hw);
	ice_service_task_stop(pf);

@@ -5030,21 +5020,28 @@ static void ice_deinit_devlink(struct ice_pf *pf)

static int ice_init(struct ice_pf *pf)
{
	struct device *dev = ice_pf_to_dev(pf);
	int err;

	err = ice_init_dev(pf);
	if (err)
		return err;

	err = ice_init_pf(pf);
	if (err) {
		dev_err(dev, "ice_init_pf failed: %d\n", err);
		goto unroll_dev_init;
	}

	if (pf->hw.mac_type == ICE_MAC_E830) {
		err = pci_enable_ptm(pf->pdev, NULL);
		if (err)
			dev_dbg(ice_pf_to_dev(pf), "PCIe PTM not supported by PCIe bus/controller\n");
			dev_dbg(dev, "PCIe PTM not supported by PCIe bus/controller\n");
	}

	err = ice_alloc_vsis(pf);
	if (err)
		goto err_alloc_vsis;
		goto unroll_pf_init;

	err = ice_init_pf_sw(pf);
	if (err)
@@ -5081,7 +5078,9 @@ static int ice_init(struct ice_pf *pf)
	ice_deinit_pf_sw(pf);
err_init_pf_sw:
	ice_dealloc_vsis(pf);
err_alloc_vsis:
unroll_pf_init:
	ice_deinit_pf(pf);
unroll_dev_init:
	ice_deinit_dev(pf);
	return err;
}
@@ -5093,6 +5092,7 @@ static void ice_deinit(struct ice_pf *pf)

	ice_deinit_pf_sw(pf);
	ice_dealloc_vsis(pf);
	ice_deinit_pf(pf);
	ice_deinit_dev(pf);
}