Skip to content

Commit 6c167f5

Browse files
Elizabeth KapplerJeff Kirsher
authored andcommitted
i40e: Refactor and cleanup i40e_open(), adding i40e_vsi_open()
This patch cleans up and moves a portion of i40e_open to i40e_vsi_open, in order to have a shorter vsi_open function that does only that. Change-ID: I1c418dda94dcfc0eb7d4386a70c330692ef5ecc9 Signed-off-by: Elizabeth Kappler <elizabeth.m.kappler@intel.com> Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@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>
1 parent 7c3c288 commit 6c167f5

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct i40e_pf {
208208
bool fc_autoneg_status;
209209

210210
u16 eeprom_version;
211-
u16 num_vmdq_vsis; /* num vmdq pools this pf has set up */
211+
u16 num_vmdq_vsis; /* num vmdq vsis this pf has set up */
212212
u16 num_vmdq_qps; /* num queue pairs per vmdq pool */
213213
u16 num_vmdq_msix; /* num queue vectors per vmdq pool */
214214
u16 num_req_vfs; /* num vfs requested for this vf */
@@ -597,6 +597,7 @@ void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector);
597597
void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf);
598598
void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf);
599599
int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
600+
int i40e_vsi_open(struct i40e_vsi *vsi);
600601
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
601602
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
602603
int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4235,7 +4235,6 @@ static int i40e_open(struct net_device *netdev)
42354235
struct i40e_netdev_priv *np = netdev_priv(netdev);
42364236
struct i40e_vsi *vsi = np->vsi;
42374237
struct i40e_pf *pf = vsi->back;
4238-
char int_name[IFNAMSIZ];
42394238
int err;
42404239

42414240
/* disallow open during test */
@@ -4244,6 +4243,31 @@ static int i40e_open(struct net_device *netdev)
42444243

42454244
netif_carrier_off(netdev);
42464245

4246+
err = i40e_vsi_open(vsi);
4247+
if (err)
4248+
return err;
4249+
4250+
#ifdef CONFIG_I40E_VXLAN
4251+
vxlan_get_rx_port(netdev);
4252+
#endif
4253+
4254+
return 0;
4255+
}
4256+
4257+
/**
4258+
* i40e_vsi_open -
4259+
* @vsi: the VSI to open
4260+
*
4261+
* Finish initialization of the VSI.
4262+
*
4263+
* Returns 0 on success, negative value on failure
4264+
**/
4265+
int i40e_vsi_open(struct i40e_vsi *vsi)
4266+
{
4267+
struct i40e_pf *pf = vsi->back;
4268+
char int_name[IFNAMSIZ];
4269+
int err;
4270+
42474271
/* allocate descriptors */
42484272
err = i40e_vsi_setup_tx_resources(vsi);
42494273
if (err)
@@ -4256,29 +4280,29 @@ static int i40e_open(struct net_device *netdev)
42564280
if (err)
42574281
goto err_setup_rx;
42584282

4283+
if (!vsi->netdev) {
4284+
err = EINVAL;
4285+
goto err_setup_rx;
4286+
}
42594287
snprintf(int_name, sizeof(int_name) - 1, "%s-%s",
4260-
dev_driver_string(&pf->pdev->dev), netdev->name);
4288+
dev_driver_string(&pf->pdev->dev), vsi->netdev->name);
42614289
err = i40e_vsi_request_irq(vsi, int_name);
42624290
if (err)
42634291
goto err_setup_rx;
42644292

42654293
/* Notify the stack of the actual queue counts. */
4266-
err = netif_set_real_num_tx_queues(netdev, vsi->num_queue_pairs);
4294+
err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_queue_pairs);
42674295
if (err)
42684296
goto err_set_queues;
42694297

4270-
err = netif_set_real_num_rx_queues(netdev, vsi->num_queue_pairs);
4298+
err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_queue_pairs);
42714299
if (err)
42724300
goto err_set_queues;
42734301

42744302
err = i40e_up_complete(vsi);
42754303
if (err)
42764304
goto err_up_complete;
42774305

4278-
#ifdef CONFIG_I40E_VXLAN
4279-
vxlan_get_rx_port(netdev);
4280-
#endif
4281-
42824306
return 0;
42834307

42844308
err_up_complete:

0 commit comments

Comments
 (0)