4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
25 */
26
27 /*
28 * MAC Services Module
29 *
30 * The GLDv3 framework locking - The MAC layer
31 * --------------------------------------------
32 *
33 * The MAC layer is central to the GLD framework and can provide the locking
34 * framework needed for itself and for the use of MAC clients. MAC end points
35 * are fairly disjoint and don't share a lot of state. So a coarse grained
36 * multi-threading scheme is to single thread all create/modify/delete or set
37 * type of control operations on a per mac end point while allowing data threads
38 * concurrently.
39 *
40 * Control operations (set) that modify a mac end point are always serialized on
41 * a per mac end point basis, We have at most 1 such thread per mac end point
42 * at a time.
43 *
44 * All other operations that are not serialized are essentially multi-threaded.
1660 return (info->mri_stat(info->mri_driver, stat, val));
1661 }
1662
1663 /*
1664 * Private function that is only used by aggr to send packets through
1665 * a port/Tx ring. Since aggr exposes a pseudo Tx ring even for ports
1666 * that does not expose Tx rings, aggr_ring_tx() entry point needs
1667 * access to mac_impl_t to send packets through m_tx() entry point.
1668 * It accomplishes this by calling mac_hwring_send_priv() function.
1669 */
1670 mblk_t *
1671 mac_hwring_send_priv(mac_client_handle_t mch, mac_ring_handle_t rh, mblk_t *mp)
1672 {
1673 mac_client_impl_t *mcip = (mac_client_impl_t *)mch;
1674 mac_impl_t *mip = mcip->mci_mip;
1675
1676 MAC_TX(mip, rh, mp, mcip);
1677 return (mp);
1678 }
1679
1680 int
1681 mac_hwgroup_addmac(mac_group_handle_t gh, const uint8_t *addr)
1682 {
1683 mac_group_t *group = (mac_group_t *)gh;
1684
1685 return (mac_group_addmac(group, addr));
1686 }
1687
1688 int
1689 mac_hwgroup_remmac(mac_group_handle_t gh, const uint8_t *addr)
1690 {
1691 mac_group_t *group = (mac_group_t *)gh;
1692
1693 return (mac_group_remmac(group, addr));
1694 }
1695
1696 /*
1697 * Set the RX group to be shared/reserved. Note that the group must be
1698 * started/stopped outside of this function.
1699 */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Joyent, Inc.
25 */
26
27 /*
28 * MAC Services Module
29 *
30 * The GLDv3 framework locking - The MAC layer
31 * --------------------------------------------
32 *
33 * The MAC layer is central to the GLD framework and can provide the locking
34 * framework needed for itself and for the use of MAC clients. MAC end points
35 * are fairly disjoint and don't share a lot of state. So a coarse grained
36 * multi-threading scheme is to single thread all create/modify/delete or set
37 * type of control operations on a per mac end point while allowing data threads
38 * concurrently.
39 *
40 * Control operations (set) that modify a mac end point are always serialized on
41 * a per mac end point basis, We have at most 1 such thread per mac end point
42 * at a time.
43 *
44 * All other operations that are not serialized are essentially multi-threaded.
1660 return (info->mri_stat(info->mri_driver, stat, val));
1661 }
1662
1663 /*
1664 * Private function that is only used by aggr to send packets through
1665 * a port/Tx ring. Since aggr exposes a pseudo Tx ring even for ports
1666 * that does not expose Tx rings, aggr_ring_tx() entry point needs
1667 * access to mac_impl_t to send packets through m_tx() entry point.
1668 * It accomplishes this by calling mac_hwring_send_priv() function.
1669 */
1670 mblk_t *
1671 mac_hwring_send_priv(mac_client_handle_t mch, mac_ring_handle_t rh, mblk_t *mp)
1672 {
1673 mac_client_impl_t *mcip = (mac_client_impl_t *)mch;
1674 mac_impl_t *mip = mcip->mci_mip;
1675
1676 MAC_TX(mip, rh, mp, mcip);
1677 return (mp);
1678 }
1679
1680 /*
1681 * Private function that is only used by aggr to update the default transmission
1682 * ring. Because aggr exposes a pseudo Tx ring even for ports that may
1683 * temporarily be down, it may need to update the default ring that is used by
1684 * MAC such that it refers to a link that can actively be used to send traffic.
1685 * Note that this is different from the case where the port has been removed
1686 * from the group. In those cases, all of the rings will be torn down because
1687 * the ring will no longer exist. It's important to give aggr a case where the
1688 * rings can still exist such that it may be able to continue to send LACP PDUs
1689 * to potentially restore the link.
1690 *
1691 * Finally, we explicitly don't do anything if the ring hasn't been enabled yet.
1692 * This is to help out aggr which doesn't really know the internal state that
1693 * MAC does about the rings and can't know that it's not quite ready for use
1694 * yet.
1695 */
1696 void
1697 mac_hwring_set_default(mac_handle_t mh, mac_ring_handle_t rh)
1698 {
1699 mac_impl_t *mip = (mac_impl_t *)mh;
1700 mac_ring_t *ring = (mac_ring_t *)rh;
1701
1702 ASSERT(MAC_PERIM_HELD(mh));
1703 VERIFY(mip->mi_state_flags & MIS_IS_AGGR);
1704
1705 if (ring->mr_state != MR_INUSE)
1706 return;
1707
1708 mip->mi_default_tx_ring = rh;
1709 }
1710
1711 int
1712 mac_hwgroup_addmac(mac_group_handle_t gh, const uint8_t *addr)
1713 {
1714 mac_group_t *group = (mac_group_t *)gh;
1715
1716 return (mac_group_addmac(group, addr));
1717 }
1718
1719 int
1720 mac_hwgroup_remmac(mac_group_handle_t gh, const uint8_t *addr)
1721 {
1722 mac_group_t *group = (mac_group_t *)gh;
1723
1724 return (mac_group_remmac(group, addr));
1725 }
1726
1727 /*
1728 * Set the RX group to be shared/reserved. Note that the group must be
1729 * started/stopped outside of this function.
1730 */
|