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