Lines Matching refs:vswp

74 int vsw_setup_switching_start(vsw_t *vswp);
75 void vsw_setup_switching_stop(vsw_t *vswp);
77 void vsw_setup_switching_post_process(vsw_t *vswp);
78 void vsw_switch_frame_nop(vsw_t *vswp, mblk_t *mp, int caller,
84 static void vsw_switch_l2_frame_mac_client(vsw_t *vswp, mblk_t *mp, int caller,
86 static void vsw_switch_l2_frame(vsw_t *vswp, mblk_t *mp, int caller,
88 static void vsw_switch_l3_frame(vsw_t *vswp, mblk_t *mp, int caller,
90 static int vsw_forward_all(vsw_t *vswp, mblk_t *mp,
92 static int vsw_forward_grp(vsw_t *vswp, mblk_t *mp,
109 void vsw_fdbe_add(vsw_t *vswp, void *port);
110 void vsw_fdbe_del(vsw_t *vswp, struct ether_addr *eaddr);
111 static vsw_fdbe_t *vsw_fdbe_find(vsw_t *vswp, struct ether_addr *);
129 extern int vsw_mac_open(vsw_t *vswp);
130 extern void vsw_mac_close(vsw_t *vswp);
131 extern void vsw_mac_rx(vsw_t *vswp, mac_resource_handle_t mrh,
133 extern void vsw_set_addrs(vsw_t *vswp);
135 extern void vsw_hio_init(vsw_t *vswp);
136 extern void vsw_hio_start_ports(vsw_t *vswp);
137 extern int vsw_mac_multicast_add(vsw_t *vswp, vsw_port_t *port,
139 extern void vsw_mac_multicast_remove(vsw_t *vswp, vsw_port_t *port,
141 extern void vsw_mac_link_update(vsw_t *vswp, link_state_t link_state);
142 extern void vsw_physlink_update_ports(vsw_t *vswp);
175 vsw_t *vswp = (vsw_t *)arg;
184 CALLB_CPR_INIT(&cprinfo, &vswp->sw_thr_lock, callb_generic_cpr,
187 mutex_enter(&vswp->sw_thr_lock);
189 while ((vswp->sw_thr_flags & VSW_SWTHR_STOP) == 0) {
195 while ((vswp->sw_thr_flags & VSW_SWTHR_STOP) == 0) {
196 wait_rv = cv_timedwait(&vswp->sw_thr_cv,
197 &vswp->sw_thr_lock, wait_time);
203 CALLB_CPR_SAFE_END(&cprinfo, &vswp->sw_thr_lock)
205 if ((vswp->sw_thr_flags & VSW_SWTHR_STOP) != 0) {
214 mutex_exit(&vswp->sw_thr_lock);
215 rv = vsw_setup_switching(vswp);
217 vsw_setup_switching_post_process(vswp);
219 mutex_enter(&vswp->sw_thr_lock);
226 vswp->sw_thr_flags &= ~VSW_SWTHR_STOP;
227 vswp->sw_thread = NULL;
237 vsw_setup_switching_start(vsw_t *vswp)
239 mutex_enter(&vswp->sw_thr_lock);
241 vswp->sw_thread = thread_create(NULL, 2 * DEFAULTSTKSZ,
242 vsw_setup_switching_thread, vswp, 0, &p0, TS_RUN, minclsyspri);
244 if (vswp->sw_thread == NULL) {
245 mutex_exit(&vswp->sw_thr_lock);
249 mutex_exit(&vswp->sw_thr_lock);
257 vsw_setup_switching_stop(vsw_t *vswp)
264 mutex_enter(&vswp->sw_thr_lock);
266 if (vswp->sw_thread != NULL) {
267 tid = vswp->sw_thread->t_did;
268 vswp->sw_thr_flags |= VSW_SWTHR_STOP;
269 cv_signal(&vswp->sw_thr_cv);
272 mutex_exit(&vswp->sw_thr_lock);
277 (void) atomic_swap_32(&vswp->switching_setup_done, B_FALSE);
279 vswp->mac_open_retries = 0;
290 vsw_setup_switching(vsw_t *vswp)
294 D1(vswp, "%s: enter", __func__);
304 if (vswp->smode & VSW_LAYER2) {
305 rv = vsw_setup_layer2(vswp);
306 } else if (vswp->smode & VSW_LAYER3) {
307 rv = vsw_setup_layer3(vswp);
309 DERR(vswp, "unknown switch mode");
315 "switching mode", vswp->instance);
317 (void) atomic_swap_32(&vswp->switching_setup_done, B_TRUE);
320 D2(vswp, "%s: Operating in mode %d", __func__,
321 vswp->smode);
323 D1(vswp, "%s: exit", __func__);
337 vsw_setup_layer2(vsw_t *vswp)
341 D1(vswp, "%s: enter", __func__);
347 vswp->vsw_switch_frame = vsw_switch_l2_frame;
348 vswp->mac_cl_switching = B_FALSE;
350 rv = strlen(vswp->physname);
357 vswp->instance);
361 mutex_enter(&vswp->mac_lock);
363 rv = vsw_mac_open(vswp);
367 "device: %s\n", vswp->instance, vswp->physname);
369 mutex_exit(&vswp->mac_lock);
378 vswp->vsw_switch_frame = vsw_switch_l2_frame_mac_client;
379 vswp->mac_cl_switching = B_TRUE;
381 D1(vswp, "%s: exit", __func__);
384 vsw_hio_init(vswp);
386 mutex_exit(&vswp->mac_lock);
390 vsw_mac_close(vswp);
391 mutex_exit(&vswp->mac_lock);
396 vsw_setup_layer3(vsw_t *vswp)
398 D1(vswp, "%s: enter", __func__);
400 D2(vswp, "%s: operating in layer 3 mode", __func__);
401 vswp->vsw_switch_frame = vsw_switch_l3_frame;
403 D1(vswp, "%s: exit", __func__);
410 vsw_switch_frame_nop(vsw_t *vswp, mblk_t *mp, int caller, vsw_port_t *port,
420 vsw_switch_l2_frame_mac_client(vsw_t *vswp, mblk_t *mp, int caller,
434 if ((ret_m = vsw_tx_msg(vswp, mp, caller, port)) != NULL) {
435 DERR(vswp, "%s: drop mblks to "
444 * vswp: pointer to the vsw instance
456 vsw_switch_l2_frame(vsw_t *vswp, mblk_t *mp, int caller,
463 D1(vswp, "%s: enter (caller %d)", __func__, caller);
478 D2(vswp, "%s: mblk data buffer %lld : actual data size %lld",
481 if (ether_cmp(&ehp->ether_dhost, &vswp->if_addr) == 0) {
489 vsw_mac_rx(vswp, mrh, mp, VSW_MACRX_FREEMSG);
500 fp = vsw_fdbe_find(vswp, &ehp->ether_dhost);
507 vsw_mac_rx(vswp, mrh, mp,
530 D2(vswp, "%s: BROADCAST pkt", __func__);
531 (void) vsw_forward_all(vswp, mp, caller, arg);
533 D2(vswp, "%s: MULTICAST pkt", __func__);
534 (void) vsw_forward_grp(vswp, mp, caller, arg);
553 vsw_mac_rx(vswp, mrh, mp,
557 if ((ret_m = vsw_tx_msg(vswp, mp,
559 DERR(vswp, "%s: drop mblks to "
570 vsw_mac_rx(vswp, mrh, mp,
579 if ((ret_m = vsw_tx_msg(vswp, mp,
581 DERR(vswp, "%s: drop mblks to "
589 D1(vswp, "%s: exit\n", __func__);
601 vsw_switch_l3_frame(vsw_t *vswp, mblk_t *mp, int caller,
608 D1(vswp, "%s: enter (caller %d)", __func__, caller);
616 DERR(vswp, "%s: unexpected caller (%d)", __func__, caller);
628 D2(vswp, "%s: mblk data buffer %lld : actual data size %lld",
635 fp = vsw_fdbe_find(vswp, &ehp->ether_dhost);
638 D2(vswp, "%s: sending to target port", __func__);
653 D2(vswp, "%s: BROADCAST pkt", __func__);
654 (void) vsw_forward_all(vswp, mp, caller, arg);
656 D2(vswp, "%s: MULTICAST pkt", __func__);
657 (void) vsw_forward_grp(vswp, mp, caller, arg);
666 vsw_mac_rx(vswp, mrh,
673 D1(vswp, "%s: exit", __func__);
680 vsw_setup_switching_post_process(vsw_t *vswp)
684 if (vswp->smode & VSW_LAYER2) {
689 vsw_set_addrs(vswp);
692 vsw_hio_start_ports(vswp);
694 if (vswp->pls_update == B_TRUE) {
695 link_state = vswp->phys_link_state;
699 vsw_physlink_update_ports(vswp);
702 vsw_mac_link_update(vswp, link_state);
710 vsw_forward_all(vsw_t *vswp, mblk_t *mp, int caller, vsw_port_t *arg)
712 vsw_port_list_t *plist = &vswp->plist;
718 D1(vswp, "vsw_forward_all: enter\n");
724 if ((vswp->smode & VSW_LAYER2) &&
729 if ((ret_m = vsw_tx_msg(vswp, nmp, caller, arg))
731 DERR(vswp, "%s: dropping pkt(s) "
747 vsw_mac_rx(vswp, NULL, mp, VSW_MACRX_COPYMSG);
753 D2(vswp, "vsw_forward_all: port %d", portp->p_instance);
771 DERR(vswp, "vsw_forward_all: nmp NULL");
779 D1(vswp, "vsw_forward_all: exit\n");
788 vsw_forward_grp(vsw_t *vswp, mblk_t *mp, int caller, vsw_port_t *arg)
804 D1(vswp, "%s: key 0x%llx", __func__, key);
812 if ((vswp->smode & VSW_LAYER2) &&
816 if ((ret_m = vsw_tx_msg(vswp, nmp, caller, arg))
818 DERR(vswp, "%s: dropping pkt(s) consisting of "
826 READ_ENTER(&vswp->mfdbrw);
827 if (mod_hash_find(vswp->mfdb, (mod_hash_key_t)key,
829 D3(vswp, "%s: no table entry found for addr 0x%llx",
841 D3(vswp, "%s: not sending to ourselves"
847 D2(vswp, "%s: not sending back up stack",
854 D3(vswp, "%s: sending to port %ld for addr "
860 * The vswp->mfdbrw is protecting the
867 vsw_mac_rx(vswp, NULL,
869 D2(vswp, "%s: sending up stack"
876 RW_EXIT(&vswp->mfdbrw);
886 vsw_mac_rx(vswp, NULL, mp,
892 D1(vswp, "%s: exit", __func__);
941 vsw_t *vswp = (vsw_t *)arg;
944 vswp->instance);
946 vswp->vlan_nchains = vsw_vlan_nchains;
947 vswp->vlan_hashp = mod_hash_create_idhash(hashname,
948 vswp->vlan_nchains, mod_hash_null_valdtor);
972 vsw_t *vswp = (vsw_t *)arg;
974 mod_hash_destroy_hash(vswp->vlan_hashp);
975 vswp->vlan_nchains = 0;
996 vsw_t *vswp = (vsw_t *)arg;
998 rv = mod_hash_insert(vswp->vlan_hashp,
999 (mod_hash_key_t)VLAN_ID_KEY(vswp->pvid),
1003 "the interface", vswp->instance, vswp->pvid);
1006 for (i = 0; i < vswp->nvids; i++) {
1007 rv = mod_hash_insert(vswp->vlan_hashp,
1008 (mod_hash_key_t)VLAN_ID_KEY(vswp->vids[i].vl_vid),
1012 " for the interface", vswp->instance,
1013 vswp->pvid);
1019 vsw_t *vswp = portp->p_vswp;
1026 "the port(%d)", vswp->instance, vswp->pvid,
1036 " for the port(%d)", vswp->instance,
1037 vswp->pvid, portp->p_instance);
1055 vsw_t *vswp = (vsw_t *)arg;
1057 rv = vsw_vlan_lookup(vswp->vlan_hashp, vswp->pvid);
1059 rv = mod_hash_remove(vswp->vlan_hashp,
1060 (mod_hash_key_t)VLAN_ID_KEY(vswp->pvid),
1065 for (i = 0; i < vswp->nvids; i++) {
1066 rv = vsw_vlan_lookup(vswp->vlan_hashp,
1067 vswp->vids[i].vl_vid);
1069 rv = mod_hash_remove(vswp->vlan_hashp,
1071 vswp->vids[i].vl_vid),
1128 vsw_fdbe_add(vsw_t *vswp, void *port)
1144 rv = mod_hash_insert(vswp->fdb_hashp, (mod_hash_key_t)addr,
1148 "the port(%d)", vswp->instance,
1158 vsw_fdbe_del(vsw_t *vswp, struct ether_addr *eaddr)
1170 rv = mod_hash_remove(vswp->fdb_hashp, (mod_hash_key_t)addr,
1193 vsw_fdbe_find(vsw_t *vswp, struct ether_addr *addrp)
1201 rv = mod_hash_find_cb(vswp->fdb_hashp, (mod_hash_key_t)key,
1243 vsw_t *vswp;
1255 vswp = (vsw_t *)arg;
1256 pvid = vswp->pvid;
1262 vswp = portp->p_vswp;
1278 if (pvid != vswp->default_vlan_id) {
1328 vsw_t *vswp;
1341 vswp = (vsw_t *)arg;
1342 pvid = vswp->pvid;
1343 vlan_hashp = vswp->vlan_hashp;
1348 vswp = portp->p_vswp;
1360 if ((vswp->mac_cl_switching == B_TRUE) &&
1361 (pvid == vswp->default_vlan_id)) {
1393 if (vswp->mac_cl_switching == B_TRUE) {
1417 if (vlan_id != vswp->default_vlan_id) {
1480 vsw_t *vswp;
1508 vswp = (vsw_t *)arg;
1509 *vidp = vswp->pvid;
1525 vsw_t *vswp = port->p_vswp;
1529 D1(vswp, "%s: enter", __func__);
1531 D2(vswp, "%s: %d addresses", __func__, mcst_pkt->count);
1544 D3(vswp, "%s: adding multicast address 0x%llx for "
1546 if (vsw_add_mcst(vswp, VSW_VNETPORT, addr, port) == 0) {
1556 DERR(vswp, "%s: unable to alloc mem",
1558 (void) vsw_del_mcst(vswp,
1573 if (vsw_mac_multicast_add(vswp, port, mcst_p,
1575 (void) vsw_del_mcst(vswp,
1587 DERR(vswp, "%s: error adding multicast "
1598 if (vsw_del_mcst(vswp, VSW_VNETPORT, addr, port) == 0) {
1599 D3(vswp, "%s: deleting multicast address "
1614 vsw_mac_multicast_remove(vswp, port, mcst_p,
1619 DERR(vswp, "%s: error deleting multicast "
1626 D1(vswp, "%s: exit", __func__);
1638 vsw_add_mcst(vsw_t *vswp, uint8_t devtype, uint64_t addr, void *arg)
1661 tgt = (void *)vswp;
1664 WRITE_ENTER(&vswp->mfdbrw);
1665 if (mod_hash_find(vswp->mfdb, (mod_hash_key_t)addr,
1674 if (mod_hash_insert(vswp->mfdb, (mod_hash_key_t)addr,
1676 DERR(vswp, "%s: hash table insertion failed", __func__);
1680 D2(vswp, "%s: added initial entry for 0x%llx to "
1693 DERR(vswp, "%s: duplicate port entry "
1699 DERR(vswp, "%s: duplicate entry found"
1713 D2(vswp, "%s: added entry for 0x%llx to table",
1728 RW_EXIT(&vswp->mfdbrw);
1740 vsw_del_mcst(vsw_t *vswp, uint8_t devtype, uint64_t addr, void *arg)
1746 D1(vswp, "%s: enter", __func__);
1750 D2(vswp, "%s: removing port %d from mFDB for address"
1753 D2(vswp, "%s: removing entry", __func__);
1754 tgt = (void *)vswp;
1757 WRITE_ENTER(&vswp->mfdbrw);
1758 if (mod_hash_find(vswp->mfdb, (mod_hash_key_t)addr,
1760 D2(vswp, "%s: address 0x%llx not in table", __func__, addr);
1761 RW_EXIT(&vswp->mfdbrw);
1770 D2(vswp, "%s: port %d found", __func__,
1773 D2(vswp, "%s: instance found", __func__);
1784 (void) mod_hash_destroy(vswp->mfdb,
1787 (void) mod_hash_replace(vswp->mfdb,
1805 RW_EXIT(&vswp->mfdbrw);
1807 D1(vswp, "%s: exit", __func__);
1825 vsw_t *vswp = port->p_vswp;
1827 D1(vswp, "%s: enter", __func__);
1837 (void) vsw_del_mcst(vswp, VSW_VNETPORT,
1848 vsw_mac_multicast_remove(vswp, port, mcap, VSW_VNETPORT);
1857 D1(vswp, "%s: exit", __func__);
1867 vsw_del_mcst_vsw(vsw_t *vswp)
1871 D1(vswp, "%s: enter", __func__);
1873 mutex_enter(&vswp->mca_lock);
1875 while (vswp->mcap != NULL) {
1876 DERR(vswp, "%s: deleting addr 0x%llx",
1877 __func__, vswp->mcap->addr);
1878 (void) vsw_del_mcst(vswp, VSW_LOCALDEV, vswp->mcap->addr, NULL);
1880 next_p = vswp->mcap->nextp;
1881 kmem_free(vswp->mcap, sizeof (mcst_addr_t));
1882 vswp->mcap = next_p;
1885 vswp->mcap = NULL;
1886 mutex_exit(&vswp->mca_lock);
1888 D1(vswp, "%s: exit", __func__);