Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / net / ethernet / netronome / nfp / nic / main.c
blob9dd5afe37f6e44ca0c4043db58514a0964246e89
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2017 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 "main.h"
11 static int nfp_nic_init(struct nfp_app *app)
13 struct nfp_pf *pf = app->pf;
15 if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count) {
16 nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
17 pf->max_data_vnics, pf->eth_tbl->count);
18 return -EINVAL;
21 return 0;
24 static int nfp_nic_sriov_enable(struct nfp_app *app, int num_vfs)
26 return 0;
29 static void nfp_nic_sriov_disable(struct nfp_app *app)
33 static int nfp_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn)
35 return nfp_nic_dcb_init(nn);
38 static void nfp_nic_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
40 nfp_nic_dcb_clean(nn);
43 static int nfp_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
44 unsigned int id)
46 struct nfp_app_nic_private *app_pri = nn->app_priv;
47 int err;
49 err = nfp_app_nic_vnic_alloc(app, nn, id);
50 if (err)
51 return err;
53 if (sizeof(*app_pri)) {
54 nn->app_priv = kzalloc(sizeof(*app_pri), GFP_KERNEL);
55 if (!nn->app_priv)
56 return -ENOMEM;
59 return 0;
62 static void nfp_nic_vnic_free(struct nfp_app *app, struct nfp_net *nn)
64 kfree(nn->app_priv);
67 const struct nfp_app_type app_nic = {
68 .id = NFP_APP_CORE_NIC,
69 .name = "nic",
71 .init = nfp_nic_init,
72 .vnic_alloc = nfp_nic_vnic_alloc,
73 .vnic_free = nfp_nic_vnic_free,
74 .sriov_enable = nfp_nic_sriov_enable,
75 .sriov_disable = nfp_nic_sriov_disable,
77 .vnic_init = nfp_nic_vnic_init,
78 .vnic_clean = nfp_nic_vnic_clean,