Skip to content

Commit ea2d37b

Browse files
sbasavapatnadavem330
authored andcommitted
bnxt_en: Refactor bnxt_vf_reps_create().
Add a new function bnxt_alloc_vf_rep() to allocate a VF representor. This function will be needed in subsequent patches to recreate the VF reps after error recovery. Signed-off-by: Sriharsha Basavapatna <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 190eda1 commit ea2d37b

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ void bnxt_vf_reps_destroy(struct bnxt *bp)
350350
__bnxt_vf_reps_destroy(bp);
351351
}
352352

353+
static int bnxt_alloc_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep,
354+
u16 *cfa_code_map)
355+
{
356+
/* get cfa handles from FW */
357+
if (hwrm_cfa_vfr_alloc(bp, vf_rep->vf_idx, &vf_rep->tx_cfa_action,
358+
&vf_rep->rx_cfa_code))
359+
return -ENOLINK;
360+
361+
cfa_code_map[vf_rep->rx_cfa_code] = vf_rep->vf_idx;
362+
vf_rep->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL);
363+
if (!vf_rep->dst)
364+
return -ENOMEM;
365+
366+
/* only cfa_action is needed to mux a packet while TXing */
367+
vf_rep->dst->u.port_info.port_id = vf_rep->tx_cfa_action;
368+
vf_rep->dst->u.port_info.lower_dev = bp->dev;
369+
370+
return 0;
371+
}
372+
353373
/* Use the OUI of the PF's perm addr and report the same mac addr
354374
* for the same VF-rep each time
355375
*/
@@ -428,25 +448,9 @@ static int bnxt_vf_reps_create(struct bnxt *bp)
428448
vf_rep->vf_idx = i;
429449
vf_rep->tx_cfa_action = CFA_HANDLE_INVALID;
430450

431-
/* get cfa handles from FW */
432-
rc = hwrm_cfa_vfr_alloc(bp, vf_rep->vf_idx,
433-
&vf_rep->tx_cfa_action,
434-
&vf_rep->rx_cfa_code);
435-
if (rc) {
436-
rc = -ENOLINK;
437-
goto err;
438-
}
439-
cfa_code_map[vf_rep->rx_cfa_code] = vf_rep->vf_idx;
440-
441-
vf_rep->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
442-
GFP_KERNEL);
443-
if (!vf_rep->dst) {
444-
rc = -ENOMEM;
451+
rc = bnxt_alloc_vf_rep(bp, vf_rep, cfa_code_map);
452+
if (rc)
445453
goto err;
446-
}
447-
/* only cfa_action is needed to mux a packet while TXing */
448-
vf_rep->dst->u.port_info.port_id = vf_rep->tx_cfa_action;
449-
vf_rep->dst->u.port_info.lower_dev = bp->dev;
450454

451455
bnxt_vf_rep_netdev_init(bp, vf_rep, dev);
452456
rc = register_netdev(dev);

0 commit comments

Comments
 (0)