Lines Matching defs:ring

185  * sure that any pointers (such as mac ring pointers) it passes to the driver
205 * R16. Drivers must maintain a generation number per Rx ring, and pass it
207 * number whenever the ring's stop routine is invoked.
602 mac_ring_t *ring = (mac_ring_t *)buf;
604 bzero(ring, sizeof (mac_ring_t));
605 cv_init(&ring->mr_cv, NULL, CV_DEFAULT, NULL);
606 mutex_init(&ring->mr_lock, NULL, MUTEX_DEFAULT, NULL);
607 ring->mr_state = MR_FREE;
615 mac_ring_t *ring = (mac_ring_t *)buf;
617 cv_destroy(&ring->mr_cv);
618 mutex_destroy(&ring->mr_lock);
1090 mac_ring_t *ring = NULL;
1102 * Start the default tx ring.
1106 ring = (mac_ring_t *)mip->mi_default_tx_ring;
1107 if (ring->mr_state != MR_INUSE) {
1108 err = mac_start_ring(ring);
1118 * Start the default ring, since it will be needed
1126 if ((ring != NULL) &&
1127 (ring->mr_state == MR_INUSE))
1128 mac_stop_ring(ring);
1177 mac_ring_t *ring;
1179 ring = (mac_ring_t *)mip->mi_default_tx_ring;
1180 if (ring->mr_state == MR_INUSE) {
1181 mac_stop_ring(ring);
1182 ring->mr_flag = 0;
1448 mac_ring_t *ring;
1450 for (ring = grp->mrg_rings; ring != NULL; ring = ring->mr_next)
1451 ring->mr_flag &= ~flag;
1493 mac_ring_t *ring;
1519 for (ring = grp->mrg_rings; ring != NULL; ring = ring->mr_next, cnt++) {
1521 hwrh[cnt] = (mac_ring_handle_t)ring;
1533 * that indicates different properties of the ring.
1538 mac_ring_t *ring = (mac_ring_t *)rh;
1539 mac_ring_info_t *info = &ring->mr_info;
1545 * Export ddi interrupt handles from the HW ring to the pseudo ring and
1547 * HW ring.
1559 /* Export the ddi handles to pseudo ring */
1565 * Save a pointer to pseudo ring in the hw ring. If
1566 * interrupt handle changes, the hw ring will be
1569 * the pseudo ring that has exported the ddi handle.
1643 * Send packets through a selected tx ring.
1648 mac_ring_t *ring = (mac_ring_t *)rh;
1649 mac_ring_info_t *info = &ring->mr_info;
1651 ASSERT(ring->mr_type == MAC_RING_TYPE_TX &&
1652 ring->mr_state >= MR_INUSE);
1657 * Query stats for a particular rx/tx ring
1662 mac_ring_t *ring = (mac_ring_t *)rh;
1663 mac_ring_info_t *info = &ring->mr_info;
1670 * a port/Tx ring. Since aggr exposes a pseudo Tx ring even for ports
1687 * ring. Because aggr exposes a pseudo Tx ring even for ports that may
1688 * temporarily be down, it may need to update the default ring that is used by
1692 * the ring will no longer exist. It's important to give aggr a case where the
1696 * Finally, we explicitly don't do anything if the ring hasn't been enabled yet.
1705 mac_ring_t *ring = (mac_ring_t *)rh;
1710 if (ring->mr_state != MR_INUSE)
1774 /* The ring is not available for reservations any more */
1790 * Quiesce future hardware classified packets for the specified Rx ring
1921 * SRS worker thread, and the soft ring threads are quiesced in sequence
2050 /* In case the ring was stopped, safely restart it */
2497 mac_ring_handle_t ring = arg;
2500 mac_tx_srs_wakeup(flent->fe_tx_srs, ring);
2505 i_mac_tx_srs_notify(mac_impl_t *mip, mac_ring_handle_t ring)
2532 mac_tx_srs_wakeup(mac_srs, ring);
2543 (mac_tx_cookie_t)ring);
2547 mac_tx_flow_srs_wakeup, ring);
3419 * data link because it shares its ring with the
3478 * default ring.
3644 * mac_ring_t 'mr' macros. Some rogue drivers may access ring structure
3646 * cases if MAC free's the ring structure after mac_stop_ring(), any
3647 * illegal access to the ring structure coming from the driver will panic
3656 mac_ring_t *ring;
3660 ring = mip->mi_ring_freelist;
3661 mip->mi_ring_freelist = ring->mr_next;
3662 bzero(ring, sizeof (mac_ring_t));
3666 ring = kmem_cache_alloc(mac_ring_cache, KM_SLEEP);
3668 ASSERT((ring != NULL) && (ring->mr_state == MR_FREE));
3669 return (ring);
3673 mac_ring_free(mac_impl_t *mip, mac_ring_t *ring)
3675 ASSERT(ring->mr_state == MR_FREE);
3678 ring->mr_state = MR_FREE;
3679 ring->mr_flag = 0;
3680 ring->mr_next = mip->mi_ring_freelist;
3681 ring->mr_mip = NULL;
3682 mip->mi_ring_freelist = ring;
3683 mac_ring_stat_delete(ring);
3692 mac_ring_t *ring = mip->mi_ring_freelist;
3693 while (ring != NULL) {
3694 ring_next = ring->mr_next;
3695 kmem_cache_free(mac_ring_cache, ring);
3696 ring = ring_next;
3703 mac_start_ring(mac_ring_t *ring)
3707 ASSERT(ring->mr_state == MR_FREE);
3709 if (ring->mr_start != NULL) {
3710 rv = ring->mr_start(ring->mr_driver, ring->mr_gen_num);
3715 ring->mr_state = MR_INUSE;
3720 mac_stop_ring(mac_ring_t *ring)
3722 ASSERT(ring->mr_state == MR_INUSE);
3724 if (ring->mr_stop != NULL)
3725 ring->mr_stop(ring->mr_driver);
3727 ring->mr_state = MR_FREE;
3730 * Increment the ring generation number for this ring.
3732 ring->mr_gen_num++;
3764 mac_ring_t *ring;
3771 for (ring = group->mrg_rings; ring != NULL; ring = ring->mr_next) {
3772 ASSERT(ring->mr_state == MR_FREE);
3773 if ((rv = mac_start_ring(ring)) != 0)
3775 ring->mr_classify_type = MAC_SW_CLASSIFIER;
3788 mac_ring_t *ring;
3790 for (ring = group->mrg_rings; ring != NULL; ring = ring->mr_next) {
3791 if (ring->mr_state != MR_FREE) {
3792 mac_stop_ring(ring);
3793 ring->mr_flag = 0;
3794 ring->mr_classify_type = MAC_NO_CLASSIFIER;
3805 mac_ring_t *ring, *rnext;
3809 ring = mac_ring_alloc(mip);
3811 /* Prepare basic information of ring */
3817 * ring index exchanged with the driver (e.g. during mr_rget)
3818 * is unique only across the group the ring belongs to.
3822 ring->mr_index = group->mrg_index * group->mrg_info.mgi_count + index;
3823 ring->mr_type = group->mrg_type;
3824 ring->mr_gh = (mac_group_handle_t)group;
3826 /* Insert the new ring to the list. */
3827 ring->mr_next = group->mrg_rings;
3828 group->mrg_rings = ring;
3833 /* Query ring information from driver */
3835 index, &ring_info, (mac_ring_handle_t)ring);
3837 ring->mr_info = ring_info;
3842 * interrupt, then only one ring among the bunch will be made
3848 rnext = ring->mr_next;
3853 * If default ring (mr_index == 0) is part
3856 * the default ring and give another ring
3864 ring->mr_info.mri_intr.mi_ddi_shared =
3873 * Rx rings get registered first. So if this is a Tx ring,
3877 if (rnext == NULL && ring->mr_type == MAC_RING_TYPE_TX) {
3879 mip->mi_rx_group_count, ring);
3883 /* Update ring's status */
3884 ring->mr_state = MR_FREE;
3885 ring->mr_flag = 0;
3887 /* Update the ring count of the group */
3890 /* Create per ring kstats */
3891 if (ring->mr_stat != NULL) {
3892 ring->mr_mip = mip;
3893 mac_ring_stat_create(ring);
3896 return (ring);
3909 * Initialize all ring members of this group. Size of zero will not
3925 mac_ring_t *ring;
3954 * create pseudo TX groups (one per TX ring) in the MAC layer,
3978 * Get all ring groups if any, and get their ring members
4048 * All TX ring groups must have zero rings.
4146 * The default ring is reserved since it is
4168 ring = group->mrg_rings;
4170 * The ring can be NULL in the case of aggr. Aggr will
4175 if (ring == NULL) {
4194 while ((ring->mr_index != 0) && (ring->mr_next != NULL))
4195 ring = ring->mr_next;
4196 ASSERT(ring->mr_index == 0);
4197 mip->mi_default_tx_ring = (mac_ring_handle_t)ring;
4202 * The default ring cannot be reserved.
4225 * the new ring's ddi handle with the existing ones and set ddi_shared
4232 mac_ring_t *ring;
4239 for (ring = group->mrg_rings; ring != NULL;
4240 ring = ring->mr_next) {
4241 if (ring == cring)
4243 if (ring->mr_info.mri_intr.mi_ddi_handle ==
4246 ring->mr_index == 0 &&
4247 !ring->mr_info.mri_intr.mi_ddi_shared) {
4248 ring->mr_info.mri_intr.mi_ddi_shared =
4301 mac_ring_t *ring;
4308 while ((ring = group->mrg_rings) != NULL) {
4309 group->mrg_rings = ring->mr_next;
4310 mac_ring_free(mip, ring);
4356 * If no bridge is in place, MAC_RING_TX transmits using tx ring. The 'rh'
4357 * pointer may be NULL to select the default ring.
4384 * Find a ring from its index.
4390 mac_ring_t *ring = group->mrg_rings;
4392 for (ring = group->mrg_rings; ring != NULL; ring = ring->mr_next)
4393 if (ring->mr_index == index)
4396 return ((mac_ring_handle_t)ring);
4399 * Add a ring to an existing group.
4401 * The ring must be either passed directly (for example if the ring
4403 * index (for example when the ring is added by the driver.
4408 i_mac_group_add_ring(mac_group_t *group, mac_ring_t *ring, int index)
4412 boolean_t driver_call = (ring == NULL);
4433 * There should be no ring with the same ring index in the target
4437 driver_call ? index : ring->mr_index) == NULL);
4442 * a driver to add a ring to an existing group, for example
4444 * for that ring.
4446 ring = mac_init_ring(mip, group, index, cap_rings);
4451 * to add a ring to an existing group. In this case the
4452 * ring is being moved between groups, which requires
4459 ASSERT(ring->mr_gh == NULL);
4463 * At this point the ring should not be in use, and it should be
4466 ASSERT(ring->mr_state < MR_INUSE);
4467 ASSERT(ring->mr_srs == NULL);
4468 ASSERT(ring->mr_type == group->mrg_type);
4472 * Add the driver level hardware ring if the process was not
4478 ring->mr_driver, ring->mr_type);
4482 * Insert the ring ahead existing rings.
4484 ring->mr_next = group->mrg_rings;
4485 group->mrg_rings = ring;
4486 ring->mr_gh = (mac_group_handle_t)group;
4498 * Start the ring if needed. Failure causes to undo the grouping action.
4500 if (ring->mr_state != MR_INUSE) {
4501 if ((ret = mac_start_ring(ring)) != 0) {
4504 ring->mr_driver, ring->mr_type);
4507 group->mrg_rings = ring->mr_next;
4509 ring->mr_gh = NULL;
4512 mac_ring_free(mip, ring);
4519 * Set up SRS/SR according to the ring type.
4521 switch (ring->mr_type) {
4524 * Setup SRS on top of the new ring if the group is
4544 ring->mr_classify_type = MAC_SW_CLASSIFIER;
4556 if (ring->mr_state == MR_INUSE)
4557 mac_stop_ring(ring);
4558 ring->mr_flag = 0;
4595 mac_tx_srs_add_ring(mac_srs, ring);
4607 * For aggr, the default ring will be NULL to begin with. If it
4608 * is NULL, then pick the first ring that gets added as the
4609 * default ring. Any ring in an aggregation can be removed at
4611 * current default ring gets removed, then a new one gets
4616 ring->mr_type == MAC_RING_TYPE_TX) {
4617 mip->mi_default_tx_ring = (mac_ring_handle_t)ring;
4620 MAC_RING_UNMARK(ring, MR_INCIPIENT);
4625 * Remove a ring from it's current group. MAC internal function for dynamic
4631 i_mac_group_rem_ring(mac_group_t *group, mac_ring_t *ring,
4641 ring->mr_index) == (mac_ring_handle_t)ring);
4642 ASSERT((mac_group_t *)ring->mr_gh == group);
4643 ASSERT(ring->mr_type == group->mrg_type);
4645 if (ring->mr_state == MR_INUSE)
4646 mac_stop_ring(ring);
4647 switch (ring->mr_type) {
4654 * ring all the way up the Rx path. mac_rx_srs_remove()
4657 * nor any association with the ring in mac_rx.
4659 if (ring->mr_srs != NULL) {
4660 mac_rx_srs_remove(ring->mr_srs);
4661 ring->mr_srs = NULL;
4702 (mac_ring_handle_t)ring) {
4703 /* pick a new default Tx ring */
4705 (group->mrg_rings != ring) ?
4707 (mac_ring_handle_t)(ring->mr_next);
4722 * Tx ring due to flow control.
4724 sringp = srs_tx->st_soft_rings[ring->mr_index];
4728 mac_tx_srs_del_ring(mac_srs, ring);
4732 ASSERT(ring != (mac_ring_t *)mip->mi_default_tx_ring);
4751 * already deleted the ring from the MAC
4757 mac_tx_srs_get_soft_ring(mac_srs, ring));
4758 mac_tx_srs_del_ring(mac_srs, ring);
4762 * one ring in the group after this, we need
4764 * yet taken the ring out, so we check with 2).
4767 if (ring->mr_next == NULL)
4770 rem_ring = ring->mr_next;
4785 * to 1 ring.
4807 * Remove the ring from the group.
4809 if (ring == group->mrg_rings)
4810 group->mrg_rings = ring->mr_next;
4815 while (pre->mr_next != ring)
4817 pre->mr_next = ring->mr_next;
4827 * Remove the driver level hardware ring.
4831 ring->mr_driver, ring->mr_type);
4835 ring->mr_gh = NULL;
4837 mac_ring_free(mip, ring);
4839 ring->mr_flag = 0;
4843 * Move a ring to the target group. If needed, remove the ring from the group
4849 mac_group_mov_ring(mac_impl_t *mip, mac_group_t *d_group, mac_ring_t *ring)
4851 mac_group_t *s_group = (mac_group_t *)ring->mr_gh;
4865 i_mac_group_rem_ring(s_group, ring, B_FALSE);
4870 rv = i_mac_group_add_ring(d_group, ring, 0);
4873 * Failed to add ring back to source group. If
4874 * that fails, the ring is stuck in limbo, log message.
4876 if (i_mac_group_add_ring(s_group, ring, 0)) {
4877 cmn_err(CE_WARN, "%s: failed to move ring %p\n",
4878 mip->mi_name, (void *)ring);
5879 * Reserve a unused ring by marking it with MR_INUSE state.
5880 * As reserved, the ring is ready to function.
5884 * If a specific ring is needed, it is specified through the desired_ring
5886 * If the desired ring was previous allocated to another client, this
5887 * function swaps it with a new ring from the group of unassigned rings.
5900 * Find an available ring and start it before changing its status.
5906 /* Can't take the default ring out of the default group */
5916 * There are clients using this ring, so let's move the clients
5917 * away from using this ring.
5952 * Hybrid I/O specifies the ring that should be given to a share.
5953 * If the ring is already used by clients, then we need to release
5954 * the ring back to the default group so that we can give it to
5955 * the share. This means the clients using this ring now get a
5956 * replacement ring. If there aren't any replacement rings, this
5961 mac_ring_t *ring, mac_ring_t **rings, int nrings)
5963 mac_group_t *group = (mac_group_t *)ring->mr_gh;
5987 * Switch this ring with some other ring from
6005 if (mac_group_mov_ring(mip, defgrp, ring) != 0) {
6010 ASSERT(ring->mr_gh == (mac_group_handle_t)defgrp);
6015 if (ring == (mac_ring_t *)mip->mi_default_tx_ring) {
6017 * See if we can get a spare ring to replace the default
6018 * ring.
6022 * Need to get a ring from another client, see if
6040 * If this ring is part of the
6042 * use it as the default ring.
6061 * default ring.
6067 * Swap the default ring with another.
6072 * If this ring is part of the rings asked by the
6073 * share we cannot use it as the default ring.
6087 * The Tx ring is with a group reserved by a MAC client. See if
6103 * Switch this ring with some other ring from
6111 * If this ring is part of the rings asked by the
6129 if (mac_group_mov_ring(mip, defgrp, ring) != 0) {
6136 ASSERT(ring->mr_gh == (mac_group_handle_t)defgrp);
6141 * Populate a zero-ring group with rings. If the share is non-NULL,
6152 mac_ring_t **rings, *ring;
6174 * If we have given this ring to a non-default
6176 * ring.
6178 ring = rings[i];
6179 if (ring->mr_gh != (mac_group_handle_t)src_group ||
6180 ring == (mac_ring_t *)mip->mi_default_tx_ring) {
6182 ring, rings, nrings) != 0) {
6190 * Pick one ring from default group.
6192 * for now pick the second ring which requires the first ring
6194 * ring which carries the multicast traffic.
6196 * for example a per-ring flag.
6200 for (ring = src_group->mrg_rings; ring != NULL;
6201 ring = ring->mr_next) {
6203 ring->mr_index == 0) {
6207 ring == (mac_ring_t *)mip->mi_default_tx_ring) {
6210 rings[i++] = ring;
6214 ASSERT(ring != NULL);
6250 /* get the desired ring */
6326 * largest number of rings, otherwise the default ring when available.
6414 * We need to leave at least one ring.
6423 * it all the rings from the donor group, except the default ring
6429 * For flows that have not asked for software or hardware ring,
6430 * try to reserve a non-default group with 1 ring, if available.
6630 mac_ring_t *ring;
6641 for (ring = group->mrg_rings; ring != NULL; ring = ring->mr_next) {
6642 if (ring->mr_classify_type == MAC_HW_CLASSIFIER) {
6645 * Remove the SRS associated with the HW ring.
6648 ring->mr_srs = NULL;
6651 ring->mr_state == MR_INUSE);
6652 if (ring->mr_state == MR_INUSE) {
6653 mac_stop_ring(ring);
6654 ring->mr_flag = 0;
6665 mac_ring_t *ring;
6671 while ((ring = group->mrg_rings) != NULL) {
6673 ring);
6969 * We need to leave at least one ring - the default ring - in
7115 mac_ring_t *ring;
7122 for (ring = grp->mrg_rings; ring != NULL;
7123 ring = ring->mr_next) {
7124 ASSERT(mac_tx_srs_ring_present(srs, ring));
7127 mac_tx_srs_get_soft_ring(srs, ring));
7128 mac_tx_srs_del_ring(srs, ring);
7139 /* move the ring back to the pool */
7141 while ((ring = grp->mrg_rings) != NULL)
7142 (void) mac_group_mov_ring(mip, defgrp, ring);
7158 mac_ring_t *ring;
7163 /* Single ring case we haven't created any soft rings */
7170 for (ring = fgrp->mrg_rings; ring != NULL;
7171 ring = ring->mr_next) {
7172 ASSERT(mac_tx_srs_ring_present(tx_srs, ring));
7175 ring));
7176 mac_tx_srs_del_ring(tx_srs, ring);
7240 mac_ring_t *ring;
7248 * the default ring. The reason being
7254 ring = fgrp->mrg_rings;
7256 if (ring->mr_state == MR_INUSE &&
7257 ring !=
7259 mac_stop_ring(ring);
7260 ring->mr_flag = 0;
7262 ring = ring->mr_next;
7497 * We are adding or removing ring(s) from a group. The source for taking
7508 mac_ring_t *ring;
7522 * If we are asked for just a group, we give 1 ring, else
7549 ring = group->mrg_rings;
7554 next = ring->mr_next;
7555 rv = mac_group_mov_ring(mip, defgrp, ring);
7564 rings[j++] = ring;
7565 ring = next;
7922 * to the ring count in the group.
7979 * group is reserved, the ring count in the default group
7997 * will land in the default ring in the default group which means