WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / netronome / nfp / nfp_app_nic.c
blobf119277fd66c968c8c642ce0c9b373103d43088b
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
4 #include "nfpcore/nfp_cpp.h"
5 #include "nfpcore/nfp_nsp.h"
6 #include "nfp_app.h"
7 #include "nfp_main.h"
8 #include "nfp_net.h"
9 #include "nfp_port.h"
11 int nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
12 struct nfp_net *nn, unsigned int id)
14 int err;
16 if (!pf->eth_tbl)
17 return 0;
19 nn->port = nfp_port_alloc(app, NFP_PORT_PHYS_PORT, nn->dp.netdev);
20 if (IS_ERR(nn->port))
21 return PTR_ERR(nn->port);
23 err = nfp_port_init_phy_port(pf, app, nn->port, id);
24 if (err) {
25 nfp_port_free(nn->port);
26 return err;
29 return nn->port->type == NFP_PORT_INVALID;
32 int nfp_app_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
33 unsigned int id)
35 int err;
37 err = nfp_app_nic_vnic_init_phy_port(app->pf, app, nn, id);
38 if (err)
39 return err < 0 ? err : 0;
41 nfp_net_get_mac_addr(app->pf, nn->dp.netdev, nn->port);
43 return 0;