Lines Matching refs:vswp

79 static	int vsw_unattach(vsw_t *vswp);
85 static int vsw_mdeg_register(vsw_t *vswp);
86 static void vsw_mdeg_unregister(vsw_t *vswp);
89 static int vsw_get_initial_md_properties(vsw_t *vswp, md_t *, mde_cookie_t);
90 static int vsw_read_mdprops(vsw_t *vswp);
96 static int vsw_port_read_props(vsw_port_t *portp, vsw_t *vswp,
98 static void vsw_read_pri_eth_types(vsw_t *vswp, md_t *mdp,
100 static void vsw_mtu_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node,
102 static int vsw_mtu_update(vsw_t *vswp, uint32_t mtu);
103 static void vsw_linkprop_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node,
105 static void vsw_bandwidth_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node,
108 static void vsw_save_lmacaddr(vsw_t *vswp, uint64_t macaddr);
122 void vsw_mac_link_update(vsw_t *vswp, link_state_t link_state);
123 void vsw_mac_rx(vsw_t *vswp, mac_resource_handle_t mrh,
125 void vsw_physlink_state_update(vsw_t *vswp);
131 extern int vsw_setup_switching_start(vsw_t *vswp);
132 extern void vsw_setup_switching_stop(vsw_t *vswp);
134 extern void vsw_switch_frame_nop(vsw_t *vswp, mblk_t *mp, int caller,
140 extern void vsw_detach_ports(vsw_t *vswp);
141 extern int vsw_port_add(vsw_t *vswp, md_t *mdp, mde_cookie_t *node);
142 extern int vsw_port_detach(vsw_t *vswp, int p_instance);
143 static int vsw_port_update(vsw_t *vswp, md_t *curr_mdp, mde_cookie_t curr_mdex,
146 extern vsw_port_t *vsw_lookup_port(vsw_t *vswp, int p_instance);
147 extern int vsw_mac_open(vsw_t *vswp);
148 extern void vsw_mac_close(vsw_t *vswp);
149 extern void vsw_mac_cleanup_ports(vsw_t *vswp);
150 extern void vsw_unset_addrs(vsw_t *vswp);
151 extern void vsw_setup_switching_post_process(vsw_t *vswp);
160 extern void vsw_hio_cleanup(vsw_t *vswp);
161 extern void vsw_hio_start_ports(vsw_t *vswp);
167 extern int vsw_mac_client_init(vsw_t *vswp, vsw_port_t *port, int type);
168 extern void vsw_mac_client_cleanup(vsw_t *vswp, vsw_port_t *port, int type);
169 extern void vsw_if_mac_reconfig(vsw_t *vswp, boolean_t update_vlans,
171 extern void vsw_reset_ports(vsw_t *vswp);
173 extern void vsw_physlink_update_ports(vsw_t *vswp);
174 extern void vsw_update_bandwidth(vsw_t *vswp, vsw_port_t *port, int type,
513 vswdebug(vsw_t *vswp, const char *fmt, ...) in vswdebug() argument
522 if (vswp == NULL) in vswdebug()
525 cmn_err(CE_CONT, "vsw%d: %s\n", vswp->instance, buf); in vswdebug()
581 vsw_t *vswp; in vsw_attach() local
604 vswp = ddi_get_soft_state(vsw_state, instance); in vsw_attach()
606 if (vswp == NULL) { in vsw_attach()
611 vswp->dip = dip; in vsw_attach()
612 vswp->instance = instance; in vsw_attach()
613 vswp->phys_link_state = LINK_STATE_UNKNOWN; in vsw_attach()
614 ddi_set_driver_private(dip, (caddr_t)vswp); in vsw_attach()
616 mutex_init(&vswp->mac_lock, NULL, MUTEX_DRIVER, NULL); in vsw_attach()
617 mutex_init(&vswp->mca_lock, NULL, MUTEX_DRIVER, NULL); in vsw_attach()
618 mutex_init(&vswp->sw_thr_lock, NULL, MUTEX_DRIVER, NULL); in vsw_attach()
619 cv_init(&vswp->sw_thr_cv, NULL, CV_DRIVER, NULL); in vsw_attach()
620 rw_init(&vswp->maccl_rwlock, NULL, RW_DRIVER, NULL); in vsw_attach()
621 rw_init(&vswp->if_lockrw, NULL, RW_DRIVER, NULL); in vsw_attach()
622 rw_init(&vswp->mfdbrw, NULL, RW_DRIVER, NULL); in vsw_attach()
623 rw_init(&vswp->plist.lockrw, NULL, RW_DRIVER, NULL); in vsw_attach()
627 rv = vsw_read_mdprops(vswp); in vsw_attach()
635 vswp->instance); in vsw_attach()
636 D2(vswp, "creating unicast hash table (%s)...", hashname); in vsw_attach()
637 vswp->fdb_nchains = vsw_fdb_nchains; in vsw_attach()
638 vswp->fdb_hashp = mod_hash_create_ptrhash(hashname, vswp->fdb_nchains, in vsw_attach()
640 vsw_create_vlans((void *)vswp, VSW_LOCALDEV); in vsw_attach()
645 vswp->instance); in vsw_attach()
646 D2(vswp, "creating multicast hash table %s)...", hashname); in vsw_attach()
647 vswp->mfdb = mod_hash_create_ptrhash(hashname, vsw_fdb_nchains, in vsw_attach()
656 (void) snprintf(qname, TASKQ_NAMELEN, "taskq%d", vswp->instance); in vsw_attach()
657 if ((vswp->taskq_p = ddi_taskq_create(vswp->dip, qname, 1, in vsw_attach()
660 vswp->instance); in vsw_attach()
667 vswp->instance); in vsw_attach()
668 if ((vswp->rxp_taskq = ddi_taskq_create(vswp->dip, qname, 1, in vsw_attach()
671 vswp->instance); in vsw_attach()
678 if (ddi_prop_update_int(DDI_DEV_T_NONE, vswp->dip, in vsw_attach()
688 vswp->vsw_switch_frame = vsw_switch_frame_nop; in vsw_attach()
695 rv = vsw_setup_switching_start(vswp); in vsw_attach()
703 rv = vsw_mac_register(vswp); in vsw_attach()
721 rv = vsw_mdeg_register(vswp); in vsw_attach()
727 vswp->attach_progress = progress; in vsw_attach()
730 vswp->next = vsw_head; in vsw_attach()
731 vsw_head = vswp; in vsw_attach()
734 ddi_report_dev(vswp->dip); in vsw_attach()
740 vswp->attach_progress = progress; in vsw_attach()
741 (void) vsw_unattach(vswp); in vsw_attach()
749 vsw_t **vswpp, *vswp; in vsw_detach() local
753 vswp = ddi_get_soft_state(vsw_state, instance); in vsw_detach()
755 if (vswp == NULL) { in vsw_detach()
768 D2(vswp, "detaching instance %d", instance); in vsw_detach()
770 if (vsw_unattach(vswp) != 0) { in vsw_detach()
778 if (*vswpp == vswp) { in vsw_detach()
779 *vswpp = vswp->next; in vsw_detach()
797 vsw_unattach(vsw_t *vswp) in vsw_unattach() argument
801 progress = vswp->attach_progress; in vsw_unattach()
809 if (vsw_mac_unregister(vswp) != 0) { in vsw_unattach()
811 "MAC layer", vswp->instance); in vsw_unattach()
827 vsw_mdeg_unregister(vswp); in vsw_unattach()
828 vsw_detach_ports(vswp); in vsw_unattach()
845 vsw_setup_switching_stop(vswp); in vsw_unattach()
847 if (vswp->hio_capable == B_TRUE) { in vsw_unattach()
848 vsw_hio_cleanup(vswp); in vsw_unattach()
849 vswp->hio_capable = B_FALSE; in vsw_unattach()
852 mutex_enter(&vswp->mac_lock); in vsw_unattach()
853 vsw_mac_close(vswp); in vsw_unattach()
854 mutex_exit(&vswp->mac_lock); in vsw_unattach()
866 ddi_taskq_destroy(vswp->rxp_taskq); in vsw_unattach()
876 ddi_taskq_destroy(vswp->taskq_p); in vsw_unattach()
882 mod_hash_destroy_hash(vswp->mfdb); in vsw_unattach()
888 vsw_destroy_vlans(vswp, VSW_LOCALDEV); in vsw_unattach()
889 mod_hash_destroy_hash(vswp->fdb_hashp); in vsw_unattach()
894 if (VSW_PRI_ETH_DEFINED(vswp)) { in vsw_unattach()
895 kmem_free(vswp->pri_types, in vsw_unattach()
896 sizeof (uint16_t) * vswp->pri_num_types); in vsw_unattach()
897 (void) vio_destroy_mblks(vswp->pri_tx_vmp); in vsw_unattach()
903 rw_destroy(&vswp->plist.lockrw); in vsw_unattach()
904 rw_destroy(&vswp->mfdbrw); in vsw_unattach()
905 rw_destroy(&vswp->if_lockrw); in vsw_unattach()
906 rw_destroy(&vswp->maccl_rwlock); in vsw_unattach()
907 cv_destroy(&vswp->sw_thr_cv); in vsw_unattach()
908 mutex_destroy(&vswp->sw_thr_lock); in vsw_unattach()
909 mutex_destroy(&vswp->mca_lock); in vsw_unattach()
910 mutex_destroy(&vswp->mac_lock); in vsw_unattach()
914 vswp->attach_progress = progress; in vsw_unattach()
947 vsw_get_md_physname(vsw_t *vswp, md_t *mdp, mde_cookie_t node, char *name) in vsw_get_md_physname() argument
956 dev_name = ddi_driver_name(vswp->dip); in vsw_get_md_physname()
957 instance = ddi_get_instance(vswp->dip); in vsw_get_md_physname()
963 "device(s) from MD", vswp->instance); in vsw_get_md_physname()
967 vswp->instance, physname); in vsw_get_md_physname()
975 vswp->instance, physname); in vsw_get_md_physname()
979 D2(vswp, "%s: using first device specified (%s)", in vsw_get_md_physname()
993 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, vswp->dip, 0, in vsw_get_md_physname()
997 vswp->instance, dev); in vsw_get_md_physname()
1002 "config file", vswp->instance, dev); in vsw_get_md_physname()
1020 vsw_get_md_smodes(vsw_t *vswp, md_t *mdp, mde_cookie_t node, uint8_t *mode) in vsw_get_md_smodes() argument
1026 D1(vswp, "%s: enter", __func__); in vsw_get_md_smodes()
1041 " from the MD", vswp->instance); in vsw_get_md_smodes()
1056 D2(vswp, "%s: curr_mode = [%s]", __func__, curr_mode); in vsw_get_md_smodes()
1066 vswp->instance, curr_mode); in vsw_get_md_smodes()
1072 D2(vswp, "%s: %d mode", __func__, *mode); in vsw_get_md_smodes()
1074 D1(vswp, "%s: exit", __func__); in vsw_get_md_smodes()
1084 vsw_mac_register(vsw_t *vswp) in vsw_mac_register() argument
1089 D1(vswp, "%s: enter", __func__); in vsw_mac_register()
1094 macp->m_driver = vswp; in vsw_mac_register()
1095 macp->m_dip = vswp->dip; in vsw_mac_register()
1096 macp->m_src_addr = (uint8_t *)&vswp->if_addr; in vsw_mac_register()
1099 macp->m_max_sdu = vswp->mtu; in vsw_mac_register()
1101 rv = mac_register(macp, &vswp->if_mh); in vsw_mac_register()
1109 "a provider with MAC layer", vswp->instance); in vsw_mac_register()
1113 vswp->if_state |= VSW_IF_REG; in vsw_mac_register()
1115 D1(vswp, "%s: exit", __func__); in vsw_mac_register()
1121 vsw_mac_unregister(vsw_t *vswp) in vsw_mac_unregister() argument
1125 D1(vswp, "%s: enter", __func__); in vsw_mac_unregister()
1127 WRITE_ENTER(&vswp->if_lockrw); in vsw_mac_unregister()
1129 if (vswp->if_state & VSW_IF_REG) { in vsw_mac_unregister()
1130 rv = mac_unregister(vswp->if_mh); in vsw_mac_unregister()
1132 DWARN(vswp, "%s: unable to unregister from MAC " in vsw_mac_unregister()
1135 RW_EXIT(&vswp->if_lockrw); in vsw_mac_unregister()
1136 D1(vswp, "%s: fail exit", __func__); in vsw_mac_unregister()
1141 vswp->if_state &= ~(VSW_IF_UP | VSW_IF_REG); in vsw_mac_unregister()
1143 RW_EXIT(&vswp->if_lockrw); in vsw_mac_unregister()
1145 D1(vswp, "%s: exit", __func__); in vsw_mac_unregister()
1153 vsw_t *vswp = (vsw_t *)arg; in vsw_m_stat() local
1155 D1(vswp, "%s: enter", __func__); in vsw_m_stat()
1157 mutex_enter(&vswp->mac_lock); in vsw_m_stat()
1158 if (vswp->mh == NULL) { in vsw_m_stat()
1159 mutex_exit(&vswp->mac_lock); in vsw_m_stat()
1164 *val = mac_stat_get(vswp->mh, stat); in vsw_m_stat()
1166 mutex_exit(&vswp->mac_lock); in vsw_m_stat()
1174 vsw_t *vswp = (vsw_t *)arg; in vsw_m_stop() local
1176 D1(vswp, "%s: enter", __func__); in vsw_m_stop()
1178 WRITE_ENTER(&vswp->if_lockrw); in vsw_m_stop()
1179 vswp->if_state &= ~VSW_IF_UP; in vsw_m_stop()
1180 RW_EXIT(&vswp->if_lockrw); in vsw_m_stop()
1183 vsw_mac_client_cleanup(vswp, NULL, VSW_LOCALDEV); in vsw_m_stop()
1185 D1(vswp, "%s: exit (state = %d)", __func__, vswp->if_state); in vsw_m_stop()
1192 vsw_t *vswp = (vsw_t *)arg; in vsw_m_start() local
1194 D1(vswp, "%s: enter", __func__); in vsw_m_start()
1196 WRITE_ENTER(&vswp->if_lockrw); in vsw_m_start()
1198 vswp->if_state |= VSW_IF_UP; in vsw_m_start()
1200 if (vswp->switching_setup_done == B_FALSE) { in vsw_m_start()
1207 RW_EXIT(&vswp->if_lockrw); in vsw_m_start()
1212 if (vswp->mh != NULL) { in vsw_m_start()
1214 rv = vsw_mac_client_init(vswp, NULL, VSW_LOCALDEV); in vsw_m_start()
1218 "unicast address\n", vswp->instance); in vsw_m_start()
1222 RW_EXIT(&vswp->if_lockrw); in vsw_m_start()
1224 D1(vswp, "%s: exit (state = %d)", __func__, vswp->if_state); in vsw_m_start()
1246 vsw_t *vswp = (vsw_t *)arg; in vsw_m_multicst() local
1251 D1(vswp, "%s: enter", __func__); in vsw_m_multicst()
1261 D2(vswp, "%s: addr = 0x%llx", __func__, addr); in vsw_m_multicst()
1264 D2(vswp, "%s: adding multicast", __func__); in vsw_m_multicst()
1265 if (vsw_add_mcst(vswp, VSW_LOCALDEV, addr, NULL) == 0) { in vsw_m_multicst()
1273 DERR(vswp, "%s unable to alloc mem", __func__); in vsw_m_multicst()
1274 (void) vsw_del_mcst(vswp, in vsw_m_multicst()
1285 ret = vsw_mac_multicast_add(vswp, NULL, mcst_p, in vsw_m_multicst()
1288 (void) vsw_del_mcst(vswp, in vsw_m_multicst()
1294 mutex_enter(&vswp->mca_lock); in vsw_m_multicst()
1295 mcst_p->nextp = vswp->mcap; in vsw_m_multicst()
1296 vswp->mcap = mcst_p; in vsw_m_multicst()
1297 mutex_exit(&vswp->mca_lock); in vsw_m_multicst()
1300 "address", vswp->instance); in vsw_m_multicst()
1305 D2(vswp, "%s: removing multicast", __func__); in vsw_m_multicst()
1309 if (vsw_del_mcst(vswp, VSW_LOCALDEV, addr, NULL) == 0) { in vsw_m_multicst()
1315 mcst_p = vsw_del_addr(VSW_LOCALDEV, vswp, addr); in vsw_m_multicst()
1318 vsw_mac_multicast_remove(vswp, NULL, mcst_p, VSW_LOCALDEV); in vsw_m_multicst()
1322 D1(vswp, "%s: exit", __func__); in vsw_m_multicst()
1330 vsw_t *vswp = (vsw_t *)arg; in vsw_m_promisc() local
1332 D1(vswp, "%s: enter", __func__); in vsw_m_promisc()
1334 WRITE_ENTER(&vswp->if_lockrw); in vsw_m_promisc()
1336 vswp->if_state |= VSW_IF_PROMISC; in vsw_m_promisc()
1338 vswp->if_state &= ~VSW_IF_PROMISC; in vsw_m_promisc()
1339 RW_EXIT(&vswp->if_lockrw); in vsw_m_promisc()
1341 D1(vswp, "%s: exit", __func__); in vsw_m_promisc()
1349 vsw_t *vswp = (vsw_t *)arg; in vsw_m_tx() local
1351 D1(vswp, "%s: enter", __func__); in vsw_m_tx()
1353 mp = vsw_vlan_frame_pretag(vswp, VSW_LOCALDEV, mp); in vsw_m_tx()
1359 vswp->vsw_switch_frame(vswp, mp, VSW_LOCALDEV, NULL, NULL); in vsw_m_tx()
1361 D1(vswp, "%s: exit", __func__); in vsw_m_tx()
1372 vsw_mdeg_register(vsw_t *vswp) in vsw_mdeg_register() argument
1380 D1(vswp, "%s: enter", __func__); in vsw_mdeg_register()
1392 VSW_SET_MDEG_PROP_INST(pspecp, vswp->regprop); in vsw_mdeg_register()
1399 D2(vswp, "%s: instance %d registering with mdeg", __func__, in vsw_mdeg_register()
1400 vswp->regprop); in vsw_mdeg_register()
1406 (void *)vswp, &mdeg_hdl); in vsw_mdeg_register()
1408 DERR(vswp, "%s: mdeg_register failed (%d) for vsw node", in vsw_mdeg_register()
1417 (void *)vswp, &mdeg_port_hdl); in vsw_mdeg_register()
1419 DERR(vswp, "%s: mdeg_register failed (%d)\n", __func__, rv); in vsw_mdeg_register()
1425 vswp->inst_spec = inst_specp; in vsw_mdeg_register()
1426 vswp->mdeg_hdl = mdeg_hdl; in vsw_mdeg_register()
1427 vswp->mdeg_port_hdl = mdeg_port_hdl; in vsw_mdeg_register()
1429 D1(vswp, "%s: exit", __func__); in vsw_mdeg_register()
1434 vswp->instance); in vsw_mdeg_register()
1438 vswp->mdeg_hdl = 0; in vsw_mdeg_register()
1439 vswp->mdeg_port_hdl = 0; in vsw_mdeg_register()
1445 vsw_mdeg_unregister(vsw_t *vswp) in vsw_mdeg_unregister() argument
1447 D1(vswp, "vsw_mdeg_unregister: enter"); in vsw_mdeg_unregister()
1449 if (vswp->mdeg_hdl != 0) in vsw_mdeg_unregister()
1450 (void) mdeg_unregister(vswp->mdeg_hdl); in vsw_mdeg_unregister()
1452 if (vswp->mdeg_port_hdl != 0) in vsw_mdeg_unregister()
1453 (void) mdeg_unregister(vswp->mdeg_port_hdl); in vsw_mdeg_unregister()
1455 if (vswp->inst_spec != NULL) { in vsw_mdeg_unregister()
1456 if (vswp->inst_spec->specp != NULL) { in vsw_mdeg_unregister()
1457 (void) kmem_free(vswp->inst_spec->specp, in vsw_mdeg_unregister()
1459 vswp->inst_spec->specp = NULL; in vsw_mdeg_unregister()
1462 (void) kmem_free(vswp->inst_spec, sizeof (mdeg_node_spec_t)); in vsw_mdeg_unregister()
1463 vswp->inst_spec = NULL; in vsw_mdeg_unregister()
1466 D1(vswp, "vsw_mdeg_unregister: exit"); in vsw_mdeg_unregister()
1475 vsw_t *vswp; in vsw_mdeg_cb() local
1484 vswp = (vsw_t *)cb_argp; in vsw_mdeg_cb()
1486 D1(vswp, "%s: added %d : removed %d : curr matched %d" in vsw_mdeg_cb()
1512 "invalid: %d\n", vswp->instance, resp->added.nelem); in vsw_mdeg_cb()
1523 "invalid: %d\n", vswp->instance, in vsw_mdeg_cb()
1537 DERR(vswp, "%s: unable to get node name\n", __func__); in vsw_mdeg_cb()
1543 DERR(vswp, "%s: Invalid node name: %s\n", in vsw_mdeg_cb()
1549 DERR(vswp, "%s: prop(cfg-handle) not found\n", in vsw_mdeg_cb()
1555 if (inst != vswp->regprop) { in vsw_mdeg_cb()
1556 DERR(vswp, "%s: Invalid cfg-handle: %lx\n", in vsw_mdeg_cb()
1561 vsw_update_md_prop(vswp, mdp, node); in vsw_mdeg_cb()
1573 vsw_t *vswp; in vsw_port_mdeg_cb() local
1583 vswp = (vsw_t *)cb_argp; in vsw_port_mdeg_cb()
1585 D2(vswp, "%s: added %d : removed %d : curr matched %d" in vsw_port_mdeg_cb()
1595 D2(vswp, "%s: adding node(%d) 0x%lx", __func__, idx, node); in vsw_port_mdeg_cb()
1597 if ((rv = vsw_port_add(vswp, mdp, &node)) != 0) { in vsw_port_mdeg_cb()
1599 "(0x%lx), err=%d", vswp->instance, node, rv); in vsw_port_mdeg_cb()
1609 DERR(vswp, "%s: prop(%s) not found in port(%d)", in vsw_port_mdeg_cb()
1614 D2(vswp, "%s: removing node(%d) 0x%lx", __func__, idx, node); in vsw_port_mdeg_cb()
1616 if (vsw_port_detach(vswp, inst) != 0) { in vsw_port_mdeg_cb()
1618 vswp->instance, inst); in vsw_port_mdeg_cb()
1623 (void) vsw_port_update(vswp, resp->match_curr.mdp, in vsw_port_mdeg_cb()
1629 D1(vswp, "%s: exit", __func__); in vsw_port_mdeg_cb()
1640 vsw_read_mdprops(vsw_t *vswp) in vsw_read_mdprops() argument
1667 inst = ddi_prop_get_int(DDI_DEV_T_ANY, vswp->dip, in vsw_read_mdprops()
1671 "OBP device tree", vswp->instance, reg_propname); in vsw_read_mdprops()
1675 vswp->regprop = inst; in vsw_read_mdprops()
1678 DWARN(vswp, "%s: cannot init MD\n", __func__); in vsw_read_mdprops()
1695 DWARN(vswp, "%s: invalid num_devs:%d\n", __func__, num_devs); in vsw_read_mdprops()
1709 DWARN(vswp, "%s: name property not found\n", in vsw_read_mdprops()
1719 DWARN(vswp, "%s: cfg-handle property not found\n", in vsw_read_mdprops()
1729 rv = vsw_get_initial_md_properties(vswp, mdp, listp[i]); in vsw_read_mdprops()
1744 vsw_get_initial_md_properties(vsw_t *vswp, md_t *mdp, mde_cookie_t node) in vsw_get_initial_md_properties() argument
1748 D1(vswp, "%s: enter", __func__); in vsw_get_initial_md_properties()
1750 if (vsw_get_md_physname(vswp, mdp, node, vswp->physname) != 0) { in vsw_get_initial_md_properties()
1757 vswp->instance); in vsw_get_initial_md_properties()
1761 vsw_save_lmacaddr(vswp, macaddr); in vsw_get_initial_md_properties()
1763 if (vsw_get_md_smodes(vswp, mdp, node, &vswp->smode)) { in vsw_get_initial_md_properties()
1764 DWARN(vswp, "%s: Unable to read %s property from MD, " in vsw_get_initial_md_properties()
1768 vswp->smode = VSW_LAYER2; in vsw_get_initial_md_properties()
1775 vsw_linkprop_read(vswp, mdp, node, &vswp->pls_update); in vsw_get_initial_md_properties()
1778 vsw_mtu_read(vswp, mdp, node, &vswp->mtu); in vsw_get_initial_md_properties()
1779 if (vswp->mtu < ETHERMTU || vswp->mtu > VNET_MAX_MTU) { in vsw_get_initial_md_properties()
1780 vswp->mtu = ETHERMTU; in vsw_get_initial_md_properties()
1782 vswp->max_frame_size = vswp->mtu + sizeof (struct ether_header) + in vsw_get_initial_md_properties()
1786 vsw_vlan_read_ids(vswp, VSW_LOCALDEV, mdp, node, &vswp->pvid, in vsw_get_initial_md_properties()
1787 &vswp->vids, &vswp->nvids, &vswp->default_vlan_id); in vsw_get_initial_md_properties()
1790 vsw_read_pri_eth_types(vswp, mdp, node); in vsw_get_initial_md_properties()
1793 vsw_bandwidth_read(vswp, mdp, node, &vswp->bandwidth); in vsw_get_initial_md_properties()
1795 D1(vswp, "%s: exit", __func__); in vsw_get_initial_md_properties()
1818 vsw_t *vswp; in vsw_vlan_read_ids() local
1833 vswp = (vsw_t *)arg; in vsw_vlan_read_ids()
1836 inst = vswp->instance; in vsw_vlan_read_ids()
1841 vswp = portp->p_vswp; in vsw_vlan_read_ids()
1853 DWARN(vswp, "%s: prop(%s) not found", __func__, in vsw_vlan_read_ids()
1859 D2(vswp, "%s: %s(%d): (%d)\n", __func__, in vsw_vlan_read_ids()
1866 DWARN(vswp, "%s: prop(%s) not found", __func__, pvid_propname); in vsw_vlan_read_ids()
1871 D2(vswp, "%s: %s(%d): (%d)\n", __func__, in vsw_vlan_read_ids()
1878 D2(vswp, "%s: prop(%s) not found", __func__, vid_propname); in vsw_vlan_read_ids()
1886 D2(vswp, "%s: %s(%d): ", __func__, vid_propname, inst); in vsw_vlan_read_ids()
1892 D2(vswp, " %d ", (*vidspp)[i].vl_vid); in vsw_vlan_read_ids()
1894 D2(vswp, "\n"); in vsw_vlan_read_ids()
1906 vsw_t *vswp; in vsw_port_read_bandwidth() local
1908 vswp = portp->p_vswp; in vsw_port_read_bandwidth()
1914 D3(vswp, "%s: prop(%s) not found\n", __func__, in vsw_port_read_bandwidth()
1918 D3(vswp, "%s: %s nodes found", __func__, port_maxbw_propname); in vsw_port_read_bandwidth()
1937 vsw_read_pri_eth_types(vsw_t *vswp, md_t *mdp, mde_cookie_t node) in vsw_read_pri_eth_types() argument
1957 D3(vswp, "%s: prop(%s) not found", __func__, in vsw_read_pri_eth_types()
1964 vswp->pri_num_types = 0; in vsw_read_pri_eth_types()
1975 vswp->pri_num_types = size; in vsw_read_pri_eth_types()
1976 vswp->pri_types = kmem_zalloc(size * sizeof (uint16_t), KM_SLEEP); in vsw_read_pri_eth_types()
1977 for (i = 0, types = vswp->pri_types; i < size; i++) { in vsw_read_pri_eth_types()
1982 &vswp->pri_tx_vmp); in vsw_read_pri_eth_types()
1986 vsw_mtu_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node, uint32_t *mtu) in vsw_mtu_read() argument
1994 inst = vswp->instance; in vsw_mtu_read()
1998 D3(vswp, "%s: prop(%s) not found", __func__, mtu_propname); in vsw_mtu_read()
2003 D2(vswp, "%s: %s(%d): (%d)\n", __func__, in vsw_mtu_read()
2015 vsw_mtu_update(vsw_t *vswp, uint32_t mtu) in vsw_mtu_update() argument
2019 WRITE_ENTER(&vswp->if_lockrw); in vsw_mtu_update()
2021 if (vswp->if_state & VSW_IF_UP) { in vsw_mtu_update()
2023 RW_EXIT(&vswp->if_lockrw); in vsw_mtu_update()
2026 " as the device is plumbed\n", vswp->instance); in vsw_mtu_update()
2031 D2(vswp, "%s: curr_mtu(%d) new_mtu(%d)\n", in vsw_mtu_update()
2032 __func__, vswp->mtu, mtu); in vsw_mtu_update()
2034 vswp->mtu = mtu; in vsw_mtu_update()
2035 vswp->max_frame_size = vswp->mtu + in vsw_mtu_update()
2038 rv = mac_maxsdu_update(vswp->if_mh, mtu); in vsw_mtu_update()
2042 " layer\n", vswp->instance); in vsw_mtu_update()
2045 RW_EXIT(&vswp->if_lockrw); in vsw_mtu_update()
2048 vsw_reset_ports(vswp); in vsw_mtu_update()
2056 vsw_linkprop_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node, in vsw_linkprop_read() argument
2067 D3(vswp, "%s: prop(%s) not found", __func__, linkpropname); in vsw_linkprop_read()
2072 D2(vswp, "%s: %s(%d): (%d)\n", __func__, linkpropname, in vsw_linkprop_read()
2073 vswp->instance, *pls); in vsw_linkprop_read()
2078 vsw_mac_link_update(vsw_t *vswp, link_state_t link_state) in vsw_mac_link_update() argument
2080 READ_ENTER(&vswp->if_lockrw); in vsw_mac_link_update()
2082 if (vswp->if_state & VSW_IF_REG) { in vsw_mac_link_update()
2083 mac_link_update(vswp->if_mh, link_state); in vsw_mac_link_update()
2086 RW_EXIT(&vswp->if_lockrw); in vsw_mac_link_update()
2090 vsw_physlink_state_update(vsw_t *vswp) in vsw_physlink_state_update() argument
2092 if (vswp->pls_update == B_TRUE) { in vsw_physlink_state_update()
2093 vsw_mac_link_update(vswp, vswp->phys_link_state); in vsw_physlink_state_update()
2095 vsw_physlink_update_ports(vswp); in vsw_physlink_state_update()
2099 vsw_bandwidth_read(vsw_t *vswp, md_t *mdp, mde_cookie_t node, uint64_t *bw) in vsw_bandwidth_read() argument
2108 D3(vswp, "%s: prop(%s) not found", __func__, in vsw_bandwidth_read()
2112 D3(vswp, "%s: %s(%d): (%ld)\n", __func__, in vsw_bandwidth_read()
2113 vsw_maxbw_propname, vswp->instance, *bw); in vsw_bandwidth_read()
2130 vsw_update_md_prop(vsw_t *vswp, md_t *mdp, mde_cookie_t node) in vsw_update_md_prop() argument
2156 D1(vswp, "%s: enter", __func__); in vsw_update_md_prop()
2161 if (vsw_get_md_physname(vswp, mdp, node, (char *)&physname) == 0) { in vsw_update_md_prop()
2172 vswp->instance, physname); in vsw_update_md_prop()
2176 if (strcmp(physname, vswp->physname)) { in vsw_update_md_prop()
2177 D2(vswp, "%s: device name changed from %s to %s", in vsw_update_md_prop()
2178 __func__, vswp->physname, physname); in vsw_update_md_prop()
2182 D2(vswp, "%s: device name unchanged at %s", in vsw_update_md_prop()
2183 __func__, vswp->physname); in vsw_update_md_prop()
2187 "device from updated MD.", vswp->instance); in vsw_update_md_prop()
2196 vswp->instance); in vsw_update_md_prop()
2200 READ_ENTER(&vswp->if_lockrw); in vsw_update_md_prop()
2202 if (vswp->if_addr.ether_addr_octet[i] in vsw_update_md_prop()
2204 D2(vswp, "%s: octet[%d] 0x%x != 0x%x", in vsw_update_md_prop()
2206 vswp->if_addr.ether_addr_octet[i], in vsw_update_md_prop()
2214 RW_EXIT(&vswp->if_lockrw); in vsw_update_md_prop()
2216 vsw_save_lmacaddr(vswp, macaddr); in vsw_update_md_prop()
2223 if (vsw_get_md_smodes(vswp, mdp, node, &new_smode)) { in vsw_update_md_prop()
2225 vswp->instance, smode_propname); in vsw_update_md_prop()
2228 if (new_smode != vswp->smode) { in vsw_update_md_prop()
2229 D2(vswp, "%s: switching mode changed from %d to %d", in vsw_update_md_prop()
2230 __func__, vswp->smode, new_smode); in vsw_update_md_prop()
2237 vsw_vlan_read_ids(vswp, VSW_LOCALDEV, mdp, node, &pvid, &vids, in vsw_update_md_prop()
2241 if ((pvid != vswp->pvid) || /* pvid changed? */ in vsw_update_md_prop()
2242 (nvids != vswp->nvids) || /* # of vids changed? */ in vsw_update_md_prop()
2243 ((nvids != 0) && (vswp->nvids != 0) && /* vids changed? */ in vsw_update_md_prop()
2244 !vsw_cmp_vids(vids, vswp->vids, nvids))) { in vsw_update_md_prop()
2249 vsw_mtu_read(vswp, mdp, node, &mtu); in vsw_update_md_prop()
2250 if (mtu != vswp->mtu) { in vsw_update_md_prop()
2256 vswp->instance, mtu); in vsw_update_md_prop()
2263 vsw_linkprop_read(vswp, mdp, node, &pls_update); in vsw_update_md_prop()
2264 if (pls_update != vswp->pls_update) { in vsw_update_md_prop()
2269 vsw_bandwidth_read(vswp, mdp, node, &maxbw); in vsw_update_md_prop()
2270 if (maxbw != vswp->bandwidth) { in vsw_update_md_prop()
2276 vswp->instance, maxbw); in vsw_update_md_prop()
2286 vswp->pls_update = pls_update; in vsw_update_md_prop()
2294 if (vswp->phys_link_state == LINK_STATE_DOWN) { in vsw_update_md_prop()
2295 vsw_mac_link_update(vswp, LINK_STATE_UP); in vsw_update_md_prop()
2302 if (vswp->smode & VSW_LAYER2) { in vsw_update_md_prop()
2303 vsw_mac_link_update(vswp, in vsw_update_md_prop()
2304 vswp->phys_link_state); in vsw_update_md_prop()
2315 vsw_setup_switching_stop(vswp); in vsw_update_md_prop()
2318 vsw_hio_cleanup(vswp); in vsw_update_md_prop()
2325 vsw_unset_addrs(vswp); in vsw_update_md_prop()
2330 mutex_enter(&vswp->mac_lock); in vsw_update_md_prop()
2331 vsw_mac_close(vswp); in vsw_update_md_prop()
2332 mutex_exit(&vswp->mac_lock); in vsw_update_md_prop()
2339 vswp->instance, vswp->physname, physname); in vsw_update_md_prop()
2340 (void) strncpy(vswp->physname, in vsw_update_md_prop()
2348 vswp->smode = new_smode; in vsw_update_md_prop()
2353 rv = vsw_mtu_update(vswp, mtu); in vsw_update_md_prop()
2362 rv = vsw_setup_switching(vswp); in vsw_update_md_prop()
2371 if (vsw_setup_switching_start(vswp) != 0) { in vsw_update_md_prop()
2380 vsw_setup_switching_post_process(vswp); in vsw_update_md_prop()
2389 vswp->instance, macaddr); in vsw_update_md_prop()
2391 READ_ENTER(&vswp->if_lockrw); in vsw_update_md_prop()
2392 if (vswp->if_state & VSW_IF_UP) { in vsw_update_md_prop()
2394 vsw_if_mac_reconfig(vswp, B_FALSE, 0, NULL, 0); in vsw_update_md_prop()
2399 mac_unicst_update(vswp->if_mh, in vsw_update_md_prop()
2400 (uint8_t *)&vswp->if_addr); in vsw_update_md_prop()
2403 RW_EXIT(&vswp->if_lockrw); in vsw_update_md_prop()
2409 vsw_vlan_remove_ids(vswp, VSW_LOCALDEV); in vsw_update_md_prop()
2411 if (vswp->if_state & VSW_IF_UP) { in vsw_update_md_prop()
2412 vsw_if_mac_reconfig(vswp, B_TRUE, pvid, vids, nvids); in vsw_update_md_prop()
2414 if (vswp->nvids != 0) { in vsw_update_md_prop()
2415 kmem_free(vswp->vids, in vsw_update_md_prop()
2416 sizeof (vsw_vlanid_t) * vswp->nvids); in vsw_update_md_prop()
2418 vswp->vids = vids; in vsw_update_md_prop()
2419 vswp->nvids = nvids; in vsw_update_md_prop()
2420 vswp->pvid = pvid; in vsw_update_md_prop()
2424 vsw_vlan_add_ids(vswp, VSW_LOCALDEV); in vsw_update_md_prop()
2432 vsw_update_bandwidth(vswp, NULL, VSW_LOCALDEV, maxbw); in vsw_update_md_prop()
2438 cmn_err(CE_WARN, "!vsw%d: configuration unchanged", vswp->instance); in vsw_update_md_prop()
2443 vswp->instance); in vsw_update_md_prop()
2450 vsw_port_read_props(vsw_port_t *portp, vsw_t *vswp, in vsw_port_read_props() argument
2465 DWARN(vswp, "%s: prop(%s) not found", __func__, in vsw_port_read_props()
2475 DERR(vswp, "%s: invalid number of nodes found (%d)", in vsw_port_read_props()
2480 D2(vswp, "%s: %d nodes found", __func__, num_nodes); in vsw_port_read_props()
2490 DWARN(vswp, "%s: no %s nodes found", __func__, chan_propname); in vsw_port_read_props()
2495 D2(vswp, "%s: %d %s nodes found", __func__, nchan, chan_propname); in vsw_port_read_props()
2499 DWARN(vswp, "%s: prop(%s) not found\n", __func__, in vsw_port_read_props()
2508 D2(vswp, "%s: ldc_id 0x%llx", __func__, ldc_id); in vsw_port_read_props()
2513 DWARN(vswp, "%s: prop(%s) not found", in vsw_port_read_props()
2519 DWARN(vswp, "%s: invalid address size", __func__); in vsw_port_read_props()
2524 D2(vswp, "%s: remote mac address 0x%llx", __func__, macaddr); in vsw_port_read_props()
2532 portp->p_vswp = vswp; in vsw_port_read_props()
2537 D2(vswp, "%s: using first of %d ldc ids", in vsw_port_read_props()
2552 D1(vswp, "%s: prop(%s) found\n", __func__, hybrid_propname); in vsw_port_read_props()
2575 vsw_port_add(vsw_t *vswp, md_t *mdp, mde_cookie_t *node) in vsw_port_add() argument
2582 rv = vsw_port_read_props(portp, vswp, mdp, node); in vsw_port_add()
2590 DERR(vswp, "%s: failed to attach port", __func__); in vsw_port_add()
2598 vsw_port_update(vsw_t *vswp, md_t *curr_mdp, mde_cookie_t curr_mdex, in vsw_port_update() argument
2632 plistp = &(vswp->plist); in vsw_port_update()
2636 portp = vsw_lookup_port(vswp, cport_num); in vsw_port_update()
2656 D1(vswp, "%s: prop(%s) found\n", __func__, hybrid_propname); in vsw_port_update()
2673 vswp->instance, portp->p_instance, maxbw); in vsw_port_update()
2714 vsw_mac_rx(vsw_t *vswp, mac_resource_handle_t mrh, in vsw_mac_rx() argument
2719 D1(vswp, "%s:enter\n", __func__); in vsw_mac_rx()
2720 READ_ENTER(&vswp->if_lockrw); in vsw_mac_rx()
2722 if (!(vswp->if_state & VSW_IF_UP)) { in vsw_mac_rx()
2723 RW_EXIT(&vswp->if_lockrw); in vsw_mac_rx()
2728 D1(vswp, "%s:exit\n", __func__); in vsw_mac_rx()
2737 if (!(vswp->if_state & VSW_IF_PROMISC)) { in vsw_mac_rx()
2738 RW_EXIT(&vswp->if_lockrw); in vsw_mac_rx()
2743 D1(vswp, "%s:exit\n", __func__); in vsw_mac_rx()
2747 RW_EXIT(&vswp->if_lockrw); in vsw_mac_rx()
2755 D1(vswp, "%s:exit\n", __func__); in vsw_mac_rx()
2760 D2(vswp, "%s: sending up stack", __func__); in vsw_mac_rx()
2763 (void) vsw_vlan_frame_untag(vswp, VSW_LOCALDEV, &mp, &mpt); in vsw_mac_rx()
2765 mac_rx(vswp->if_mh, mrh, mp); in vsw_mac_rx()
2767 D1(vswp, "%s:exit\n", __func__); in vsw_mac_rx()
2772 vsw_save_lmacaddr(vsw_t *vswp, uint64_t macaddr) in vsw_save_lmacaddr() argument
2776 WRITE_ENTER(&vswp->if_lockrw); in vsw_save_lmacaddr()
2778 vswp->if_addr.ether_addr_octet[i] = macaddr & 0xFF; in vsw_save_lmacaddr()
2781 RW_EXIT(&vswp->if_lockrw); in vsw_save_lmacaddr()