2 * Copyright (C) 2017 Netronome Systems, Inc.
4 * This software is dual licensed under the GNU General License Version 2,
5 * June 1991 as shown in the file COPYING in the top-level directory of this
6 * source tree or the BSD 2-Clause License provided below. You have the
7 * option to license this software under the complete terms of either license.
9 * The BSD 2-Clause License:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * 1. Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * 2. Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 #include <net/devlink.h>
44 * enum nfp_port_type - type of port NFP can switch traffic to
45 * @NFP_PORT_INVALID: port is invalid, %NFP_PORT_PHYS_PORT transitions to this
46 * state when port disappears because of FW fault or config
48 * @NFP_PORT_PHYS_PORT: external NIC port
56 * enum nfp_port_flags - port flags (can be type-specific)
57 * @NFP_PORT_CHANGED: port state has changed since last eth table refresh;
58 * for NFP_PORT_PHYS_PORT, never set otherwise; must hold
66 * struct nfp_port - structure representing NFP port
67 * @netdev: backpointer to associated netdev
68 * @type: what port type does the entity represent
70 * @app: backpointer to the app structure
71 * @dl_port: devlink port structure
72 * @eth_id: for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
73 * @eth_port: for %NFP_PORT_PHYS_PORT translated ETH Table port entry
74 * @port_list: entry on pf's list of ports
77 struct net_device *netdev;
78 enum nfp_port_type type;
84 struct devlink_port dl_port;
87 struct nfp_eth_table_port *eth_port;
89 struct list_head port_list;
92 struct nfp_port *nfp_port_from_netdev(struct net_device *netdev);
93 struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port);
94 struct nfp_eth_table_port *nfp_port_get_eth_port(struct nfp_port *port);
97 nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len);
100 nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
101 struct net_device *netdev);
102 void nfp_port_free(struct nfp_port *port);
104 int nfp_net_refresh_eth_port(struct nfp_port *port);
105 void nfp_net_refresh_port_table(struct nfp_port *port);
107 int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port);
108 void nfp_devlink_port_unregister(struct nfp_port *port);