Lines Matching refs:ed
1188 static int fun_init_vports(struct fun_ethdev *ed, unsigned int n) in fun_init_vports() argument
1190 if (ed->num_vports) in fun_init_vports()
1193 ed->vport_info = kvcalloc(n, sizeof(*ed->vport_info), GFP_KERNEL); in fun_init_vports()
1194 if (!ed->vport_info) in fun_init_vports()
1196 ed->num_vports = n; in fun_init_vports()
1200 static void fun_free_vports(struct fun_ethdev *ed) in fun_free_vports() argument
1202 kvfree(ed->vport_info); in fun_free_vports()
1203 ed->vport_info = NULL; in fun_free_vports()
1204 ed->num_vports = 0; in fun_free_vports()
1207 static struct fun_vport_info *fun_get_vport(struct fun_ethdev *ed, in fun_get_vport() argument
1210 if (!ed->vport_info || vport >= ed->num_vports) in fun_get_vport()
1213 return ed->vport_info + vport; in fun_get_vport()
1221 struct fun_ethdev *ed = to_fun_ethdev(fdev); in fun_set_vf_mac() local
1228 mutex_lock(&ed->state_mutex); in fun_set_vf_mac()
1229 vi = fun_get_vport(ed, vf); in fun_set_vf_mac()
1239 mutex_unlock(&ed->state_mutex); in fun_set_vf_mac()
1249 struct fun_ethdev *ed = to_fun_ethdev(fdev); in fun_set_vf_vlan() local
1259 mutex_lock(&ed->state_mutex); in fun_set_vf_vlan()
1260 vi = fun_get_vport(ed, vf); in fun_set_vf_vlan()
1273 mutex_unlock(&ed->state_mutex); in fun_set_vf_vlan()
1283 struct fun_ethdev *ed = to_fun_ethdev(fdev); in fun_set_vf_rate() local
1290 mutex_lock(&ed->state_mutex); in fun_set_vf_rate()
1291 vi = fun_get_vport(ed, vf); in fun_set_vf_rate()
1300 mutex_unlock(&ed->state_mutex); in fun_set_vf_rate()
1308 struct fun_ethdev *ed = to_fun_ethdev(fp->fdev); in fun_get_vf_config() local
1311 mutex_lock(&ed->state_mutex); in fun_get_vf_config()
1312 vi = fun_get_vport(ed, vf); in fun_get_vf_config()
1325 mutex_unlock(&ed->state_mutex); in fun_get_vf_config()
1533 static int fun_max_qs(struct fun_ethdev *ed, unsigned int *ntx, in fun_max_qs() argument
1538 if (ed->num_ports > 1 || is_kdump_kernel()) { in fun_max_qs()
1544 neth = fun_get_res_count(&ed->fdev, FUN_ADMIN_OP_ETH); in fun_max_qs()
1555 *ntx = min(ed->nsqs_per_port - 1, num_online_cpus()); in fun_max_qs()
1710 static int fun_create_netdev(struct fun_ethdev *ed, unsigned int portid) in fun_create_netdev() argument
1712 struct fun_dev *fdev = &ed->fdev; in fun_create_netdev()
1718 rc = fun_max_qs(ed, &ntx, &nrx); in fun_create_netdev()
1729 fun_queue_defaults(netdev, ed->nsqs_per_port); in fun_create_netdev()
1799 ed->netdevs[portid] = netdev; in fun_create_netdev()
1809 ed->netdevs[portid] = NULL; in fun_create_netdev()
1840 static int fun_create_ports(struct fun_ethdev *ed, unsigned int nports) in fun_create_ports() argument
1842 struct fun_dev *fd = &ed->fdev; in fun_create_ports()
1846 ed->nsqs_per_port = min(fd->num_irqs - 1, in fun_create_ports()
1848 if (ed->nsqs_per_port < 2) { in fun_create_ports()
1853 ed->netdevs = kcalloc(nports, sizeof(*ed->netdevs), GFP_KERNEL); in fun_create_ports()
1854 if (!ed->netdevs) in fun_create_ports()
1857 ed->num_ports = nports; in fun_create_ports()
1859 rc = fun_create_netdev(ed, i); in fun_create_ports()
1868 fun_destroy_netdev(ed->netdevs[--i]); in fun_create_ports()
1869 kfree(ed->netdevs); in fun_create_ports()
1870 ed->netdevs = NULL; in fun_create_ports()
1871 ed->num_ports = 0; in fun_create_ports()
1875 static void fun_destroy_ports(struct fun_ethdev *ed) in fun_destroy_ports() argument
1879 for (i = 0; i < ed->num_ports; i++) in fun_destroy_ports()
1880 fun_destroy_netdev(ed->netdevs[i]); in fun_destroy_ports()
1882 kfree(ed->netdevs); in fun_destroy_ports()
1883 ed->netdevs = NULL; in fun_destroy_ports()
1884 ed->num_ports = 0; in fun_destroy_ports()
1887 static void fun_update_link_state(const struct fun_ethdev *ed, in fun_update_link_state() argument
1894 if (port_idx >= ed->num_ports) in fun_update_link_state()
1897 netdev = ed->netdevs[port_idx]; in fun_update_link_state()
1947 struct fun_ethdev *ed = to_fun_ethdev(fdev); in fun_service_cb() local
1951 fun_destroy_ports(ed); in fun_service_cb()
1957 if (rc < 0 || rc == ed->num_ports) in fun_service_cb()
1960 if (ed->num_ports) in fun_service_cb()
1961 fun_destroy_ports(ed); in fun_service_cb()
1963 fun_create_ports(ed, rc); in fun_service_cb()
1969 struct fun_ethdev *ed = to_fun_ethdev(fdev); in funeth_sriov_configure() local
1979 mutex_lock(&ed->state_mutex); in funeth_sriov_configure()
1980 fun_free_vports(ed); in funeth_sriov_configure()
1981 mutex_unlock(&ed->state_mutex); in funeth_sriov_configure()
1990 mutex_lock(&ed->state_mutex); in funeth_sriov_configure()
1991 rc = fun_init_vports(ed, nvfs); in funeth_sriov_configure()
1992 mutex_unlock(&ed->state_mutex); in funeth_sriov_configure()
2014 struct fun_ethdev *ed; in funeth_probe() local
2024 ed = devlink_priv(devlink); in funeth_probe()
2025 mutex_init(&ed->state_mutex); in funeth_probe()
2027 fdev = &ed->fdev; in funeth_probe()
2034 rc = fun_create_ports(ed, rc); in funeth_probe()
2045 mutex_destroy(&ed->state_mutex); in funeth_probe()
2054 struct fun_ethdev *ed; in funeth_remove() local
2056 ed = to_fun_ethdev(fdev); in funeth_remove()
2057 devlink = priv_to_devlink(ed); in funeth_remove()
2065 fun_destroy_ports(ed); in funeth_remove()
2067 mutex_destroy(&ed->state_mutex); in funeth_remove()