682 void
683 mac_trill_snoop(mac_handle_t mh, mblk_t *mp)
684 {
685 mac_impl_t *mip = (mac_impl_t *)mh;
686
687 if (mip->mi_promisc_list != NULL)
688 mac_promisc_dispatch(mip, mp, NULL);
689 }
690
691 /*
692 * This is the upward reentry point for packets arriving from the bridging
693 * module and from mac_rx for links not part of a bridge.
694 */
695 void
696 mac_rx_common(mac_handle_t mh, mac_resource_handle_t mrh, mblk_t *mp_chain)
697 {
698 mac_impl_t *mip = (mac_impl_t *)mh;
699 mac_ring_t *mr = (mac_ring_t *)mrh;
700 mac_soft_ring_set_t *mac_srs;
701 mblk_t *bp = mp_chain;
702 boolean_t hw_classified = B_FALSE;
703
704 /*
705 * If there are any promiscuous mode callbacks defined for
706 * this MAC, pass them a copy if appropriate.
707 */
708 if (mip->mi_promisc_list != NULL)
709 mac_promisc_dispatch(mip, mp_chain, NULL);
710
711 if (mr != NULL) {
712 /*
713 * If the SRS teardown has started, just return. The 'mr'
714 * continues to be valid until the driver unregisters the mac.
715 * Hardware classified packets will not make their way up
716 * beyond this point once the teardown has started. The driver
717 * is never passed a pointer to a flow entry or SRS or any
718 * structure that can be freed much before mac_unregister.
719 */
720 mutex_enter(&mr->mr_lock);
721 if ((mr->mr_state != MR_INUSE) || (mr->mr_flag &
722 (MR_INCIPIENT | MR_CONDEMNED | MR_QUIESCE))) {
723 mutex_exit(&mr->mr_lock);
724 freemsgchain(mp_chain);
725 return;
726 }
727 if (mr->mr_classify_type == MAC_HW_CLASSIFIER) {
728 hw_classified = B_TRUE;
729 MR_REFHOLD_LOCKED(mr);
730 }
731 mutex_exit(&mr->mr_lock);
732
733 /*
734 * We check if an SRS is controlling this ring.
735 * If so, we can directly call the srs_lower_proc
736 * routine otherwise we need to go through mac_rx_classify
737 * to reach the right place.
738 */
739 if (hw_classified) {
740 mac_srs = mr->mr_srs;
741 /*
742 * This is supposed to be the fast path.
743 * All packets received though here were steered by
744 * the hardware classifier, and share the same
745 * MAC header info.
746 */
747 mac_srs->srs_rx.sr_lower_proc(mh,
748 (mac_resource_handle_t)mac_srs, mp_chain, B_FALSE);
749 MR_REFRELE(mr);
750 return;
751 }
752 /* We'll fall through to software classification */
753 } else {
754 flow_entry_t *flent;
755 int err;
756
757 rw_enter(&mip->mi_rw_lock, RW_READER);
758 if (mip->mi_single_active_client != NULL) {
759 flent = mip->mi_single_active_client->mci_flent_list;
760 FLOW_TRY_REFHOLD(flent, err);
761 rw_exit(&mip->mi_rw_lock);
762 if (err == 0) {
763 (flent->fe_cb_fn)(flent->fe_cb_arg1,
764 flent->fe_cb_arg2, mp_chain, B_FALSE);
765 FLOW_REFRELE(flent);
766 return;
767 }
768 } else {
769 rw_exit(&mip->mi_rw_lock);
770 }
771 }
|
682 void
683 mac_trill_snoop(mac_handle_t mh, mblk_t *mp)
684 {
685 mac_impl_t *mip = (mac_impl_t *)mh;
686
687 if (mip->mi_promisc_list != NULL)
688 mac_promisc_dispatch(mip, mp, NULL);
689 }
690
691 /*
692 * This is the upward reentry point for packets arriving from the bridging
693 * module and from mac_rx for links not part of a bridge.
694 */
695 void
696 mac_rx_common(mac_handle_t mh, mac_resource_handle_t mrh, mblk_t *mp_chain)
697 {
698 mac_impl_t *mip = (mac_impl_t *)mh;
699 mac_ring_t *mr = (mac_ring_t *)mrh;
700 mac_soft_ring_set_t *mac_srs;
701 mblk_t *bp = mp_chain;
702
703 /*
704 * If there are any promiscuous mode callbacks defined for
705 * this MAC, pass them a copy if appropriate.
706 */
707 if (mip->mi_promisc_list != NULL)
708 mac_promisc_dispatch(mip, mp_chain, NULL);
709
710 if (mr != NULL) {
711 /*
712 * If the SRS teardown has started, just return. The 'mr'
713 * continues to be valid until the driver unregisters the MAC.
714 * Hardware classified packets will not make their way up
715 * beyond this point once the teardown has started. The driver
716 * is never passed a pointer to a flow entry or SRS or any
717 * structure that can be freed much before mac_unregister.
718 */
719 mutex_enter(&mr->mr_lock);
720 if ((mr->mr_state != MR_INUSE) || (mr->mr_flag &
721 (MR_INCIPIENT | MR_CONDEMNED | MR_QUIESCE))) {
722 mutex_exit(&mr->mr_lock);
723 freemsgchain(mp_chain);
724 return;
725 }
726
727 /*
728 * The ring is in passthru mode; pass the chain up to
729 * the pseudo ring.
730 */
731 if (mr->mr_classify_type == MAC_PASSTHRU_CLASSIFIER) {
732 MR_REFHOLD_LOCKED(mr);
733 mutex_exit(&mr->mr_lock);
734 mr->mr_pt_fn(mr->mr_pt_arg1, mr->mr_pt_arg2, mp_chain,
735 B_FALSE);
736 MR_REFRELE(mr);
737 return;
738 }
739
740 /*
741 * The passthru callback should only be set when in
742 * MAC_PASSTHRU_CLASSIFIER mode.
743 */
744 ASSERT3P(mr->mr_pt_fn, ==, NULL);
745
746 /*
747 * We check if an SRS is controlling this ring.
748 * If so, we can directly call the srs_lower_proc
749 * routine otherwise we need to go through mac_rx_classify
750 * to reach the right place.
751 */
752 if (mr->mr_classify_type == MAC_HW_CLASSIFIER) {
753 MR_REFHOLD_LOCKED(mr);
754 mutex_exit(&mr->mr_lock);
755 ASSERT3P(mr->mr_srs, !=, NULL);
756 mac_srs = mr->mr_srs;
757
758 /*
759 * This is the fast path. All packets received
760 * on this ring are hardware classified and
761 * share the same MAC header info.
762 */
763 mac_srs->srs_rx.sr_lower_proc(mh,
764 (mac_resource_handle_t)mac_srs, mp_chain, B_FALSE);
765 MR_REFRELE(mr);
766 return;
767 }
768
769 mutex_exit(&mr->mr_lock);
770 /* We'll fall through to software classification */
771 } else {
772 flow_entry_t *flent;
773 int err;
774
775 rw_enter(&mip->mi_rw_lock, RW_READER);
776 if (mip->mi_single_active_client != NULL) {
777 flent = mip->mi_single_active_client->mci_flent_list;
778 FLOW_TRY_REFHOLD(flent, err);
779 rw_exit(&mip->mi_rw_lock);
780 if (err == 0) {
781 (flent->fe_cb_fn)(flent->fe_cb_arg1,
782 flent->fe_cb_arg2, mp_chain, B_FALSE);
783 FLOW_REFRELE(flent);
784 return;
785 }
786 } else {
787 rw_exit(&mip->mi_rw_lock);
788 }
789 }
|