Print this page
11493 aggr needs support for multiple pseudo rx groups
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/sun4v/io/vnet.c
          +++ new/usr/src/uts/sun4v/io/vnet.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + * Copyright 2018 Joyent, Inc.
  25   26   */
  26   27  
  27   28  #include <sys/types.h>
  28   29  #include <sys/errno.h>
  29   30  #include <sys/param.h>
  30   31  #include <sys/callb.h>
  31   32  #include <sys/stream.h>
  32   33  #include <sys/kmem.h>
  33   34  #include <sys/conf.h>
  34   35  #include <sys/devops.h>
↓ open down ↓ 1090 lines elided ↑ open up ↑
1125 1126           */
1126 1127          err = mac_register(macp, &vnetp->mh);
1127 1128          mac_free(macp);
1128 1129          return (err == 0 ? DDI_SUCCESS : DDI_FAILURE);
1129 1130  }
1130 1131  
1131 1132  /* read the mac address of the device */
1132 1133  static int
1133 1134  vnet_read_mac_address(vnet_t *vnetp)
1134 1135  {
1135      -        uchar_t         *macaddr;
1136      -        uint32_t        size;
1137      -        int             rv;
     1136 +        uchar_t         *macaddr;
     1137 +        uint32_t        size;
     1138 +        int             rv;
1138 1139  
1139 1140          rv = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, vnetp->dip,
1140 1141              DDI_PROP_DONTPASS, macaddr_propname, &macaddr, &size);
1141 1142          if ((rv != DDI_PROP_SUCCESS) || (size != ETHERADDRL)) {
1142 1143                  DWARN(vnetp, "prop_lookup failed(%s) err(%d)\n",
1143 1144                      macaddr_propname, rv);
1144 1145                  return (DDI_FAILURE);
1145 1146          }
1146 1147          bcopy(macaddr, (caddr_t)vnetp->vendor_addr, ETHERADDRL);
1147 1148          bcopy(macaddr, (caddr_t)vnetp->curr_macaddr, ETHERADDRL);
↓ open down ↓ 1162 lines elided ↑ open up ↑
2310 2311          default:
2311 2312                  break;
2312 2313          }
2313 2314  }
2314 2315  
2315 2316  /*
2316 2317   * Callback funtion for MAC layer to get group information.
2317 2318   */
2318 2319  static void
2319 2320  vnet_get_group(void *arg, mac_ring_type_t type, const int index,
2320      -        mac_group_info_t *infop, mac_group_handle_t handle)
     2321 +    mac_group_info_t *infop, mac_group_handle_t handle)
2321 2322  {
2322 2323          vnet_t  *vnetp = (vnet_t *)arg;
2323 2324  
2324 2325          switch (type) {
2325 2326  
2326 2327          case MAC_RING_TYPE_RX:
2327 2328          {
2328 2329                  vnet_pseudo_rx_group_t  *rx_grp;
2329 2330  
2330 2331                  /* We advertised only one RX group */
↓ open down ↓ 67 lines elided ↑ open up ↑
2398 2399           * return. If and when a hybrid resource is activated for this vnet
2399 2400           * device, we will bind the hwring and start it then. If a hwring is
2400 2401           * already bound, start it now.
2401 2402           */
2402 2403          if (rx_ringp->hw_rh == NULL) {
2403 2404                  rx_ringp->gen_num = mr_gen_num;
2404 2405                  rx_ringp->state |= VNET_RXRING_STARTED;
2405 2406                  return (0);
2406 2407          }
2407 2408  
2408      -        err = mac_hwring_start(rx_ringp->hw_rh);
     2409 +        err = mac_hwring_activate(rx_ringp->hw_rh);
2409 2410          if (err == 0) {
2410 2411                  rx_ringp->gen_num = mr_gen_num;
2411 2412                  rx_ringp->state |= VNET_RXRING_STARTED;
2412 2413          } else {
2413 2414                  err = ENXIO;
2414 2415          }
2415 2416  
2416 2417          return (err);
2417 2418  }
2418 2419  
↓ open down ↓ 17 lines elided ↑ open up ↑
2436 2437          /*
2437 2438           * This must be a ring reserved for a hwring. If the hwring is not
2438 2439           * bound yet, simply mark the state to indicate the ring is stopped and
2439 2440           * return. If a hwring is already bound, stop it now.
2440 2441           */
2441 2442          if (rx_ringp->hw_rh == NULL) {
2442 2443                  rx_ringp->state &= ~VNET_RXRING_STARTED;
2443 2444                  return;
2444 2445          }
2445 2446  
2446      -        mac_hwring_stop(rx_ringp->hw_rh);
     2447 +        mac_hwring_quiesce(rx_ringp->hw_rh);
2447 2448          rx_ringp->state &= ~VNET_RXRING_STARTED;
2448 2449  }
2449 2450  
2450 2451  static int
2451 2452  vnet_rx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
2452 2453  {
2453 2454          vnet_pseudo_rx_ring_t   *rx_ringp = (vnet_pseudo_rx_ring_t *)rdriver;
2454 2455          vnet_t                  *vnetp = (vnet_t *)rx_ringp->vnetp;
2455 2456          vnet_res_t              *vresp;
2456 2457          mac_register_t          *macp;
↓ open down ↓ 166 lines elided ↑ open up ↑
2623 2624          } else {
2624 2625                  vresp = (vnet_res_t *)rx_ringp->hw_rh;
2625 2626                  mp = vgen_rx_poll(vresp->macreg.m_driver, bytes_to_pickup);
2626 2627          }
2627 2628          return (mp);
2628 2629  }
2629 2630  
2630 2631  /* ARGSUSED */
2631 2632  void
2632 2633  vnet_hio_rx_cb(void *arg, mac_resource_handle_t mrh, mblk_t *mp,
2633      -        boolean_t loopback)
     2634 +    boolean_t loopback)
