Skip to content

Commit

Permalink
i40e: rework fdir setup and teardown
Browse files Browse the repository at this point in the history
Use the newer i40e_vsi_open() and i40e_vsi_close() in the FDIR VSI
lifetime.  This makes sure we're using standard methods for all the
VSI open and close paths.  This also fixes a memory leak of the
FDIR queue buffer info structs across a reset.

Change-ID: I1b60a1b08ab923afe4f49810c2c7844d850e19b9
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
Shannon Nelson authored and Jeff Kirsher committed Apr 22, 2014
1 parent 8276f75 commit 8a9eb7d
Showing 1 changed file with 17 additions and 40 deletions.
57 changes: 17 additions & 40 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4335,6 +4335,11 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
vsi->num_queue_pairs);
if (err)
goto err_set_queues;

} else if (vsi->type == I40E_VSI_FDIR) {
snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
dev_driver_string(&pf->pdev->dev));
err = i40e_vsi_request_irq(vsi, int_name);
} else {
err = EINVAL;
goto err_setup_rx;
Expand Down Expand Up @@ -5269,8 +5274,7 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi);
static void i40e_fdir_sb_setup(struct i40e_pf *pf)
{
struct i40e_vsi *vsi;
bool new_vsi = false;
int err, i;
int i;

if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
return;
Expand All @@ -5290,47 +5294,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
pf->vsi[pf->lan_vsi]->seid, 0);
if (!vsi) {
dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n");
goto err_vsi;
pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
return;
}
new_vsi = true;
}
i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);

err = i40e_vsi_setup_tx_resources(vsi);
if (err)
goto err_setup_tx;
err = i40e_vsi_setup_rx_resources(vsi);
if (err)
goto err_setup_rx;

if (new_vsi) {
char int_name[IFNAMSIZ + 9];
err = i40e_vsi_configure(vsi);
if (err)
goto err_setup_rx;
snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
dev_driver_string(&pf->pdev->dev));
err = i40e_vsi_request_irq(vsi, int_name);
if (err)
goto err_setup_rx;
err = i40e_up_complete(vsi);
if (err)
goto err_up_complete;
clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
}

return;

err_up_complete:
i40e_down(vsi);
i40e_vsi_free_irq(vsi);
err_setup_rx:
i40e_vsi_free_rx_resources(vsi);
err_setup_tx:
i40e_vsi_free_tx_resources(vsi);
err_vsi:
pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
i40e_vsi_clear(vsi);
i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
}

/**
Expand Down Expand Up @@ -8184,6 +8153,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
u16 link_status;
int err = 0;
u32 len;
u32 i;

err = pci_enable_device_mem(pdev);
if (err)
Expand Down Expand Up @@ -8373,6 +8343,13 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
goto err_vsis;
}
/* if FDIR VSI was set up, start it now */
for (i = 0; i < pf->hw.func_caps.num_vsis; i++) {
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
i40e_vsi_open(pf->vsi[i]);
break;
}
}

/* The main driver is (mostly) up and happy. We need to set this state
* before setting up the misc vector or we get a race and the vector
Expand Down

0 comments on commit 8a9eb7d

Please sign in to comment.