Lines Matching refs:portp

89 static int vgen_force_link_state(vgen_port_t *portp, int link_state);
102 static void vgen_port_detach(vgen_port_t *portp);
103 static void vgen_port_list_insert(vgen_port_t *portp);
104 static void vgen_port_list_remove(vgen_port_t *portp);
112 static int vgen_port_read_props(vgen_port_t *portp, vgen_t *vgenp, md_t *mdp,
115 static int vgen_port_attach(vgen_port_t *portp);
116 static void vgen_port_detach_mdeg(vgen_port_t *portp);
119 static uint64_t vgen_port_stat(vgen_port_t *portp, uint_t stat);
120 static void vgen_port_reset(vgen_port_t *portp);
124 static int vgen_ldc_attach(vgen_port_t *portp, uint64_t ldc_id);
126 static void vgen_port_init(vgen_port_t *portp);
127 static void vgen_port_uninit(vgen_port_t *portp);
133 static int vgen_portsend(vgen_port_t *portp, mblk_t *mp);
190 static void vgen_vlan_create_hash(vgen_port_t *portp);
191 static void vgen_vlan_destroy_hash(vgen_port_t *portp);
192 static void vgen_vlan_add_ids(vgen_port_t *portp);
193 static void vgen_vlan_remove_ids(vgen_port_t *portp);
197 static mblk_t *vgen_vlan_frame_fixtag(vgen_port_t *portp, mblk_t *mp,
199 static void vgen_vlan_unaware_port_reset(vgen_port_t *portp);
631 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_start() local
632 vgen_t *vgenp = portp->vgenp; in vgen_start()
635 mutex_enter(&portp->lock); in vgen_start()
636 vgen_port_init(portp); in vgen_start()
637 portp->flags |= VGEN_STARTED; in vgen_start()
638 mutex_exit(&portp->lock); in vgen_start()
648 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_stop() local
649 vgen_t *vgenp = portp->vgenp; in vgen_stop()
653 mutex_enter(&portp->lock); in vgen_stop()
654 if (portp->flags & VGEN_STARTED) { in vgen_stop()
655 vgen_port_uninit(portp); in vgen_stop()
656 portp->flags &= ~(VGEN_STARTED); in vgen_stop()
658 mutex_exit(&portp->lock); in vgen_stop()
667 vgen_port_t *portp; in vgen_tx() local
670 portp = (vgen_port_t *)arg; in vgen_tx()
671 status = vgen_portsend(portp, mp); in vgen_tx()
699 vgen_vlan_frame_fixtag(vgen_port_t *portp, mblk_t *mp, boolean_t is_tagged, in vgen_vlan_frame_fixtag() argument
706 vgenp = portp->vgenp; in vgen_vlan_frame_fixtag()
732 if (portp != vgenp->vsw_portp) { in vgen_vlan_frame_fixtag()
738 rv = vgen_vlan_lookup(portp->vlan_hashp, vid); in vgen_vlan_frame_fixtag()
746 (vid == portp->pvid) ? (dst_tagged = B_FALSE) : in vgen_vlan_frame_fixtag()
779 vgen_portsend(vgen_port_t *portp, mblk_t *mp) in vgen_portsend() argument
784 vgen_t *vgenp = portp->vgenp; in vgen_portsend()
791 if (portp == NULL) { in vgen_portsend()
795 if (portp->use_vsw_port) { in vgen_portsend()
797 portp = portp->vgenp->vsw_portp; in vgen_portsend()
798 ASSERT(portp != NULL); in vgen_portsend()
819 if (portp != vgenp->vsw_portp && in vgen_portsend()
820 portp->pvid != vnetp->default_vlan_id) { in vgen_portsend()
827 mp = vgen_vlan_frame_fixtag(portp, mp, is_tagged, vlan_id); in vgen_portsend()
834 ldcp = portp->ldcp; in vgen_portsend()
996 vgen_port_t *portp; in vgen_multicst() local
1002 portp = (vgen_port_t *)arg; in vgen_multicst()
1003 vgenp = portp->vgenp; in vgen_multicst()
1005 if (portp->is_vsw_port != B_TRUE) { in vgen_multicst()
1013 ldcp = portp->ldcp; in vgen_multicst()
1118 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_stat() local
1120 *val = vgen_port_stat(portp, stat); in vgen_stat()
1129 vgen_port_t *portp; in vgen_detach_ports() local
1134 while ((portp = plistp->headp) != NULL) { in vgen_detach_ports()
1135 vgen_port_detach(portp); in vgen_detach_ports()
1144 vgen_port_detach(vgen_port_t *portp) in vgen_port_detach() argument
1149 vgenp = portp->vgenp; in vgen_port_detach()
1150 port_num = portp->port_num; in vgen_port_detach()
1164 if (vgenp->vsw_portp == portp) { in vgen_port_detach()
1172 if (portp->vhp != NULL) { in vgen_port_detach()
1173 vio_net_resource_unreg(portp->vhp); in vgen_port_detach()
1174 portp->vhp = NULL; in vgen_port_detach()
1177 vgen_vlan_destroy_hash(portp); in vgen_port_detach()
1180 vgen_port_list_remove(portp); in vgen_port_detach()
1183 vgen_ldc_detach(portp->ldcp); in vgen_port_detach()
1185 if (portp->num_ldcs != 0) { in vgen_port_detach()
1186 kmem_free(portp->ldc_ids, portp->num_ldcs * sizeof (uint64_t)); in vgen_port_detach()
1187 portp->num_ldcs = 0; in vgen_port_detach()
1190 mutex_destroy(&portp->lock); in vgen_port_detach()
1191 KMEM_FREE(portp); in vgen_port_detach()
1198 vgen_port_list_insert(vgen_port_t *portp) in vgen_port_list_insert() argument
1203 vgenp = portp->vgenp; in vgen_port_list_insert()
1207 plistp->headp = portp; in vgen_port_list_insert()
1209 plistp->tailp->nextp = portp; in vgen_port_list_insert()
1211 plistp->tailp = portp; in vgen_port_list_insert()
1212 portp->nextp = NULL; in vgen_port_list_insert()
1217 vgen_port_list_remove(vgen_port_t *portp) in vgen_port_list_remove() argument
1224 vgenp = portp->vgenp; in vgen_port_list_remove()
1231 if (portp == plistp->headp) { in vgen_port_list_remove()
1232 plistp->headp = portp->nextp; in vgen_port_list_remove()
1233 if (portp == plistp->tailp) in vgen_port_list_remove()
1237 ((nextp = prevp->nextp) != NULL) && (nextp != portp); in vgen_port_list_remove()
1240 if (nextp == portp) { in vgen_port_list_remove()
1241 prevp->nextp = portp->nextp; in vgen_port_list_remove()
1243 if (portp == plistp->tailp) in vgen_port_list_remove()
1252 vgen_port_t *portp = NULL; in vgen_port_lookup() local
1254 for (portp = plistp->headp; portp != NULL; portp = portp->nextp) { in vgen_port_lookup()
1255 if (portp->port_num == port_num) { in vgen_port_lookup()
1260 return (portp); in vgen_port_lookup()
1264 vgen_port_init(vgen_port_t *portp) in vgen_port_init() argument
1267 vgen_vlan_add_ids(portp); in vgen_port_init()
1270 (void) vgen_ldc_init(portp->ldcp); in vgen_port_init()
1274 vgen_port_uninit(vgen_port_t *portp) in vgen_port_uninit() argument
1276 vgen_ldc_uninit(portp->ldcp); in vgen_port_uninit()
1279 vgen_vlan_remove_ids(portp); in vgen_port_uninit()
1404 vgen_port_t *portp; in vgen_vlan_read_ids() local
1426 portp = (vgen_port_t *)arg; in vgen_vlan_read_ids()
1427 vgenp = portp->vgenp; in vgen_vlan_read_ids()
1431 inst = portp->port_num; in vgen_vlan_read_ids()
1490 vgen_vlan_create_hash(vgen_port_t *portp) in vgen_vlan_create_hash() argument
1495 portp->port_num); in vgen_vlan_create_hash()
1497 portp->vlan_nchains = vgen_vlan_nchains; in vgen_vlan_create_hash()
1498 portp->vlan_hashp = mod_hash_create_idhash(hashname, in vgen_vlan_create_hash()
1499 portp->vlan_nchains, mod_hash_null_valdtor); in vgen_vlan_create_hash()
1506 vgen_vlan_destroy_hash(vgen_port_t *portp) in vgen_vlan_destroy_hash() argument
1508 if (portp->vlan_hashp != NULL) { in vgen_vlan_destroy_hash()
1509 mod_hash_destroy_hash(portp->vlan_hashp); in vgen_vlan_destroy_hash()
1510 portp->vlan_hashp = NULL; in vgen_vlan_destroy_hash()
1511 portp->vlan_nchains = 0; in vgen_vlan_destroy_hash()
1519 vgen_vlan_add_ids(vgen_port_t *portp) in vgen_vlan_add_ids() argument
1524 rv = mod_hash_insert(portp->vlan_hashp, in vgen_vlan_add_ids()
1525 (mod_hash_key_t)VLAN_ID_KEY(portp->pvid), in vgen_vlan_add_ids()
1529 for (i = 0; i < portp->nvids; i++) { in vgen_vlan_add_ids()
1530 rv = mod_hash_insert(portp->vlan_hashp, in vgen_vlan_add_ids()
1531 (mod_hash_key_t)VLAN_ID_KEY(portp->vids[i]), in vgen_vlan_add_ids()
1541 vgen_vlan_remove_ids(vgen_port_t *portp) in vgen_vlan_remove_ids() argument
1547 rv = mod_hash_remove(portp->vlan_hashp, in vgen_vlan_remove_ids()
1548 (mod_hash_key_t)VLAN_ID_KEY(portp->pvid), in vgen_vlan_remove_ids()
1552 for (i = 0; i < portp->nvids; i++) { in vgen_vlan_remove_ids()
1553 rv = mod_hash_remove(portp->vlan_hashp, in vgen_vlan_remove_ids()
1554 (mod_hash_key_t)VLAN_ID_KEY(portp->vids[i]), in vgen_vlan_remove_ids()
2089 vgen_port_t *portp; in vgen_add_port() local
2092 portp = kmem_zalloc(sizeof (vgen_port_t), KM_SLEEP); in vgen_add_port()
2094 rv = vgen_port_read_props(portp, vgenp, mdp, mdex); in vgen_add_port()
2096 KMEM_FREE(portp); in vgen_add_port()
2100 rv = vgen_port_attach(portp); in vgen_add_port()
2110 vgen_port_read_props(vgen_port_t *portp, vgen_t *vgenp, md_t *mdp, in vgen_port_read_props() argument
2207 portp->is_vsw_port = B_TRUE; in vgen_port_read_props()
2209 portp->is_vsw_port = B_FALSE; in vgen_port_read_props()
2214 portp->vgenp = vgenp; in vgen_port_read_props()
2215 portp->port_num = port_num; in vgen_port_read_props()
2216 ether_copy(&ea, &portp->macaddr); in vgen_port_read_props()
2217 portp->ldc_ids = kmem_zalloc(sizeof (uint64_t) * num_ldcs, KM_SLEEP); in vgen_port_read_props()
2218 bcopy(ldc_ids, portp->ldc_ids, sizeof (uint64_t) * num_ldcs); in vgen_port_read_props()
2219 portp->num_ldcs = num_ldcs; in vgen_port_read_props()
2222 vgen_vlan_read_ids(portp, VGEN_PEER, mdp, mdex, &portp->pvid, in vgen_port_read_props()
2223 &portp->vids, &portp->nvids, NULL); in vgen_port_read_props()
2235 vgen_port_t *portp; in vgen_remove_port() local
2247 portp = vgen_port_lookup(plistp, (int)port_num); in vgen_remove_port()
2248 if (portp == NULL) { in vgen_remove_port()
2254 vgen_port_detach_mdeg(portp); in vgen_remove_port()
2262 vgen_port_attach(vgen_port_t *portp) in vgen_port_attach() argument
2271 ASSERT(portp != NULL); in vgen_port_attach()
2272 vgenp = portp->vgenp; in vgen_port_attach()
2273 ldcids = portp->ldc_ids; in vgen_port_attach()
2276 portp->port_num, ldcids[0]); in vgen_port_attach()
2278 mutex_init(&portp->lock, NULL, MUTEX_DRIVER, NULL); in vgen_port_attach()
2284 if (vgen_ldc_attach(portp, ldcids[0]) == DDI_FAILURE) { in vgen_port_attach()
2285 vgen_port_detach(portp); in vgen_port_attach()
2290 vgen_vlan_create_hash(portp); in vgen_port_attach()
2292 if (portp->is_vsw_port == B_TRUE) { in vgen_port_attach()
2294 (void) atomic_swap_32(&portp->use_vsw_port, B_FALSE); in vgen_port_attach()
2297 (void) atomic_swap_32(&portp->use_vsw_port, B_TRUE); in vgen_port_attach()
2302 vgen_port_detach(portp); in vgen_port_attach()
2306 macp->m_driver = portp; in vgen_port_attach()
2313 mutex_enter(&portp->lock); in vgen_port_attach()
2315 portp->macaddr, &portp->vhp, &portp->vcb); in vgen_port_attach()
2316 mutex_exit(&portp->lock); in vgen_port_attach()
2323 vgen_port_list_insert(portp); in vgen_port_attach()
2326 if (portp->is_vsw_port == B_TRUE) { in vgen_port_attach()
2328 vgenp->vsw_portp = portp; in vgen_port_attach()
2333 portp); in vgen_port_attach()
2334 vgen_port_detach(portp); in vgen_port_attach()
2337 DBG1(vgenp, NULL, "exit: port_num(%d)\n", portp->port_num); in vgen_port_attach()
2343 vgen_port_detach_mdeg(vgen_port_t *portp) in vgen_port_detach_mdeg() argument
2345 vgen_t *vgenp = portp->vgenp; in vgen_port_detach_mdeg()
2347 DBG1(vgenp, NULL, "enter: port_num(%d)\n", portp->port_num); in vgen_port_detach_mdeg()
2349 mutex_enter(&portp->lock); in vgen_port_detach_mdeg()
2352 if (portp->flags & VGEN_STARTED) { in vgen_port_detach_mdeg()
2353 vgen_port_uninit(portp); in vgen_port_detach_mdeg()
2354 portp->flags &= ~(VGEN_STARTED); in vgen_port_detach_mdeg()
2357 mutex_exit(&portp->lock); in vgen_port_detach_mdeg()
2358 vgen_port_detach(portp); in vgen_port_detach_mdeg()
2360 DBG1(vgenp, NULL, "exit: port_num(%d)\n", portp->port_num); in vgen_port_detach_mdeg()
2370 vgen_port_t *portp; in vgen_update_port() local
2396 portp = vgen_port_lookup(plistp, (int)cport_num); in vgen_update_port()
2397 if (portp == NULL) { in vgen_update_port()
2404 vgen_vlan_read_ids(portp, VGEN_PEER, curr_mdp, curr_mdex, &pvid, &vids, in vgen_update_port()
2408 if ((pvid != portp->pvid) || /* pvid changed? */ in vgen_update_port()
2409 (nvids != portp->nvids) || /* # of vids changed? */ in vgen_update_port()
2410 ((nvids != 0) && (portp->nvids != 0) && /* vids changed? */ in vgen_update_port()
2411 bcmp(vids, portp->vids, sizeof (uint16_t) * nvids))) { in vgen_update_port()
2421 vgen_vlan_remove_ids(portp); in vgen_update_port()
2424 portp->pvid = pvid; in vgen_update_port()
2425 if (portp->nvids != 0) { in vgen_update_port()
2426 kmem_free(portp->vids, sizeof (uint16_t) * portp->nvids); in vgen_update_port()
2427 portp->nvids = 0; in vgen_update_port()
2430 portp->vids = kmem_zalloc(sizeof (uint16_t) * nvids, KM_SLEEP); in vgen_update_port()
2431 bcopy(vids, portp->vids, sizeof (uint16_t) * nvids); in vgen_update_port()
2432 portp->nvids = nvids; in vgen_update_port()
2437 vgen_vlan_add_ids(portp); in vgen_update_port()
2440 vgen_vlan_unaware_port_reset(portp); in vgen_update_port()
2448 vgen_port_stat(vgen_port_t *portp, uint_t stat) in vgen_port_stat() argument
2450 return (vgen_ldc_stat(portp->ldcp, stat)); in vgen_port_stat()
2455 vgen_ldc_attach(vgen_port_t *portp, uint64_t ldc_id) in vgen_ldc_attach() argument
2469 vgenp = portp->vgenp; in vgen_ldc_attach()
2476 ldcp->portp = portp; in vgen_ldc_attach()
2533 portp->ldcp = ldcp; in vgen_ldc_attach()
2569 vgen_port_t *portp; in vgen_ldc_detach() local
2574 portp = ldcp->portp; in vgen_ldc_detach()
2575 vgenp = portp->vgenp; in vgen_ldc_detach()
2659 if (ldcp->portp != vgenp->vsw_portp) { in vgen_ldc_init()
2664 &ldcp->portp->use_vsw_port, B_FALSE); in vgen_ldc_init()
2947 if (ldcp->portp != vgenp->vsw_portp) { in vgen_handle_evt_up()
2951 (void) atomic_swap_32(&ldcp->portp->use_vsw_port, B_FALSE); in vgen_handle_evt_up()
3671 vgen_port_t *portp = ldcp->portp; in vgen_set_vnet_proto_ops() local
3679 if (portp == vgenp->vsw_portp && vnetp->pls_update == B_TRUE) { in vgen_set_vnet_proto_ops()
3699 vgen_port_t *portp = ldcp->portp; in vgen_set_vnet_proto_ops() local
3710 if (portp->nvids == 0 && portp->pvid == vnetp->pvid) { in vgen_set_vnet_proto_ops()
3766 vgen_vlan_unaware_port_reset(vgen_port_t *portp) in vgen_vlan_unaware_port_reset() argument
3768 vgen_ldc_t *ldcp = portp->ldcp; in vgen_vlan_unaware_port_reset()
3769 vgen_t *vgenp = portp->vgenp; in vgen_vlan_unaware_port_reset()
3780 (portp->nvids != 0 || portp->pvid != vnetp->pvid)) { in vgen_vlan_unaware_port_reset()
3791 vgen_port_reset(vgen_port_t *portp) in vgen_port_reset() argument
3793 (void) vgen_ldc_reset(portp->ldcp, VGEN_OTHER); in vgen_port_reset()
3799 vgen_port_t *portp; in vgen_reset_vlan_unaware_ports() local
3805 for (portp = plistp->headp; portp != NULL; portp = portp->nextp) { in vgen_reset_vlan_unaware_ports()
3807 vgen_vlan_unaware_port_reset(portp); in vgen_reset_vlan_unaware_ports()
3817 vgen_port_t *portp; in vgen_reset_vsw_port() local
3819 if ((portp = vgenp->vsw_portp) != NULL) { in vgen_reset_vsw_port()
3820 vgen_port_reset(portp); in vgen_reset_vsw_port()
3886 vgen_port_t *portp = ldcp->portp; in vgen_process_reset() local
3896 if (portp == vgenp->vsw_portp) { /* vswitch port ? */ in vgen_process_reset()
3906 vio_net_report_err_t rep_err = portp->vcb.vio_net_report_err; in vgen_process_reset()
3907 rep_err(portp->vhp, VIO_NET_RES_DOWN); in vgen_process_reset()
3979 (void) atomic_swap_32(&portp->use_vsw_port, B_TRUE); in vgen_process_reset()
4031 (void) atomic_swap_32(&portp->use_vsw_port, in vgen_process_reset()
4155 if (ldcp->portp == vgenp->vsw_portp) { in vgen_handshake()
4201 ldcp->portp->vcb.vio_net_tx_update; in vgen_handshake()
4204 vtx_update(ldcp->portp->vhp); in vgen_handshake()
4750 ldcp->portp == vgenp->vsw_portp) { in vgen_handle_attr_ack()
5186 if (ldcp->portp != vgenp->vsw_portp) { in vgen_handle_physlink_info()
5386 vrx_cb = ldcp->portp->vcb.vio_net_rx_cb; in vgen_handle_pkt_data()
5396 vrx_cb(ldcp->portp->vhp, mp); in vgen_handle_pkt_data()
5521 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_enable_intr() local
5522 vgen_ldc_t *ldcp = portp->ldcp; in vgen_enable_intr()
5553 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_disable_intr() local
5554 vgen_ldc_t *ldcp = portp->ldcp; in vgen_disable_intr()
5573 vgen_port_t *portp = (vgen_port_t *)arg; in vgen_rx_poll() local
5574 vgen_ldc_t *ldcp = portp->ldcp; in vgen_rx_poll()
5650 ldcp->portp->vcb.vio_net_tx_update; in vgen_tx_watchdog()
5653 vtx_update(ldcp->portp->vhp); in vgen_tx_watchdog()
5820 vgen_port_t *portp; in vgen_ioctl() local
5829 portp = (vgen_port_t *)arg; in vgen_ioctl()
5831 if (portp == NULL) { in vgen_ioctl()
5836 mutex_enter(&portp->lock); in vgen_ioctl()
5842 rv = vgen_force_link_state(portp, iocp->ioc_cmd); in vgen_ioctl()
5852 mutex_exit(&portp->lock); in vgen_ioctl()
5870 vgen_force_link_state(vgen_port_t *portp, int cmd) in vgen_force_link_state() argument
5874 vgen_ldc_t *ldcp = portp->ldcp; in vgen_force_link_state()
5875 vgen_t *vgenp = portp->vgenp; in vgen_force_link_state()
5914 vgen_port_t *portp; in vgen_ioctl() local
5916 portp = (vgen_port_t *)arg; in vgen_ioctl()
5918 if (portp == NULL) { in vgen_ioctl()