2634 2635  {
2635 2636          vnet_t                  *vnetp = (vnet_t *)arg;
2636 2637          vnet_pseudo_rx_ring_t   *ringp = (vnet_pseudo_rx_ring_t *)mrh;
2637 2638  
2638 2639          /*
2639 2640           * Packets received over a hybrid resource need additional processing
2640 2641           * to remove the tag, for the pvid case. The underlying resource is
2641 2642           * not aware of the vnet's pvid and thus packets are received with the
2642 2643           * vlan tag in the header; unlike packets that are received over a ldc
2643 2644           * channel in which case the peer vnet/vsw would have already removed
↓ open down ↓ 195 lines elided ↑ open up ↑
2839 2840  
2840 2841                  /* Store the hw ring handle */
2841 2842                  rx_ringp->hw_rh = hw_rh[i];
2842 2843  
2843 2844                  /* Bind the pseudo ring to the underlying hwring */
2844 2845                  mac_hwring_setup(rx_ringp->hw_rh,
2845 2846                      (mac_resource_handle_t)rx_ringp, NULL);
2846 2847  
2847 2848                  /* Start the hwring if needed */
2848 2849                  if (rx_ringp->state & VNET_RXRING_STARTED) {
2849      -                        rv = mac_hwring_start(rx_ringp->hw_rh);
     2850 +                        rv = mac_hwring_activate(rx_ringp->hw_rh);
2850 2851                          if (rv != 0) {
2851 2852                                  mac_hwring_teardown(rx_ringp->hw_rh);
2852 2853                                  rx_ringp->hw_rh = NULL;
2853 2854                                  goto fail;
2854 2855                          }
2855 2856                  }
2856 2857          }
2857 2858  
2858 2859          /* Get the list of the underlying TX rings. */
2859 2860          hw_ring_cnt = mac_hwrings_get(vnetp->hio_mch, &vnetp->tx_hwgh, hw_rh,
↓ open down ↓ 53 lines elided ↑ open up ↑
2913 2914                  }
2914 2915          }
2915 2916          (void) mac_client_tx_notify(vnetp->hio_mch, NULL,
2916 2917              tx_grp->tx_notify_handle);
2917 2918  
2918 2919          rx_grp = &vnetp->rx_grp[0];
2919 2920          for (i = 0; i < VNET_NUM_HYBRID_RINGS; i++) {
2920 2921                  rx_ringp = &rx_grp->rings[i + VNET_HYBRID_RXRING_INDEX];
2921 2922                  if (rx_ringp->hw_rh != NULL) {
2922 2923                          /* Stop the hwring */
2923      -                        mac_hwring_stop(rx_ringp->hw_rh);
     2924 +                        mac_hwring_quiesce(rx_ringp->hw_rh);
2924 2925  
2925 2926                          /* Teardown the hwring */
2926 2927                          mac_hwring_teardown(rx_ringp->hw_rh);
2927 2928                          rx_ringp->hw_rh = NULL;
2928 2929                  }
2929 2930          }
2930 2931  
2931 2932          if (vnetp->rx_hwgh != NULL) {
2932 2933                  vnetp->rx_hwgh = NULL;
2933 2934                  /*
↓ open down ↓ 306 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX