Lines Matching +full:port +full:- +full:id

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
19 return nn->port; in nfp_port_from_netdev()
25 return repr->port; in nfp_port_from_netdev()
36 struct nfp_port *port; in nfp_port_get_port_parent_id() local
39 port = nfp_port_from_netdev(netdev); in nfp_port_get_port_parent_id()
40 if (!port) in nfp_port_get_port_parent_id()
41 return -EOPNOTSUPP; in nfp_port_get_port_parent_id()
43 ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial); in nfp_port_get_port_parent_id()
44 memcpy(&ppid->id, serial, ppid->id_len); in nfp_port_get_port_parent_id()
52 struct nfp_port *port; in nfp_port_setup_tc() local
54 port = nfp_port_from_netdev(netdev); in nfp_port_setup_tc()
55 if (!port) in nfp_port_setup_tc()
56 return -EOPNOTSUPP; in nfp_port_setup_tc()
58 return nfp_app_setup_tc(port->app, netdev, type, type_data); in nfp_port_setup_tc()
63 struct nfp_port *port; in nfp_port_set_features() local
65 port = nfp_port_from_netdev(netdev); in nfp_port_set_features()
66 if (!port) in nfp_port_set_features()
69 if ((netdev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) && in nfp_port_set_features()
70 port->tc_offload_cnt) { in nfp_port_set_features()
72 return -EBUSY; in nfp_port_set_features()
78 struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port) in __nfp_port_get_eth_port() argument
80 if (!port) in __nfp_port_get_eth_port()
82 if (port->type != NFP_PORT_PHYS_PORT) in __nfp_port_get_eth_port()
85 return port->eth_port; in __nfp_port_get_eth_port()
88 struct nfp_eth_table_port *nfp_port_get_eth_port(struct nfp_port *port) in nfp_port_get_eth_port() argument
90 if (!__nfp_port_get_eth_port(port)) in nfp_port_get_eth_port()
93 if (test_bit(NFP_PORT_CHANGED, &port->flags)) in nfp_port_get_eth_port()
94 if (nfp_net_refresh_eth_port(port)) in nfp_port_get_eth_port()
97 return __nfp_port_get_eth_port(port); in nfp_port_get_eth_port()
104 struct nfp_port *port; in nfp_port_get_phys_port_name() local
107 port = nfp_port_from_netdev(netdev); in nfp_port_get_phys_port_name()
108 if (!port) in nfp_port_get_phys_port_name()
109 return -EOPNOTSUPP; in nfp_port_get_phys_port_name()
111 switch (port->type) { in nfp_port_get_phys_port_name()
113 eth_port = __nfp_port_get_eth_port(port); in nfp_port_get_phys_port_name()
115 return -EOPNOTSUPP; in nfp_port_get_phys_port_name()
117 if (!eth_port->is_split) in nfp_port_get_phys_port_name()
118 n = snprintf(name, len, "p%d", eth_port->label_port); in nfp_port_get_phys_port_name()
120 n = snprintf(name, len, "p%ds%d", eth_port->label_port, in nfp_port_get_phys_port_name()
121 eth_port->label_subport); in nfp_port_get_phys_port_name()
124 if (!port->pf_split) in nfp_port_get_phys_port_name()
125 n = snprintf(name, len, "pf%d", port->pf_id); in nfp_port_get_phys_port_name()
127 n = snprintf(name, len, "pf%ds%d", port->pf_id, in nfp_port_get_phys_port_name()
128 port->pf_split_id); in nfp_port_get_phys_port_name()
131 n = snprintf(name, len, "pf%dvf%d", port->pf_id, port->vf_id); in nfp_port_get_phys_port_name()
134 return -EOPNOTSUPP; in nfp_port_get_phys_port_name()
138 return -EINVAL; in nfp_port_get_phys_port_name()
144 * nfp_port_configure() - helper to set the interface configured bit
152 * 0 - configuration successful (or no change);
153 * -ERRNO - configuration failed.
158 struct nfp_port *port; in nfp_port_configure() local
161 port = nfp_port_from_netdev(netdev); in nfp_port_configure()
162 eth_port = __nfp_port_get_eth_port(port); in nfp_port_configure()
165 if (port->eth_forced) in nfp_port_configure()
168 err = nfp_eth_set_configured(port->app->cpp, eth_port->index, configed); in nfp_port_configure()
169 return err < 0 && err != -EOPNOTSUPP ? err : 0; in nfp_port_configure()
173 struct nfp_port *port, unsigned int id) in nfp_port_init_phy_port() argument
175 /* Check if vNIC has external port associated and cfg is OK */ in nfp_port_init_phy_port()
176 if (!pf->eth_tbl || id >= pf->eth_tbl->count) { in nfp_port_init_phy_port()
177 nfp_err(app->cpp, in nfp_port_init_phy_port()
178 "NSP port entries don't match vNICs (no entry %d)\n", in nfp_port_init_phy_port()
179 id); in nfp_port_init_phy_port()
180 return -EINVAL; in nfp_port_init_phy_port()
182 if (pf->eth_tbl->ports[id].override_changed) { in nfp_port_init_phy_port()
183 nfp_warn(app->cpp, in nfp_port_init_phy_port()
184 "Config changed for port #%d, reboot required before port will be operational\n", in nfp_port_init_phy_port()
185 pf->eth_tbl->ports[id].index); in nfp_port_init_phy_port()
186 port->type = NFP_PORT_INVALID; in nfp_port_init_phy_port()
190 port->eth_port = &pf->eth_tbl->ports[id]; in nfp_port_init_phy_port()
191 port->eth_id = pf->eth_tbl->ports[id].index; in nfp_port_init_phy_port()
192 port->netdev->dev_port = id; in nfp_port_init_phy_port()
193 if (pf->mac_stats_mem) in nfp_port_init_phy_port()
194 port->eth_stats = in nfp_port_init_phy_port()
195 pf->mac_stats_mem + port->eth_id * NFP_MAC_STATS_SIZE; in nfp_port_init_phy_port()
204 struct nfp_port *port; in nfp_port_alloc() local
206 port = kzalloc(sizeof(*port), GFP_KERNEL); in nfp_port_alloc()
207 if (!port) in nfp_port_alloc()
208 return ERR_PTR(-ENOMEM); in nfp_port_alloc()
210 port->netdev = netdev; in nfp_port_alloc()
211 port->type = type; in nfp_port_alloc()
212 port->app = app; in nfp_port_alloc()
214 list_add_tail(&port->port_list, &app->pf->ports); in nfp_port_alloc()
216 return port; in nfp_port_alloc()
219 void nfp_port_free(struct nfp_port *port) in nfp_port_free() argument
221 if (!port) in nfp_port_free()
223 list_del(&port->port_list); in nfp_port_free()
224 kfree(port); in nfp_port_free()