Lines Matching +full:hp +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (C) 2016-2017 Oracle. All rights reserved.
37 * and dev->tx_timeout() should be called to fix the problem.
66 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in vsw_get_drvinfo()
67 strscpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); in vsw_get_drvinfo()
74 return port->vp->msg_enable; in vsw_get_msglevel()
81 port->vp->msg_enable = value; in vsw_set_msglevel()
111 return port->q_index; in vsw_select_queue()
124 return sunvnet_set_rx_mode_common(dev, port->vp); in vsw_set_rx_mode()
130 struct vio_driver_state *vio = &port->vio; in ldmvsw_open()
145 return sunvnet_poll_controller_common(dev, port->vp); in vsw_poll_controller()
163 static const char *local_mac_prop = "local-mac-address";
164 static const char *cfg_handle_prop = "cfg-handle";
166 static struct vnet *vsw_get_vnet(struct mdesc_handle *hp, in vsw_get_vnet() argument
176 /* Get the parent virtual-network-switch macaddr and cfghandle */ in vsw_get_vnet()
177 mdesc_for_each_arc(a, hp, port_node, MDESC_ARC_TYPE_BACK) { in vsw_get_vnet()
178 u64 target = mdesc_arc_target(hp, a); in vsw_get_vnet()
181 name = mdesc_get_property(hp, target, "name", NULL); in vsw_get_vnet()
182 if (!name || strcmp(name, "virtual-network-switch")) in vsw_get_vnet()
185 local_mac = mdesc_get_property(hp, target, in vsw_get_vnet()
187 cfghandle = mdesc_get_property(hp, target, in vsw_get_vnet()
192 return ERR_PTR(-ENODEV); in vsw_get_vnet()
198 if (iter->local_mac == *local_mac) { in vsw_get_vnet()
208 return ERR_PTR(-ENOMEM); in vsw_get_vnet()
211 spin_lock_init(&vp->lock); in vsw_get_vnet()
212 INIT_LIST_HEAD(&vp->port_list); in vsw_get_vnet()
213 INIT_LIST_HEAD(&vp->list); in vsw_get_vnet()
214 vp->local_mac = *local_mac; in vsw_get_vnet()
215 list_add(&vp->list, &vnet_list); in vsw_get_vnet()
235 return ERR_PTR(-ENOMEM); in vsw_alloc_netdev()
236 dev->needed_headroom = VNET_PACKET_SKIP + 8; in vsw_alloc_netdev()
237 dev->needed_tailroom = 8; in vsw_alloc_netdev()
240 ether_addr_copy(dev->perm_addr, dev->dev_addr); in vsw_alloc_netdev()
242 sprintf(dev->name, "vif%d.%d", (int)handle, (int)port_id); in vsw_alloc_netdev()
244 dev->netdev_ops = &vsw_ops; in vsw_alloc_netdev()
245 dev->ethtool_ops = &vsw_ethtool_ops; in vsw_alloc_netdev()
246 dev->watchdog_timeo = VSW_TX_TIMEOUT; in vsw_alloc_netdev()
248 dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG; in vsw_alloc_netdev()
249 dev->features = dev->hw_features; in vsw_alloc_netdev()
251 /* MTU range: 68 - 65535 */ in vsw_alloc_netdev()
252 dev->min_mtu = ETH_MIN_MTU; in vsw_alloc_netdev()
253 dev->max_mtu = VNET_MAX_MTU; in vsw_alloc_netdev()
255 SET_NETDEV_DEV(dev, &vdev->dev); in vsw_alloc_netdev()
272 static const char *remote_macaddr_prop = "remote-mac-address";
277 struct mdesc_handle *hp; in vsw_port_probe() local
287 hp = mdesc_grab(); in vsw_port_probe()
289 if (!hp) in vsw_port_probe()
290 return -ENODEV; in vsw_port_probe()
292 rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len); in vsw_port_probe()
293 err = -ENODEV; in vsw_port_probe()
296 mdesc_release(hp); in vsw_port_probe()
300 port_id = mdesc_get_property(hp, vdev->mp, id_prop, NULL); in vsw_port_probe()
301 err = -ENODEV; in vsw_port_probe()
304 mdesc_release(hp); in vsw_port_probe()
309 vp = vsw_get_vnet(hp, vdev->mp, &handle); in vsw_port_probe()
312 pr_err("Failed to get vnet for vsw-port\n"); in vsw_port_probe()
313 mdesc_release(hp); in vsw_port_probe()
317 mdesc_release(hp); in vsw_port_probe()
322 pr_err("Failed to alloc netdev for vsw-port\n"); in vsw_port_probe()
328 INIT_LIST_HEAD(&port->list); in vsw_port_probe()
331 port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff; in vsw_port_probe()
333 port->vp = vp; in vsw_port_probe()
334 port->dev = dev; in vsw_port_probe()
335 port->switch_port = 1; in vsw_port_probe()
336 port->tso = false; /* no tso in vsw, misbehaves in bridge */ in vsw_port_probe()
337 port->tsolen = 0; in vsw_port_probe()
345 port->vsw = 1; in vsw_port_probe()
347 err = vio_driver_init(&port->vio, vdev, VDEV_NETWORK, in vsw_port_probe()
349 &vsw_vio_ops, dev->name); in vsw_port_probe()
353 err = vio_ldc_alloc(&port->vio, &vsw_ldc_cfg, port); in vsw_port_probe()
357 dev_set_drvdata(&vdev->dev, port); in vsw_port_probe()
359 netif_napi_add(dev, &port->napi, sunvnet_poll_common); in vsw_port_probe()
361 spin_lock_irqsave(&vp->lock, flags); in vsw_port_probe()
362 list_add_rcu(&port->list, &vp->port_list); in vsw_port_probe()
363 spin_unlock_irqrestore(&vp->lock, flags); in vsw_port_probe()
365 timer_setup(&port->clean_timer, sunvnet_clean_timer_expire_common, 0); in vsw_port_probe()
373 spin_lock_irqsave(&vp->lock, flags); in vsw_port_probe()
375 spin_unlock_irqrestore(&vp->lock, flags); in vsw_port_probe()
377 napi_enable(&port->napi); in vsw_port_probe()
378 vio_port_up(&port->vio); in vsw_port_probe()
385 netdev_info(dev, "LDOM vsw-port %pM\n", dev->dev_addr); in vsw_port_probe()
387 pr_info("%s: PORT ( remote-mac %pM%s )\n", dev->name, in vsw_port_probe()
388 port->raddr, " switch-port"); in vsw_port_probe()
393 del_timer_sync(&port->clean_timer); in vsw_port_probe()
394 list_del_rcu(&port->list); in vsw_port_probe()
396 netif_napi_del(&port->napi); in vsw_port_probe()
397 dev_set_drvdata(&vdev->dev, NULL); in vsw_port_probe()
398 vio_ldc_free(&port->vio); in vsw_port_probe()
407 struct vnet_port *port = dev_get_drvdata(&vdev->dev); in vsw_port_remove()
411 del_timer_sync(&port->vio.timer); in vsw_port_remove()
412 del_timer_sync(&port->clean_timer); in vsw_port_remove()
414 napi_disable(&port->napi); in vsw_port_remove()
415 unregister_netdev(port->dev); in vsw_port_remove()
417 list_del_rcu(&port->list); in vsw_port_remove()
420 spin_lock_irqsave(&port->vp->lock, flags); in vsw_port_remove()
422 spin_unlock_irqrestore(&port->vp->lock, flags); in vsw_port_remove()
423 netif_napi_del(&port->napi); in vsw_port_remove()
425 vio_ldc_free(&port->vio); in vsw_port_remove()
427 dev_set_drvdata(&vdev->dev, NULL); in vsw_port_remove()
429 free_netdev(port->dev); in vsw_port_remove()
441 list_del(&vp->list); in vsw_cleanup()
443 if (!list_empty(&vp->port_list)) in vsw_cleanup()
452 .type = "vsw-port",