Print this page
6064 ixgbe needs X550 support

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ixgbe/ixgbe_main.c
          +++ new/usr/src/uts/common/io/ixgbe/ixgbe_main.c
↓ open down ↓ 21 lines elided ↑ open up ↑
  22   22  /*
  23   23   * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  28   28   * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  29   29   * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  30   30   * Copyright (c) 2013 Saso Kiselkov. All rights reserved.
  31   31   * Copyright (c) 2013 OSN Online Service Nuernberg GmbH. All rights reserved.
       32 + * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
  32   33   */
  33   34  
  34   35  #include "ixgbe_sw.h"
  35   36  
  36   37  static char ixgbe_ident[] = "Intel 10Gb Ethernet";
  37      -static char ixgbe_version[] = "ixgbe 1.1.7";
  38   38  
  39   39  /*
  40   40   * Local function protoypes
  41   41   */
  42   42  static int ixgbe_register_mac(ixgbe_t *);
  43   43  static int ixgbe_identify_hardware(ixgbe_t *);
  44   44  static int ixgbe_regs_map(ixgbe_t *);
  45   45  static void ixgbe_init_properties(ixgbe_t *);
  46   46  static int ixgbe_init_driver_settings(ixgbe_t *);
  47   47  static void ixgbe_init_locks(ixgbe_t *);
↓ open down ↓ 10 lines elided ↑ open up ↑
  58   58  static int ixgbe_alloc_rx_data(ixgbe_t *);
  59   59  static void ixgbe_free_rx_data(ixgbe_t *);
  60   60  static void ixgbe_setup_rings(ixgbe_t *);
  61   61  static void ixgbe_setup_rx(ixgbe_t *);
  62   62  static void ixgbe_setup_tx(ixgbe_t *);
  63   63  static void ixgbe_setup_rx_ring(ixgbe_rx_ring_t *);
  64   64  static void ixgbe_setup_tx_ring(ixgbe_tx_ring_t *);
  65   65  static void ixgbe_setup_rss(ixgbe_t *);
  66   66  static void ixgbe_setup_vmdq(ixgbe_t *);
  67   67  static void ixgbe_setup_vmdq_rss(ixgbe_t *);
       68 +static void ixgbe_setup_rss_table(ixgbe_t *);
  68   69  static void ixgbe_init_unicst(ixgbe_t *);
  69   70  static int ixgbe_unicst_find(ixgbe_t *, const uint8_t *);
  70   71  static void ixgbe_setup_multicst(ixgbe_t *);
  71   72  static void ixgbe_get_hw_state(ixgbe_t *);
  72   73  static void ixgbe_setup_vmdq_rss_conf(ixgbe_t *ixgbe);
  73   74  static void ixgbe_get_conf(ixgbe_t *);
  74   75  static void ixgbe_init_params(ixgbe_t *);
  75   76  static int ixgbe_get_prop(ixgbe_t *, char *, int, int, int);
  76   77  static void ixgbe_driver_link_check(ixgbe_t *);
  77   78  static void ixgbe_sfp_check(void *);
  78   79  static void ixgbe_overtemp_check(void *);
       80 +static void ixgbe_phy_check(void *);
  79   81  static void ixgbe_link_timer(void *);
  80   82  static void ixgbe_local_timer(void *);
  81   83  static void ixgbe_arm_watchdog_timer(ixgbe_t *);
  82   84  static void ixgbe_restart_watchdog_timer(ixgbe_t *);
  83   85  static void ixgbe_disable_adapter_interrupts(ixgbe_t *);
  84   86  static void ixgbe_enable_adapter_interrupts(ixgbe_t *);
  85   87  static boolean_t is_valid_mac_addr(uint8_t *);
  86   88  static boolean_t ixgbe_stall_check(ixgbe_t *);
  87   89  static boolean_t ixgbe_set_loopback_mode(ixgbe_t *, uint32_t);
  88   90  static void ixgbe_set_internal_mac_loopback(ixgbe_t *);
↓ open down ↓ 218 lines elided ↑ open up ↑
 307  309          1,              /* minimum number of tx queues */
 308  310          8,              /* default number of tx queues */
 309  311          15500,          /* maximum MTU size */
 310  312          0xFF8,          /* maximum interrupt throttle rate */
 311  313          0,              /* minimum interrupt throttle rate */
 312  314          200,            /* default interrupt throttle rate */
 313  315          64,             /* maximum total msix vectors */
 314  316          16,             /* maximum number of ring vectors */
 315  317          2,              /* maximum number of other vectors */
 316  318          (IXGBE_EICR_LSC
 317      -        | IXGBE_EICR_GPI_SDP1
 318      -        | IXGBE_EICR_GPI_SDP2), /* "other" interrupt types handled */
      319 +        | IXGBE_EICR_GPI_SDP1_X540
      320 +        | IXGBE_EICR_GPI_SDP2_X540), /* "other" interrupt types handled */
 319  321  
 320      -        (IXGBE_SDP1_GPIEN
 321      -        | IXGBE_SDP2_GPIEN), /* "other" interrupt types enable mask */
      322 +        (IXGBE_SDP1_GPIEN_X540
      323 +        | IXGBE_SDP2_GPIEN_X540), /* "other" interrupt types enable mask */
 322  324  
 323  325          (IXGBE_FLAG_DCA_CAPABLE
 324  326          | IXGBE_FLAG_RSS_CAPABLE
 325  327          | IXGBE_FLAG_VMDQ_CAPABLE
 326  328          | IXGBE_FLAG_RSC_CAPABLE) /* capability flags */
 327  329  };
 328  330  
      331 +static adapter_info_t ixgbe_X550_cap = {
      332 +        128,            /* maximum number of rx queues */
      333 +        1,              /* minimum number of rx queues */
      334 +        128,            /* default number of rx queues */
      335 +        64,             /* maximum number of rx groups */
      336 +        1,              /* minimum number of rx groups */
      337 +        1,              /* default number of rx groups */
      338 +        128,            /* maximum number of tx queues */
      339 +        1,              /* minimum number of tx queues */
      340 +        8,              /* default number of tx queues */
      341 +        15500,          /* maximum MTU size */
      342 +        0xFF8,          /* maximum interrupt throttle rate */
      343 +        0,              /* minimum interrupt throttle rate */
      344 +        0x200,          /* default interrupt throttle rate */
      345 +        64,             /* maximum total msix vectors */
      346 +        16,             /* maximum number of ring vectors */
      347 +        2,              /* maximum number of other vectors */
      348 +        IXGBE_EICR_LSC, /* "other" interrupt types handled */
      349 +        0,              /* "other" interrupt types enable mask */
      350 +        (IXGBE_FLAG_RSS_CAPABLE
      351 +        | IXGBE_FLAG_VMDQ_CAPABLE
      352 +        | IXGBE_FLAG_RSC_CAPABLE) /* capability flags */
      353 +};
      354 +
 329  355  /*
 330  356   * Module Initialization Functions.
 331  357   */
 332  358  
 333  359  int
 334  360  _init(void)
 335  361  {
 336  362          int status;
 337  363  
 338  364          mac_init_ops(&ixgbe_dev_ops, MODULE_NAME);
↓ open down ↓ 80 lines elided ↑ open up ↑
 419  445  
 420  446          hw = &ixgbe->hw;
 421  447          osdep = &ixgbe->osdep;
 422  448          hw->back = osdep;
 423  449          osdep->ixgbe = ixgbe;
 424  450  
 425  451          /* Attach the instance pointer to the dev_info data structure */
 426  452          ddi_set_driver_private(devinfo, ixgbe);
 427  453  
 428  454          /*
 429      -         * Initialize for fma support
      455 +         * Initialize for FMA support
 430  456           */
 431  457          ixgbe->fm_capabilities = ixgbe_get_prop(ixgbe, PROP_FM_CAPABLE,
 432  458              0, 0x0f, DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
 433  459              DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE);
 434  460          ixgbe_fm_init(ixgbe);
 435  461          ixgbe->attach_progress |= ATTACH_PROGRESS_FM_INIT;
 436  462  
 437  463          /*
 438  464           * Map PCI config space registers
 439  465           */
↓ open down ↓ 88 lines elided ↑ open up ↑
 528  554           */
 529  555          (void) sprintf(taskqname, "ixgbe%d_overtemp_taskq", instance);
 530  556          if ((ixgbe->overtemp_taskq = ddi_taskq_create(devinfo, taskqname,
 531  557              1, TASKQ_DEFAULTPRI, 0)) == NULL) {
 532  558                  ixgbe_error(ixgbe, "overtemp_taskq create failed");
 533  559                  goto attach_fail;
 534  560          }
 535  561          ixgbe->attach_progress |= ATTACH_PROGRESS_OVERTEMP_TASKQ;
 536  562  
 537  563          /*
      564 +         * Create a taskq for processing external PHY interrupts
      565 +         */
      566 +        (void) sprintf(taskqname, "ixgbe%d_phy_taskq", instance);
      567 +        if ((ixgbe->phy_taskq = ddi_taskq_create(devinfo, taskqname,
      568 +            1, TASKQ_DEFAULTPRI, 0)) == NULL) {
      569 +                ixgbe_error(ixgbe, "phy_taskq create failed");
      570 +                goto attach_fail;
      571 +        }
      572 +        ixgbe->attach_progress |= ATTACH_PROGRESS_PHY_TASKQ;
      573 +
      574 +        /*
 538  575           * Initialize driver parameters
 539  576           */
 540  577          if (ixgbe_init_driver_settings(ixgbe) != IXGBE_SUCCESS) {
 541  578                  ixgbe_error(ixgbe, "Failed to initialize driver settings");
 542  579                  goto attach_fail;
 543  580          }
 544  581  
 545  582          /*
 546  583           * Initialize mutexes for this device.
 547  584           * Do this before enabling the interrupt handler and
↓ open down ↓ 14 lines elided ↑ open up ↑
 562  599          ixgbe->link_check_hrtime = gethrtime() +
 563  600              (IXGBE_LINK_UP_TIME * 100000000ULL);
 564  601          ixgbe->attach_progress |= ATTACH_PROGRESS_INIT;
 565  602  
 566  603          if (ixgbe_check_acc_handle(ixgbe->osdep.cfg_handle) != DDI_FM_OK) {
 567  604                  ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
 568  605                  goto attach_fail;
 569  606          }
 570  607  
 571  608          /*
      609 +         * Initialize adapter capabilities
      610 +         */
      611 +        ixgbe_init_params(ixgbe);
      612 +
      613 +        /*
 572  614           * Initialize statistics
 573  615           */
 574  616          if (ixgbe_init_stats(ixgbe) != IXGBE_SUCCESS) {
 575  617                  ixgbe_error(ixgbe, "Failed to initialize statistics");
 576  618                  goto attach_fail;
 577  619          }
 578  620          ixgbe->attach_progress |= ATTACH_PROGRESS_STATS;
 579  621  
 580  622          /*
 581  623           * Register the driver to the MAC
↓ open down ↓ 16 lines elided ↑ open up ↑
 598  640          /*
 599  641           * Now that mutex locks are initialized, and the chip is also
 600  642           * initialized, enable interrupts.
 601  643           */
 602  644          if (ixgbe_enable_intrs(ixgbe) != IXGBE_SUCCESS) {
 603  645                  ixgbe_error(ixgbe, "Failed to enable DDI interrupts");
 604  646                  goto attach_fail;
 605  647          }
 606  648          ixgbe->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
 607  649  
 608      -        ixgbe_log(ixgbe, "%s, %s", ixgbe_ident, ixgbe_version);
      650 +        ixgbe_log(ixgbe, "%s", ixgbe_ident);
 609  651          atomic_or_32(&ixgbe->ixgbe_state, IXGBE_INITIALIZED);
 610  652  
 611  653          return (DDI_SUCCESS);
 612  654  
 613  655  attach_fail:
 614  656          ixgbe_unconfigure(devinfo, ixgbe);
 615  657          return (DDI_FAILURE);
 616  658  }
 617  659  
 618  660  /*
↓ open down ↓ 162 lines elided ↑ open up ↑
 781  823          }
 782  824  
 783  825          /*
 784  826           * Remove taskq for over-temp
 785  827           */
 786  828          if (ixgbe->attach_progress & ATTACH_PROGRESS_OVERTEMP_TASKQ) {
 787  829                  ddi_taskq_destroy(ixgbe->overtemp_taskq);
 788  830          }
 789  831  
 790  832          /*
      833 +         * Remove taskq for external PHYs
      834 +         */
      835 +        if (ixgbe->attach_progress & ATTACH_PROGRESS_PHY_TASKQ) {
      836 +                ddi_taskq_destroy(ixgbe->phy_taskq);
      837 +        }
      838 +
      839 +        /*
 791  840           * Remove interrupts
 792  841           */
 793  842          if (ixgbe->attach_progress & ATTACH_PROGRESS_ALLOC_INTR) {
 794  843                  ixgbe_rem_intrs(ixgbe);
 795  844          }
 796  845  
 797  846          /*
 798  847           * Unregister interrupt callback handler
 799  848           */
 800  849          (void) ddi_cb_unregister(ixgbe->cb_hdl);
↓ open down ↓ 149 lines elided ↑ open up ↑
 950  999  
 951 1000          case ixgbe_mac_X540:
 952 1001                  IXGBE_DEBUGLOG_0(ixgbe, "identify X540 adapter\n");
 953 1002                  ixgbe->capab = &ixgbe_X540_cap;
 954 1003                  /*
 955 1004                   * For now, X540 is all set in its capab structure.
 956 1005                   * As other X540 variants show up, things can change here.
 957 1006                   */
 958 1007                  break;
 959 1008  
     1009 +        case ixgbe_mac_X550:
     1010 +        case ixgbe_mac_X550EM_x:
     1011 +                IXGBE_DEBUGLOG_0(ixgbe, "identify X550 adapter\n");
     1012 +                ixgbe->capab = &ixgbe_X550_cap;
     1013 +
     1014 +                if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
     1015 +                        ixgbe->capab->flags |= IXGBE_FLAG_SFP_PLUG_CAPABLE;
     1016 +
     1017 +                /*
     1018 +                 * Link detection on X552 SFP+ and X552/X557-AT
     1019 +                 */
     1020 +                if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP ||
     1021 +                    hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
     1022 +                        ixgbe->capab->other_intr |=
     1023 +                            IXGBE_EIMS_GPI_SDP0_BY_MAC(hw);
     1024 +                        ixgbe->capab->other_gpie |= IXGBE_SDP0_GPIEN_X540;
     1025 +                }
     1026 +                break;
     1027 +
 960 1028          default:
 961 1029                  IXGBE_DEBUGLOG_1(ixgbe,
 962 1030                      "adapter not supported in ixgbe_identify_hardware(): %d\n",
 963 1031                      hw->mac.type);
 964 1032                  return (IXGBE_FAILURE);
 965 1033          }
 966 1034  
 967 1035          return (IXGBE_SUCCESS);
 968 1036  }
 969 1037  
↓ open down ↓ 34 lines elided ↑ open up ↑
1004 1072   * ixgbe_init_properties - Initialize driver properties.
1005 1073   */
1006 1074  static void
1007 1075  ixgbe_init_properties(ixgbe_t *ixgbe)
1008 1076  {
1009 1077          /*
1010 1078           * Get conf file properties, including link settings
1011 1079           * jumbo frames, ring number, descriptor number, etc.
1012 1080           */
1013 1081          ixgbe_get_conf(ixgbe);
1014      -
1015      -        ixgbe_init_params(ixgbe);
1016 1082  }
1017 1083  
1018 1084  /*
1019 1085   * ixgbe_init_driver_settings - Initialize driver settings.
1020 1086   *
1021 1087   * The settings include hardware function pointers, bus information,
1022 1088   * rx/tx rings settings, link state, and any other parameters that
1023 1089   * need to be setup during driver initialization.
1024 1090   */
1025 1091  static int
↓ open down ↓ 214 lines elided ↑ open up ↑
1240 1306  }
1241 1307  
1242 1308  /*
1243 1309   * ixgbe_init - Initialize the device.
1244 1310   */
1245 1311  static int
1246 1312  ixgbe_init(ixgbe_t *ixgbe)
1247 1313  {
1248 1314          struct ixgbe_hw *hw = &ixgbe->hw;
1249 1315          u8 pbanum[IXGBE_PBANUM_LENGTH];
     1316 +        int rv;
1250 1317  
1251 1318          mutex_enter(&ixgbe->gen_lock);
1252 1319  
1253 1320          /*
1254      -         * Reset chipset to put the hardware in a known state
1255      -         * before we try to do anything with the eeprom.
     1321 +         * Configure/Initialize hardware
1256 1322           */
1257      -        if (ixgbe_reset_hw(hw) != IXGBE_SUCCESS) {
1258      -                ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
1259      -                goto init_fail;
     1323 +        rv = ixgbe_init_hw(hw);
     1324 +        if (rv != IXGBE_SUCCESS) {
     1325 +                switch (rv) {
     1326 +
     1327 +                /*
     1328 +                 * The first three errors are not prohibitive to us progressing
     1329 +                 * further, and are maily advisory in nature. In the case of a
     1330 +                 * SFP module not being present or not deemed supported by the
     1331 +                 * common code, we adivse the operator of this fact but carry on
     1332 +                 * instead of failing hard, as SFPs can be inserted or replaced
     1333 +                 * while the driver is running. In the case of a unknown error,
     1334 +                 * we fail-hard, logging the reason and emitting a FMA event.
     1335 +                 */
     1336 +                case IXGBE_ERR_EEPROM_VERSION:
     1337 +                        ixgbe_error(ixgbe,
     1338 +                            "This Intel 10Gb Ethernet device is pre-release and"
     1339 +                            " contains outdated firmware. Please contact your"
     1340 +                            " hardware vendor for a replacement.");
     1341 +                        break;
     1342 +                case IXGBE_ERR_SFP_NOT_PRESENT:
     1343 +                        ixgbe_error(ixgbe,
     1344 +                            "No SFP+ module detected on this interface. Please "
     1345 +                            "install a supported SFP+ module for this "
     1346 +                            "interface to become operational.");
     1347 +                        break;
     1348 +                case IXGBE_ERR_SFP_NOT_SUPPORTED:
     1349 +                        ixgbe_error(ixgbe,
     1350 +                            "Unsupported SFP+ module detected. Please replace "
     1351 +                            "it with a supported SFP+ module per Intel "
     1352 +                            "documentation, or bypass this check with "
     1353 +                            "allow_unsupported_sfp=1 in ixgbe.conf.");
     1354 +                        break;
     1355 +                default:
     1356 +                        ixgbe_error(ixgbe,
     1357 +                            "Failed to initialize hardware. ixgbe_init_hw "
     1358 +                            "returned %d", rv);
     1359 +                        ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
     1360 +                        goto init_fail;
     1361 +                }
1260 1362          }
1261 1363  
1262 1364          /*
1263 1365           * Need to init eeprom before validating the checksum.
1264 1366           */
1265 1367          if (ixgbe_init_eeprom_params(hw) < 0) {
1266 1368                  ixgbe_error(ixgbe,
1267 1369                      "Unable to intitialize the eeprom interface.");
1268 1370                  ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
1269 1371                  goto init_fail;
↓ open down ↓ 20 lines elided ↑ open up ↑
1290 1392          /*
1291 1393           * Setup default flow control thresholds - enable/disable
1292 1394           * & flow control type is controlled by ixgbe.conf
1293 1395           */
1294 1396          hw->fc.high_water[0] = DEFAULT_FCRTH;
1295 1397          hw->fc.low_water[0] = DEFAULT_FCRTL;
1296 1398          hw->fc.pause_time = DEFAULT_FCPAUSE;
1297 1399          hw->fc.send_xon = B_TRUE;
1298 1400  
1299 1401          /*
     1402 +         * Initialize flow control
     1403 +         */
     1404 +        (void) ixgbe_start_hw(hw);
     1405 +
     1406 +        /*
1300 1407           * Initialize link settings
1301 1408           */
1302 1409          (void) ixgbe_driver_setup_link(ixgbe, B_FALSE);
1303 1410  
1304 1411          /*
1305 1412           * Initialize the chipset hardware
1306 1413           */
1307 1414          if (ixgbe_chip_start(ixgbe) != IXGBE_SUCCESS) {
1308 1415                  ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
1309 1416                  goto init_fail;
↓ open down ↓ 27 lines elided ↑ open up ↑
1337 1444          return (IXGBE_FAILURE);
1338 1445  }
1339 1446  
1340 1447  /*
1341 1448   * ixgbe_chip_start - Initialize and start the chipset hardware.
1342 1449   */
1343 1450  static int
1344 1451  ixgbe_chip_start(ixgbe_t *ixgbe)
1345 1452  {
1346 1453          struct ixgbe_hw *hw = &ixgbe->hw;
1347      -        int ret_val, i;
     1454 +        int i;
1348 1455  
1349 1456          ASSERT(mutex_owned(&ixgbe->gen_lock));
1350 1457  
1351 1458          /*
1352 1459           * Get the mac address
1353 1460           * This function should handle SPARC case correctly.
1354 1461           */
1355 1462          if (!ixgbe_find_mac_address(ixgbe)) {
1356 1463                  ixgbe_error(ixgbe, "Failed to get the mac address");
1357 1464                  return (IXGBE_FAILURE);
↓ open down ↓ 2 lines elided ↑ open up ↑
1360 1467          /*
1361 1468           * Validate the mac address
1362 1469           */
1363 1470          (void) ixgbe_init_rx_addrs(hw);
1364 1471          if (!is_valid_mac_addr(hw->mac.addr)) {
1365 1472                  ixgbe_error(ixgbe, "Invalid mac address");
1366 1473                  return (IXGBE_FAILURE);
1367 1474          }
1368 1475  
1369 1476          /*
1370      -         * Configure/Initialize hardware
1371      -         */
1372      -        ret_val = ixgbe_init_hw(hw);
1373      -        if (ret_val != IXGBE_SUCCESS) {
1374      -                if (ret_val == IXGBE_ERR_EEPROM_VERSION) {
1375      -                        ixgbe_error(ixgbe,
1376      -                            "This 82599 device is pre-release and contains"
1377      -                            " outdated firmware, please contact your hardware"
1378      -                            " vendor for a replacement.");
1379      -                } else {
1380      -                        ixgbe_error(ixgbe, "Failed to initialize hardware");
1381      -                        return (IXGBE_FAILURE);
1382      -                }
1383      -        }
1384      -
1385      -        /*
1386 1477           * Re-enable relaxed ordering for performance.  It is disabled
1387 1478           * by default in the hardware init.
1388 1479           */
1389 1480          if (ixgbe->relax_order_enable == B_TRUE)
1390 1481                  ixgbe_enable_relaxed_ordering(hw);
1391 1482  
1392 1483          /*
1393 1484           * Setup adapter interrupt vectors
1394 1485           */
1395 1486          ixgbe_setup_adapter_vector(ixgbe);
↓ open down ↓ 9 lines elided ↑ open up ↑
1405 1496          ixgbe_setup_multicst(ixgbe);
1406 1497  
1407 1498          /*
1408 1499           * Set interrupt throttling rate
1409 1500           */
1410 1501          for (i = 0; i < ixgbe->intr_cnt; i++) {
1411 1502                  IXGBE_WRITE_REG(hw, IXGBE_EITR(i), ixgbe->intr_throttling[i]);
1412 1503          }
1413 1504  
1414 1505          /*
1415      -         * Save the state of the phy
     1506 +         * Disable Wake-on-LAN
1416 1507           */
     1508 +        IXGBE_WRITE_REG(hw, IXGBE_WUC, 0);
     1509 +
     1510 +        /*
     1511 +         * Some adapters offer Energy Efficient Ethernet (EEE) support.
     1512 +         * Due to issues with EEE in e1000g/igb, we disable this by default
     1513 +         * as a precautionary measure.
     1514 +         *
     1515 +         * Currently, the only known adapter which supports EEE in the ixgbe
     1516 +         * line is 8086,15AB (IXGBE_DEV_ID_X550EM_X_KR), and only after the
     1517 +         * first revision of it, as well as any X550 with MAC type 6 (non-EM)
     1518 +         */
     1519 +        (void) ixgbe_setup_eee(hw, B_FALSE);
     1520 +
     1521 +        /*
     1522 +         * Turn on any present SFP Tx laser
     1523 +         */
     1524 +        ixgbe_enable_tx_laser(hw);
     1525 +
     1526 +        /*
     1527 +         * Power on the PHY
     1528 +         */
     1529 +        (void) ixgbe_set_phy_power(hw, B_TRUE);
     1530 +
     1531 +        /*
     1532 +         * Save the state of the PHY
     1533 +         */
1417 1534          ixgbe_get_hw_state(ixgbe);
1418 1535  
1419 1536          /*
1420 1537           * Make sure driver has control
1421 1538           */
1422 1539          ixgbe_get_driver_control(hw);
1423 1540  
1424 1541          return (IXGBE_SUCCESS);
1425 1542  }
1426 1543  
1427 1544  /*
1428 1545   * ixgbe_chip_stop - Stop the chipset hardware
1429 1546   */
1430 1547  static void
1431 1548  ixgbe_chip_stop(ixgbe_t *ixgbe)
1432 1549  {
1433 1550          struct ixgbe_hw *hw = &ixgbe->hw;
     1551 +        int rv;
1434 1552  
1435 1553          ASSERT(mutex_owned(&ixgbe->gen_lock));
1436 1554  
1437 1555          /*
1438      -         * Tell firmware driver is no longer in control
     1556 +         * Stop interupt generation and disable Tx unit
1439 1557           */
1440      -        ixgbe_release_driver_control(hw);
     1558 +        hw->adapter_stopped = B_FALSE;
     1559 +        (void) ixgbe_stop_adapter(hw);
1441 1560  
1442 1561          /*
1443 1562           * Reset the chipset
1444 1563           */
1445 1564          (void) ixgbe_reset_hw(hw);
1446 1565  
1447 1566          /*
1448 1567           * Reset PHY
1449 1568           */
1450 1569          (void) ixgbe_reset_phy(hw);
     1570 +
     1571 +        /*
     1572 +         * Enter LPLU (Low Power, Link Up) mode, if available. Avoid resetting
     1573 +         * the PHY while doing so. Else, just power down the PHY.
     1574 +         */
     1575 +        if (hw->phy.ops.enter_lplu != NULL) {
     1576 +                hw->phy.reset_disable = B_TRUE;
     1577 +                rv = hw->phy.ops.enter_lplu(hw);
     1578 +                if (rv != IXGBE_SUCCESS)
     1579 +                        ixgbe_error(ixgbe, "Error while entering LPLU: %d", rv);
     1580 +                hw->phy.reset_disable = B_FALSE;
     1581 +        } else {
     1582 +                (void) ixgbe_set_phy_power(hw, B_FALSE);
     1583 +        }
     1584 +
     1585 +        /*
     1586 +         * Turn off any present SFP Tx laser
     1587 +         * Expected for health and safety reasons
     1588 +         */
     1589 +        ixgbe_disable_tx_laser(hw);
     1590 +
     1591 +        /*
     1592 +         * Tell firmware driver is no longer in control
     1593 +         */
     1594 +        ixgbe_release_driver_control(hw);
     1595 +
1451 1596  }
1452 1597  
1453 1598  /*
1454 1599   * ixgbe_reset - Reset the chipset and re-start the driver.
1455 1600   *
1456 1601   * It involves stopping and re-starting the chipset,
1457 1602   * and re-configuring the rx/tx rings.
1458 1603   */
1459 1604  static int
1460 1605  ixgbe_reset(ixgbe_t *ixgbe)
↓ open down ↓ 181 lines elided ↑ open up ↑
1642 1787  
1643 1788          return (done);
1644 1789  }
1645 1790  
1646 1791  /*
1647 1792   * ixgbe_start - Start the driver/chipset.
1648 1793   */
1649 1794  int
1650 1795  ixgbe_start(ixgbe_t *ixgbe, boolean_t alloc_buffer)
1651 1796  {
     1797 +        struct ixgbe_hw *hw = &ixgbe->hw;
1652 1798          int i;
1653 1799  
1654 1800          ASSERT(mutex_owned(&ixgbe->gen_lock));
1655 1801  
1656 1802          if (alloc_buffer) {
1657 1803                  if (ixgbe_alloc_rx_data(ixgbe) != IXGBE_SUCCESS) {
1658 1804                          ixgbe_error(ixgbe,
1659 1805                              "Failed to allocate software receive rings");
1660 1806                          return (IXGBE_FAILURE);
1661 1807                  }
↓ open down ↓ 15 lines elided ↑ open up ↑
1677 1823                  mutex_enter(&ixgbe->tx_rings[i].tx_lock);
1678 1824  
1679 1825          /*
1680 1826           * Start the chipset hardware
1681 1827           */
1682 1828          if (ixgbe_chip_start(ixgbe) != IXGBE_SUCCESS) {
1683 1829                  ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
1684 1830                  goto start_failure;
1685 1831          }
1686 1832  
     1833 +        /*
     1834 +         * Configure link now for X550
     1835 +         *
     1836 +         * X550 possesses a LPLU (Low-Power Link Up) mode which keeps the
     1837 +         * resting state of the adapter at a 1Gb FDX speed. Prior to the X550,
     1838 +         * the resting state of the link would be the maximum speed that
     1839 +         * autonegotiation will allow (usually 10Gb, infrastructure allowing)
     1840 +         * so we never bothered with explicitly setting the link to 10Gb as it
     1841 +         * would already be at that state on driver attach. With X550, we must
     1842 +         * trigger a re-negotiation of the link in order to switch from a LPLU
     1843 +         * 1Gb link to 10Gb (cable and link partner permitting.)
     1844 +         */
     1845 +        if (hw->mac.type == ixgbe_mac_X550 ||
     1846 +            hw->mac.type == ixgbe_mac_X550EM_x) {
     1847 +                (void) ixgbe_driver_setup_link(ixgbe, B_TRUE);
     1848 +                ixgbe_get_hw_state(ixgbe);
     1849 +        }
     1850 +
1687 1851          if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
1688 1852                  goto start_failure;
1689 1853          }
1690 1854  
1691 1855          /*
1692 1856           * Setup the rx/tx rings
1693 1857           */
1694 1858          ixgbe_setup_rings(ixgbe);
1695 1859  
1696 1860          /*
↓ open down ↓ 487 lines elided ↑ open up ↑
2184 2348  
2185 2349          /*
2186 2350           * Setup the Receive Descriptor Control Register (RXDCTL)
2187 2351           * PTHRESH=32 descriptors (half the internal cache)
2188 2352           * HTHRESH=0 descriptors (to minimize latency on fetch)
2189 2353           * WTHRESH defaults to 1 (writeback each descriptor)
2190 2354           */
2191 2355          reg_val = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index));
2192 2356          reg_val |= IXGBE_RXDCTL_ENABLE; /* enable queue */
2193 2357  
2194      -        /* Not a valid value for 82599 or X540 */
     2358 +        /* Not a valid value for 82599, X540 or X550 */
2195 2359          if (hw->mac.type == ixgbe_mac_82598EB) {
2196 2360                  reg_val |= 0x0020;      /* pthresh */
2197 2361          }
2198 2362          IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index), reg_val);
2199 2363  
2200 2364          if (hw->mac.type == ixgbe_mac_82599EB ||
2201      -            hw->mac.type == ixgbe_mac_X540) {
     2365 +            hw->mac.type == ixgbe_mac_X540 ||
     2366 +            hw->mac.type == ixgbe_mac_X550 ||
     2367 +            hw->mac.type == ixgbe_mac_X550EM_x) {
2202 2368                  reg_val = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
2203 2369                  reg_val |= (IXGBE_RDRXCTL_CRCSTRIP | IXGBE_RDRXCTL_AGGDIS);
2204 2370                  IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg_val);
2205 2371          }
2206 2372  
2207 2373          /*
2208 2374           * Setup the Split and Replication Receive Control Register.
2209 2375           * Set the rx buffer size and the advanced descriptor type.
2210 2376           */
2211 2377          reg_val = (ixgbe->rx_buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) |
↓ open down ↓ 5 lines elided ↑ open up ↑
2217 2383  static void
2218 2384  ixgbe_setup_rx(ixgbe_t *ixgbe)
2219 2385  {
2220 2386          ixgbe_rx_ring_t *rx_ring;
2221 2387          struct ixgbe_hw *hw = &ixgbe->hw;
2222 2388          uint32_t reg_val;
2223 2389          uint32_t ring_mapping;
2224 2390          uint32_t i, index;
2225 2391          uint32_t psrtype_rss_bit;
2226 2392  
     2393 +        /*
     2394 +         * Ensure that Rx is disabled while setting up
     2395 +         * the Rx unit and Rx descriptor ring(s)
     2396 +         */
     2397 +        ixgbe_disable_rx(hw);
     2398 +
2227 2399          /* PSRTYPE must be configured for 82599 */
2228 2400          if (ixgbe->classify_mode != IXGBE_CLASSIFY_VMDQ &&
2229 2401              ixgbe->classify_mode != IXGBE_CLASSIFY_VMDQ_RSS) {
2230 2402                  reg_val = IXGBE_PSRTYPE_TCPHDR | IXGBE_PSRTYPE_UDPHDR |
2231 2403                      IXGBE_PSRTYPE_IPV4HDR | IXGBE_PSRTYPE_IPV6HDR;
2232 2404                  reg_val |= IXGBE_PSRTYPE_L2HDR;
2233 2405                  reg_val |= 0x80000000;
2234 2406                  IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), reg_val);
2235 2407          } else {
2236 2408                  if (ixgbe->num_rx_groups > 32) {
↓ open down ↓ 4 lines elided ↑ open up ↑
2241 2413                  for (i = 0; i < ixgbe->capab->max_rx_grp_num; i++) {
2242 2414                          reg_val = IXGBE_PSRTYPE_TCPHDR | IXGBE_PSRTYPE_UDPHDR |
2243 2415                              IXGBE_PSRTYPE_IPV4HDR | IXGBE_PSRTYPE_IPV6HDR;
2244 2416                          reg_val |= IXGBE_PSRTYPE_L2HDR;
2245 2417                          reg_val |= psrtype_rss_bit;
2246 2418                          IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(i), reg_val);
2247 2419                  }
2248 2420          }
2249 2421  
2250 2422          /*
2251      -         * Set filter control in FCTRL to accept broadcast packets and do
2252      -         * not pass pause frames to host.  Flow control settings are already
2253      -         * in this register, so preserve them.
     2423 +         * Set filter control in FCTRL to determine types of packets are passed
     2424 +         * up to the driver.
     2425 +         * - Pass broadcast packets.
     2426 +         * - Do not pass flow control pause frames (82598-specific)
2254 2427           */
2255 2428          reg_val = IXGBE_READ_REG(hw, IXGBE_FCTRL);
2256      -        reg_val |= IXGBE_FCTRL_BAM;     /* broadcast accept mode */
2257      -        reg_val |= IXGBE_FCTRL_DPF;     /* discard pause frames */
     2429 +        reg_val |= IXGBE_FCTRL_BAM; /* Broadcast Accept Mode */
     2430 +        if (hw->mac.type == ixgbe_mac_82598EB) {
     2431 +                reg_val |= IXGBE_FCTRL_DPF; /* Discard Pause Frames */
     2432 +        }
2258 2433          IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg_val);
2259 2434  
2260 2435          /*
2261 2436           * Hardware checksum settings
2262 2437           */
2263 2438          if (ixgbe->rx_hcksum_enable) {
2264      -                reg_val = IXGBE_RXCSUM_IPPCSE;  /* IP checksum */
     2439 +                reg_val = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
     2440 +                reg_val |= IXGBE_RXCSUM_IPPCSE; /* IP checksum */
2265 2441                  IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, reg_val);
2266 2442          }
2267 2443  
2268 2444          /*
2269 2445           * Setup VMDq and RSS for multiple receive queues
2270 2446           */
2271 2447          switch (ixgbe->classify_mode) {
2272 2448          case IXGBE_CLASSIFY_RSS:
2273 2449                  /*
2274 2450                   * One group, only RSS is needed when more than
↓ open down ↓ 17 lines elided ↑ open up ↑
2292 2468                   */
2293 2469                  ixgbe_setup_vmdq_rss(ixgbe);
2294 2470                  break;
2295 2471  
2296 2472          default:
2297 2473                  break;
2298 2474          }
2299 2475  
2300 2476          /*
2301 2477           * Enable the receive unit.  This must be done after filter
2302      -         * control is set in FCTRL.
     2478 +         * control is set in FCTRL. On 82598, we disable the descriptor monitor.
     2479 +         * 82598 is the only adapter which defines this RXCTRL option.
2303 2480           */
2304      -        reg_val = (IXGBE_RXCTRL_RXEN    /* Enable Receive Unit */
2305      -            | IXGBE_RXCTRL_DMBYPS);     /* descriptor monitor bypass */
2306      -        IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg_val);
     2481 +        reg_val = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
     2482 +        if (hw->mac.type == ixgbe_mac_82598EB)
     2483 +                reg_val |= IXGBE_RXCTRL_DMBYPS; /* descriptor monitor bypass */
     2484 +        reg_val |= IXGBE_RXCTRL_RXEN;
     2485 +        (void) ixgbe_enable_rx_dma(hw, reg_val);
2307 2486  
2308 2487          /*
2309 2488           * ixgbe_setup_rx_ring must be called after configuring RXCTRL
2310 2489           */
2311 2490          for (i = 0; i < ixgbe->num_rx_rings; i++) {
2312 2491                  rx_ring = &ixgbe->rx_rings[i];
2313 2492                  ixgbe_setup_rx_ring(rx_ring);
2314 2493          }
2315 2494  
2316 2495          /*
↓ open down ↓ 6 lines elided ↑ open up ↑
2323 2502                  ring_mapping |= (i & 0xF) << (8 * (index & 0x3));
2324 2503                  IXGBE_WRITE_REG(hw, IXGBE_RQSMR(index >> 2), ring_mapping);
2325 2504          }
2326 2505  
2327 2506          /*
2328 2507           * The Max Frame Size in MHADD/MAXFRS will be internally increased
2329 2508           * by four bytes if the packet has a VLAN field, so includes MTU,
2330 2509           * ethernet header and frame check sequence.
2331 2510           * Register is MAXFRS in 82599.
2332 2511           */
2333      -        reg_val = (ixgbe->default_mtu + sizeof (struct ether_header)
     2512 +        reg_val = IXGBE_READ_REG(hw, IXGBE_MHADD);
     2513 +        reg_val &= ~IXGBE_MHADD_MFS_MASK;
     2514 +        reg_val |= (ixgbe->default_mtu + sizeof (struct ether_header)
2334 2515              + ETHERFCSL) << IXGBE_MHADD_MFS_SHIFT;
2335 2516          IXGBE_WRITE_REG(hw, IXGBE_MHADD, reg_val);
2336 2517  
2337 2518          /*
2338 2519           * Setup Jumbo Frame enable bit
2339 2520           */
2340      -        if (ixgbe->default_mtu > ETHERMTU) {
2341      -                reg_val = IXGBE_READ_REG(hw, IXGBE_HLREG0);
     2521 +        reg_val = IXGBE_READ_REG(hw, IXGBE_HLREG0);
     2522 +        if (ixgbe->default_mtu > ETHERMTU)
2342 2523                  reg_val |= IXGBE_HLREG0_JUMBOEN;
2343      -                IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_val);
2344      -        }
     2524 +        else
     2525 +                reg_val &= ~IXGBE_HLREG0_JUMBOEN;
     2526 +        IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_val);
2345 2527  
2346 2528          /*
2347 2529           * Setup RSC for multiple receive queues.
2348 2530           */
2349 2531          if (ixgbe->lro_enable) {
2350 2532                  for (i = 0; i < ixgbe->num_rx_rings; i++) {
2351 2533                          /*
2352 2534                           * Make sure rx_buf_size * MAXDESC not greater
2353 2535                           * than 65535.
2354 2536                           * Intel recommends 4 for MAXDESC field value.
↓ open down ↓ 134 lines elided ↑ open up ↑
2489 2671                  ring_mapping |= (i & 0xF) << (8 * (i & 0x3));
2490 2672                  if ((i & 0x3) == 0x3) {
2491 2673                          switch (hw->mac.type) {
2492 2674                          case ixgbe_mac_82598EB:
2493 2675                                  IXGBE_WRITE_REG(hw, IXGBE_TQSMR(i >> 2),
2494 2676                                      ring_mapping);
2495 2677                                  break;
2496 2678  
2497 2679                          case ixgbe_mac_82599EB:
2498 2680                          case ixgbe_mac_X540:
     2681 +                        case ixgbe_mac_X550:
     2682 +                        case ixgbe_mac_X550EM_x:
2499 2683                                  IXGBE_WRITE_REG(hw, IXGBE_TQSM(i >> 2),
2500 2684                                      ring_mapping);
2501 2685                                  break;
2502 2686  
2503 2687                          default:
2504 2688                                  break;
2505 2689                          }
2506 2690  
2507 2691                          ring_mapping = 0;
2508 2692                  }
2509 2693          }
2510 2694          if (i & 0x3) {
2511 2695                  switch (hw->mac.type) {
2512 2696                  case ixgbe_mac_82598EB:
2513 2697                          IXGBE_WRITE_REG(hw, IXGBE_TQSMR(i >> 2), ring_mapping);
2514 2698                          break;
2515 2699  
2516 2700                  case ixgbe_mac_82599EB:
2517 2701                  case ixgbe_mac_X540:
     2702 +                case ixgbe_mac_X550:
     2703 +                case ixgbe_mac_X550EM_x:
2518 2704                          IXGBE_WRITE_REG(hw, IXGBE_TQSM(i >> 2), ring_mapping);
2519 2705                          break;
2520 2706  
2521 2707                  default:
2522 2708                          break;
2523 2709                  }
2524 2710          }
2525 2711  
2526 2712          /*
2527 2713           * Enable CRC appending and TX padding (for short tx frames)
2528 2714           */
2529 2715          reg_val = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2530 2716          reg_val |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_TXPADEN;
2531 2717          IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_val);
2532 2718  
2533 2719          /*
2534      -         * enable DMA for 82599 and X540 parts
     2720 +         * enable DMA for 82599, X540 and X550 parts
2535 2721           */
2536 2722          if (hw->mac.type == ixgbe_mac_82599EB ||
2537      -            hw->mac.type == ixgbe_mac_X540) {
     2723 +            hw->mac.type == ixgbe_mac_X540 ||
     2724 +            hw->mac.type == ixgbe_mac_X550 ||
     2725 +            hw->mac.type == ixgbe_mac_X550EM_x) {
2538 2726                  /* DMATXCTL.TE must be set after all Tx config is complete */
2539 2727                  reg_val = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2540 2728                  reg_val |= IXGBE_DMATXCTL_TE;
2541 2729                  IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg_val);
2542 2730  
2543 2731                  /* Disable arbiter to set MTQC */
2544 2732                  reg_val = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
2545 2733                  reg_val |= IXGBE_RTTDCS_ARBDIS;
2546 2734                  IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg_val);
2547 2735                  IXGBE_WRITE_REG(hw, IXGBE_MTQC, IXGBE_MTQC_64Q_1PB);
↓ open down ↓ 13 lines elided ↑ open up ↑
2561 2749          }
2562 2750  }
2563 2751  
2564 2752  /*
2565 2753   * ixgbe_setup_rss - Setup receive-side scaling feature.
2566 2754   */
2567 2755  static void
2568 2756  ixgbe_setup_rss(ixgbe_t *ixgbe)
2569 2757  {
2570 2758          struct ixgbe_hw *hw = &ixgbe->hw;
2571      -        uint32_t i, mrqc, rxcsum;
2572      -        uint32_t random;
2573      -        uint32_t reta;
2574      -        uint32_t ring_per_group;
     2759 +        uint32_t mrqc;
2575 2760  
2576 2761          /*
2577      -         * Fill out redirection table
     2762 +         * Initialize RETA/ERETA table
2578 2763           */
2579      -        reta = 0;
2580      -        ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
     2764 +        ixgbe_setup_rss_table(ixgbe);
2581 2765  
2582      -        for (i = 0; i < 128; i++) {
2583      -                reta = (reta << 8) | (i % ring_per_group) |
2584      -                    ((i % ring_per_group) << 4);
2585      -                if ((i & 3) == 3)
2586      -                        IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
2587      -        }
2588      -
2589 2766          /*
2590      -         * Fill out hash function seeds with a random constant
2591      -         */
2592      -        for (i = 0; i < 10; i++) {
2593      -                (void) random_get_pseudo_bytes((uint8_t *)&random,
2594      -                    sizeof (uint32_t));
2595      -                IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), random);
2596      -        }
2597      -
2598      -        /*
2599 2767           * Enable RSS & perform hash on these packet types
2600 2768           */
2601 2769          mrqc = IXGBE_MRQC_RSSEN |
2602 2770              IXGBE_MRQC_RSS_FIELD_IPV4 |
2603 2771              IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
2604 2772              IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
2605 2773              IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP |
2606 2774              IXGBE_MRQC_RSS_FIELD_IPV6_EX |
2607 2775              IXGBE_MRQC_RSS_FIELD_IPV6 |
2608 2776              IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
2609 2777              IXGBE_MRQC_RSS_FIELD_IPV6_UDP |
2610 2778              IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
2611 2779          IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
2612      -
2613      -        /*
2614      -         * Disable Packet Checksum to enable RSS for multiple receive queues.
2615      -         * It is an adapter hardware limitation that Packet Checksum is
2616      -         * mutually exclusive with RSS.
2617      -         */
2618      -        rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
2619      -        rxcsum |= IXGBE_RXCSUM_PCSD;
2620      -        rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
2621      -        IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
2622 2780  }
2623 2781  
2624 2782  /*
2625 2783   * ixgbe_setup_vmdq - Setup MAC classification feature
2626 2784   */
2627 2785  static void
2628 2786  ixgbe_setup_vmdq(ixgbe_t *ixgbe)
2629 2787  {
2630 2788          struct ixgbe_hw *hw = &ixgbe->hw;
2631 2789          uint32_t vmdctl, i, vtctl;
↓ open down ↓ 8 lines elided ↑ open up ↑
2640 2798                   * VMDq Enable = 1;
2641 2799                   * VMDq Filter = 0; MAC filtering
2642 2800                   * Default VMDq output index = 0;
2643 2801                   */
2644 2802                  vmdctl = IXGBE_VMD_CTL_VMDQ_EN;
2645 2803                  IXGBE_WRITE_REG(hw, IXGBE_VMD_CTL, vmdctl);
2646 2804                  break;
2647 2805  
2648 2806          case ixgbe_mac_82599EB:
2649 2807          case ixgbe_mac_X540:
     2808 +        case ixgbe_mac_X550:
     2809 +        case ixgbe_mac_X550EM_x:
2650 2810                  /*
2651 2811                   * Enable VMDq-only.
2652 2812                   */
2653 2813                  vmdctl = IXGBE_MRQC_VMDQEN;
2654 2814                  IXGBE_WRITE_REG(hw, IXGBE_MRQC, vmdctl);
2655 2815  
2656 2816                  for (i = 0; i < hw->mac.num_rar_entries; i++) {
2657 2817                          IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(i), 0);
2658 2818                          IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(i), 0);
2659 2819                  }
↓ open down ↓ 16 lines elided ↑ open up ↑
2676 2836          }
2677 2837  }
2678 2838  
2679 2839  /*
2680 2840   * ixgbe_setup_vmdq_rss - Setup both vmdq feature and rss feature.
2681 2841   */
2682 2842  static void
2683 2843  ixgbe_setup_vmdq_rss(ixgbe_t *ixgbe)
2684 2844  {
2685 2845          struct ixgbe_hw *hw = &ixgbe->hw;
2686      -        uint32_t i, mrqc, rxcsum;
2687      -        uint32_t random;
2688      -        uint32_t reta;
2689      -        uint32_t ring_per_group;
2690      -        uint32_t vmdctl, vtctl;
     2846 +        uint32_t i, mrqc;
     2847 +        uint32_t vtctl, vmdctl;
2691 2848  
2692 2849          /*
2693      -         * Fill out redirection table
     2850 +         * Initialize RETA/ERETA table
2694 2851           */
2695      -        reta = 0;
2696      -        ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
2697      -        for (i = 0; i < 128; i++) {
2698      -                reta = (reta << 8) | (i % ring_per_group) |
2699      -                    ((i % ring_per_group) << 4);
2700      -                if ((i & 3) == 3)
2701      -                        IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
2702      -        }
     2852 +        ixgbe_setup_rss_table(ixgbe);
2703 2853  
2704 2854          /*
2705      -         * Fill out hash function seeds with a random constant
2706      -         */
2707      -        for (i = 0; i < 10; i++) {
2708      -                (void) random_get_pseudo_bytes((uint8_t *)&random,
2709      -                    sizeof (uint32_t));
2710      -                IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), random);
2711      -        }
2712      -
2713      -        /*
2714 2855           * Enable and setup RSS and VMDq
2715 2856           */
2716 2857          switch (hw->mac.type) {
2717 2858          case ixgbe_mac_82598EB:
2718 2859                  /*
2719 2860                   * Enable RSS & Setup RSS Hash functions
2720 2861                   */
2721 2862                  mrqc = IXGBE_MRQC_RSSEN |
2722 2863                      IXGBE_MRQC_RSS_FIELD_IPV4 |
2723 2864                      IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
↓ open down ↓ 10 lines elided ↑ open up ↑
2734 2875                   * Enable and Setup VMDq
2735 2876                   * VMDq Filter = 0; MAC filtering
2736 2877                   * Default VMDq output index = 0;
2737 2878                   */
2738 2879                  vmdctl = IXGBE_VMD_CTL_VMDQ_EN;
2739 2880                  IXGBE_WRITE_REG(hw, IXGBE_VMD_CTL, vmdctl);
2740 2881                  break;
2741 2882  
2742 2883          case ixgbe_mac_82599EB:
2743 2884          case ixgbe_mac_X540:
     2885 +        case ixgbe_mac_X550:
     2886 +        case ixgbe_mac_X550EM_x:
2744 2887                  /*
2745 2888                   * Enable RSS & Setup RSS Hash functions
2746 2889                   */
2747 2890                  mrqc = IXGBE_MRQC_RSS_FIELD_IPV4 |
2748 2891                      IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
2749 2892                      IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
2750 2893                      IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP |
2751 2894                      IXGBE_MRQC_RSS_FIELD_IPV6_EX |
2752 2895                      IXGBE_MRQC_RSS_FIELD_IPV6 |
2753 2896                      IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
↓ open down ↓ 15 lines elided ↑ open up ↑
2769 2912                          IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(i), 0);
2770 2913                          IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(i), 0);
2771 2914                  }
2772 2915                  break;
2773 2916  
2774 2917          default:
2775 2918                  break;
2776 2919  
2777 2920          }
2778 2921  
2779      -        /*
2780      -         * Disable Packet Checksum to enable RSS for multiple receive queues.
2781      -         * It is an adapter hardware limitation that Packet Checksum is
2782      -         * mutually exclusive with RSS.
2783      -         */
2784      -        rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
2785      -        rxcsum |= IXGBE_RXCSUM_PCSD;
2786      -        rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
2787      -        IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
2788      -
2789 2922          if (hw->mac.type == ixgbe_mac_82599EB ||
2790      -            hw->mac.type == ixgbe_mac_X540) {
     2923 +            hw->mac.type == ixgbe_mac_X540 ||
     2924 +            hw->mac.type == ixgbe_mac_X550 ||
     2925 +            hw->mac.type == ixgbe_mac_X550EM_x) {
2791 2926                  /*
2792 2927                   * Enable Virtualization and Replication.
2793 2928                   */
2794 2929                  vtctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
2795 2930                  IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vtctl);
2796 2931  
2797 2932                  /*
2798 2933                   * Enable receiving packets to all VFs
2799 2934                   */
2800 2935                  IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), IXGBE_VFRE_ENABLE_ALL);
2801 2936                  IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), IXGBE_VFRE_ENABLE_ALL);
2802 2937          }
2803 2938  }
2804 2939  
2805 2940  /*
     2941 + * ixgbe_setup_rss_table - Setup RSS table
     2942 + */
     2943 +static void
     2944 +ixgbe_setup_rss_table(ixgbe_t *ixgbe)
     2945 +{
     2946 +        struct ixgbe_hw *hw = &ixgbe->hw;
     2947 +        uint32_t i, j;
     2948 +        uint32_t random;
     2949 +        uint32_t reta;
     2950 +        uint32_t ring_per_group;
     2951 +        uint32_t ring;
     2952 +        uint32_t table_size;
     2953 +        uint32_t index_mult;
     2954 +        uint32_t rxcsum;
     2955 +
     2956 +        /*
     2957 +         * Set multiplier for RETA setup and table size based on MAC type.
     2958 +         * RETA table sizes vary by model:
     2959 +         *
     2960 +         * 82598, 82599, X540: 128 table entries.
     2961 +         * X550: 512 table entries.
     2962 +         */
     2963 +        index_mult = 0x1;
     2964 +        table_size = 128;
     2965 +        switch (ixgbe->hw.mac.type) {
     2966 +        case ixgbe_mac_82598EB:
     2967 +                index_mult = 0x11;
     2968 +                break;
     2969 +        case ixgbe_mac_X550:
     2970 +        case ixgbe_mac_X550EM_x:
     2971 +                table_size = 512;
     2972 +                break;
     2973 +        default:
     2974 +                break;
     2975 +        }
     2976 +
     2977 +        /*
     2978 +         * Fill out RSS redirection table. The configuation of the indices is
     2979 +         * hardware-dependent.
     2980 +         *
     2981 +         *  82598: 8 bits wide containing two 4 bit RSS indices
     2982 +         *  82599, X540: 8 bits wide containing one 4 bit RSS index
     2983 +         *  X550: 8 bits wide containing one 6 bit RSS index
     2984 +         */
     2985 +        reta = 0;
     2986 +        ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
     2987 +
     2988 +        for (i = 0, j = 0; i < table_size; i++, j++) {
     2989 +                if (j == ring_per_group) j = 0;
     2990 +
     2991 +                /*
     2992 +                 * The low 8 bits are for hash value (n+0);
     2993 +                 * The next 8 bits are for hash value (n+1), etc.
     2994 +                 */
     2995 +                ring = (j * index_mult);
     2996 +                reta = reta >> 8;
     2997 +                reta = reta | (((uint32_t)ring) << 24);
     2998 +
     2999 +                if ((i & 3) == 3)
     3000 +                        /*
     3001 +                         * The first 128 table entries are programmed into the
     3002 +                         * RETA register, with any beyond that (eg; on X550)
     3003 +                         * into ERETA.
     3004 +                         */
     3005 +                        if (i < 128)
     3006 +                                IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
     3007 +                        else
     3008 +                                IXGBE_WRITE_REG(hw, IXGBE_ERETA((i >> 2) - 32),
     3009 +                                    reta);
     3010 +                        reta = 0;
     3011 +        }
     3012 +
     3013 +        /*
     3014 +         * Fill out hash function seeds with a random constant
     3015 +         */
     3016 +        for (i = 0; i < 10; i++) {
     3017 +                (void) random_get_pseudo_bytes((uint8_t *)&random,
     3018 +                    sizeof (uint32_t));
     3019 +                IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), random);
     3020 +        }
     3021 +
     3022 +        /*
     3023 +         * Disable Packet Checksum to enable RSS for multiple receive queues.
     3024 +         * It is an adapter hardware limitation that Packet Checksum is
     3025 +         * mutually exclusive with RSS.
     3026 +         */
     3027 +        rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
     3028 +        rxcsum |= IXGBE_RXCSUM_PCSD;
     3029 +        rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
     3030 +        IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
     3031 +}
     3032 +
     3033 +/*
2806 3034   * ixgbe_init_unicst - Initialize the unicast addresses.
2807 3035   */
2808 3036  static void
2809 3037  ixgbe_init_unicst(ixgbe_t *ixgbe)
2810 3038  {
2811 3039          struct ixgbe_hw *hw = &ixgbe->hw;
2812 3040          uint8_t *mac_addr;
2813 3041          int slot;
2814 3042          /*
2815 3043           * Here we should consider two situations:
↓ open down ↓ 176 lines elided ↑ open up ↑
2992 3220                          ixgbe->num_rx_rings = ixgbe->num_rx_groups;
2993 3221                  } else {
2994 3222                          ixgbe->num_rx_rings = ixgbe->num_rx_groups *
2995 3223                              min(8, ring_per_group);
2996 3224                  }
2997 3225  
2998 3226                  break;
2999 3227  
3000 3228          case ixgbe_mac_82599EB:
3001 3229          case ixgbe_mac_X540:
     3230 +        case ixgbe_mac_X550:
     3231 +        case ixgbe_mac_X550EM_x:
3002 3232                  /*
3003 3233                   * 82599 supports the following combination:
3004 3234                   * vmdq no. x rss no.
3005 3235                   * [33..64] x [1..2]
3006 3236                   * [2..32]  x [1..4]
3007 3237                   * 1 x [1..16]
3008 3238                   * However 8 rss queue per pool (vmdq) is sufficient for
3009 3239                   * most cases.
3010 3240                   *
3011      -                 * For now, treat X540 like the 82599.
     3241 +                 * For now, treat X540 and X550 like the 82599.
3012 3242                   */
3013 3243                  ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
3014 3244                  if (ixgbe->num_rx_groups == 1) {
3015 3245                          ixgbe->num_rx_rings = min(8, ring_per_group);
3016 3246                  } else if (ixgbe->num_rx_groups <= 32) {
3017 3247                          ixgbe->num_rx_rings = ixgbe->num_rx_groups *
3018 3248                              min(4, ring_per_group);
3019 3249                  } else if (ixgbe->num_rx_groups <= 64) {
3020 3250                          ixgbe->num_rx_rings = ixgbe->num_rx_groups *
3021 3251                              min(2, ring_per_group);
↓ open down ↓ 142 lines elided ↑ open up ↑
3164 3394              0, 1, DEFAULT_RX_HCKSUM_ENABLE);
3165 3395          ixgbe->lso_enable = ixgbe_get_prop(ixgbe, PROP_LSO_ENABLE,
3166 3396              0, 1, DEFAULT_LSO_ENABLE);
3167 3397          ixgbe->lro_enable = ixgbe_get_prop(ixgbe, PROP_LRO_ENABLE,
3168 3398              0, 1, DEFAULT_LRO_ENABLE);
3169 3399          ixgbe->tx_head_wb_enable = ixgbe_get_prop(ixgbe, PROP_TX_HEAD_WB_ENABLE,
3170 3400              0, 1, DEFAULT_TX_HEAD_WB_ENABLE);
3171 3401          ixgbe->relax_order_enable = ixgbe_get_prop(ixgbe,
3172 3402              PROP_RELAX_ORDER_ENABLE, 0, 1, DEFAULT_RELAX_ORDER_ENABLE);
3173 3403  
3174      -        /* Head Write Back not recommended for 82599 and X540 */
     3404 +        /* Head Write Back not recommended for 82599, X540 and X550 */
3175 3405          if (hw->mac.type == ixgbe_mac_82599EB ||
3176      -            hw->mac.type == ixgbe_mac_X540) {
     3406 +            hw->mac.type == ixgbe_mac_X540 ||
     3407 +            hw->mac.type == ixgbe_mac_X550 ||
     3408 +            hw->mac.type == ixgbe_mac_X550EM_x) {
3177 3409                  ixgbe->tx_head_wb_enable = B_FALSE;
3178 3410          }
3179 3411  
3180 3412          /*
3181 3413           * ixgbe LSO needs the tx h/w checksum support.
3182 3414           * LSO will be disabled if tx h/w checksum is not
3183 3415           * enabled.
3184 3416           */
3185 3417          if (ixgbe->tx_hcksum_enable == B_FALSE) {
3186 3418                  ixgbe->lso_enable = B_FALSE;
↓ open down ↓ 2 lines elided ↑ open up ↑
3189 3421          /*
3190 3422           * ixgbe LRO needs the rx h/w checksum support.
3191 3423           * LRO will be disabled if rx h/w checksum is not
3192 3424           * enabled.
3193 3425           */
3194 3426          if (ixgbe->rx_hcksum_enable == B_FALSE) {
3195 3427                  ixgbe->lro_enable = B_FALSE;
3196 3428          }
3197 3429  
3198 3430          /*
3199      -         * ixgbe LRO only been supported by 82599 and X540 now
     3431 +         * ixgbe LRO only supported by 82599, X540 and X550
3200 3432           */
3201 3433          if (hw->mac.type == ixgbe_mac_82598EB) {
3202 3434                  ixgbe->lro_enable = B_FALSE;
3203 3435          }
3204 3436          ixgbe->tx_copy_thresh = ixgbe_get_prop(ixgbe, PROP_TX_COPY_THRESHOLD,
3205 3437              MIN_TX_COPY_THRESHOLD, MAX_TX_COPY_THRESHOLD,
3206 3438              DEFAULT_TX_COPY_THRESHOLD);
3207 3439          ixgbe->tx_recycle_thresh = ixgbe_get_prop(ixgbe,
3208 3440              PROP_TX_RECYCLE_THRESHOLD, MIN_TX_RECYCLE_THRESHOLD,
3209 3441              MAX_TX_RECYCLE_THRESHOLD, DEFAULT_TX_RECYCLE_THRESHOLD);
↓ open down ↓ 9 lines elided ↑ open up ↑
3219 3451              DEFAULT_RX_COPY_THRESHOLD);
3220 3452          ixgbe->rx_limit_per_intr = ixgbe_get_prop(ixgbe, PROP_RX_LIMIT_PER_INTR,
3221 3453              MIN_RX_LIMIT_PER_INTR, MAX_RX_LIMIT_PER_INTR,
3222 3454              DEFAULT_RX_LIMIT_PER_INTR);
3223 3455  
3224 3456          ixgbe->intr_throttling[0] = ixgbe_get_prop(ixgbe, PROP_INTR_THROTTLING,
3225 3457              ixgbe->capab->min_intr_throttle,
3226 3458              ixgbe->capab->max_intr_throttle,
3227 3459              ixgbe->capab->def_intr_throttle);
3228 3460          /*
3229      -         * 82599 and X540 require the interrupt throttling rate is
3230      -         * a multiple of 8. This is enforced by the register
3231      -         * definiton.
     3461 +         * 82599, X540 and X550 require the interrupt throttling rate is
     3462 +         * a multiple of 8. This is enforced by the register definiton.
3232 3463           */
3233      -        if (hw->mac.type == ixgbe_mac_82599EB || hw->mac.type == ixgbe_mac_X540)
     3464 +        if (hw->mac.type == ixgbe_mac_82599EB ||
     3465 +            hw->mac.type == ixgbe_mac_X540 ||
     3466 +            hw->mac.type == ixgbe_mac_X550 ||
     3467 +            hw->mac.type == ixgbe_mac_X550EM_x)
3234 3468                  ixgbe->intr_throttling[0] = ixgbe->intr_throttling[0] & 0xFF8;
3235 3469  
3236 3470          hw->allow_unsupported_sfp = ixgbe_get_prop(ixgbe,
3237 3471              PROP_ALLOW_UNSUPPORTED_SFP, 0, 1, DEFAULT_ALLOW_UNSUPPORTED_SFP);
3238 3472  }
3239 3473  
3240 3474  static void
3241 3475  ixgbe_init_params(ixgbe_t *ixgbe)
3242 3476  {
3243      -        ixgbe->param_en_10000fdx_cap = 1;
3244      -        ixgbe->param_en_1000fdx_cap = 1;
3245      -        ixgbe->param_en_100fdx_cap = 1;
3246      -        ixgbe->param_adv_10000fdx_cap = 1;
3247      -        ixgbe->param_adv_1000fdx_cap = 1;
3248      -        ixgbe->param_adv_100fdx_cap = 1;
     3477 +        struct ixgbe_hw *hw = &ixgbe->hw;
     3478 +        ixgbe_link_speed speeds_supported = 0;
     3479 +        boolean_t negotiate;
3249 3480  
     3481 +        /*
     3482 +         * Get a list of speeds the adapter supports. If the hw struct hasn't
     3483 +         * been populated with this information yet, retrieve it from the
     3484 +         * adapter and save it to our own variable.
     3485 +         *
     3486 +         * On certain adapters, such as ones which use SFPs, the contents of
     3487 +         * hw->phy.speeds_supported (and hw->phy.autoneg_advertised) are not
     3488 +         * updated, so we must rely on calling ixgbe_get_link_capabilities()
     3489 +         * in order to ascertain the speeds which we are capable of supporting,
     3490 +         * and in the case of SFP-equipped adapters, which speed we are
     3491 +         * advertising. If ixgbe_get_link_capabilities() fails for some reason,
     3492 +         * we'll go with a default list of speeds as a last resort.
     3493 +         */
     3494 +        speeds_supported = hw->phy.speeds_supported;
     3495 +
     3496 +        if (speeds_supported == 0) {
     3497 +                if (ixgbe_get_link_capabilities(hw, &speeds_supported,
     3498 +                    &negotiate) != IXGBE_SUCCESS) {
     3499 +                        if (hw->mac.type == ixgbe_mac_82598EB) {
     3500 +                                speeds_supported =
     3501 +                                    IXGBE_LINK_SPEED_82598_AUTONEG;
     3502 +                        } else {
     3503 +                                speeds_supported =
     3504 +                                    IXGBE_LINK_SPEED_82599_AUTONEG;
     3505 +                        }
     3506 +                }
     3507 +        }
     3508 +        ixgbe->speeds_supported = speeds_supported;
     3509 +
     3510 +        /*
     3511 +         * By default, all supported speeds are enabled and advertised.
     3512 +         */
     3513 +        if (speeds_supported & IXGBE_LINK_SPEED_10GB_FULL) {
     3514 +                ixgbe->param_en_10000fdx_cap = 1;
     3515 +                ixgbe->param_adv_10000fdx_cap = 1;
     3516 +        } else {
     3517 +                ixgbe->param_en_10000fdx_cap = 0;
     3518 +                ixgbe->param_adv_10000fdx_cap = 0;
     3519 +        }
     3520 +
     3521 +        if (speeds_supported & IXGBE_LINK_SPEED_5GB_FULL) {
     3522 +                ixgbe->param_en_5000fdx_cap = 1;
     3523 +                ixgbe->param_adv_5000fdx_cap = 1;
     3524 +        } else {
     3525 +                ixgbe->param_en_5000fdx_cap = 0;
     3526 +                ixgbe->param_adv_5000fdx_cap = 0;
     3527 +        }
     3528 +
     3529 +        if (speeds_supported & IXGBE_LINK_SPEED_2_5GB_FULL) {
     3530 +                ixgbe->param_en_2500fdx_cap = 1;
     3531 +                ixgbe->param_adv_2500fdx_cap = 1;
     3532 +        } else {
     3533 +                ixgbe->param_en_2500fdx_cap = 0;
     3534 +                ixgbe->param_adv_2500fdx_cap = 0;
     3535 +        }
     3536 +
     3537 +        if (speeds_supported & IXGBE_LINK_SPEED_1GB_FULL) {
     3538 +                ixgbe->param_en_1000fdx_cap = 1;
     3539 +                ixgbe->param_adv_1000fdx_cap = 1;
     3540 +        } else {
     3541 +                ixgbe->param_en_1000fdx_cap = 0;
     3542 +                ixgbe->param_adv_1000fdx_cap = 0;
     3543 +        }
     3544 +
     3545 +        if (speeds_supported & IXGBE_LINK_SPEED_100_FULL) {
     3546 +                ixgbe->param_en_100fdx_cap = 1;
     3547 +                ixgbe->param_adv_100fdx_cap = 1;
     3548 +        } else {
     3549 +                ixgbe->param_en_100fdx_cap = 0;
     3550 +                ixgbe->param_adv_100fdx_cap = 0;
     3551 +        }
     3552 +
3250 3553          ixgbe->param_pause_cap = 1;
3251 3554          ixgbe->param_asym_pause_cap = 1;
3252 3555          ixgbe->param_rem_fault = 0;
3253 3556  
3254 3557          ixgbe->param_adv_autoneg_cap = 1;
3255 3558          ixgbe->param_adv_pause_cap = 1;
3256 3559          ixgbe->param_adv_asym_pause_cap = 1;
3257 3560          ixgbe->param_adv_rem_fault = 0;
3258 3561  
3259 3562          ixgbe->param_lp_10000fdx_cap = 0;
     3563 +        ixgbe->param_lp_5000fdx_cap = 0;
     3564 +        ixgbe->param_lp_2500fdx_cap = 0;
3260 3565          ixgbe->param_lp_1000fdx_cap = 0;
3261 3566          ixgbe->param_lp_100fdx_cap = 0;
3262 3567          ixgbe->param_lp_autoneg_cap = 0;
3263 3568          ixgbe->param_lp_pause_cap = 0;
3264 3569          ixgbe->param_lp_asym_pause_cap = 0;
3265 3570          ixgbe->param_lp_rem_fault = 0;
3266 3571  }
3267 3572  
3268 3573  /*
3269 3574   * ixgbe_get_prop - Get a property value out of the configuration file
↓ open down ↓ 27 lines elided ↑ open up ↑
3297 3602  
3298 3603          return (value);
3299 3604  }
3300 3605  
3301 3606  /*
3302 3607   * ixgbe_driver_setup_link - Using the link properties to setup the link.
3303 3608   */
3304 3609  int
3305 3610  ixgbe_driver_setup_link(ixgbe_t *ixgbe, boolean_t setup_hw)
3306 3611  {
3307      -        u32 autoneg_advertised = 0;
     3612 +        struct ixgbe_hw *hw = &ixgbe->hw;
     3613 +        ixgbe_link_speed advertised = 0;
3308 3614  
3309 3615          /*
3310      -         * No half duplex support with 10Gb parts
     3616 +         * Assemble a list of enabled speeds to auto-negotiate with.
3311 3617           */
3312      -        if (ixgbe->param_adv_10000fdx_cap == 1)
3313      -                autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
     3618 +        if (ixgbe->param_en_10000fdx_cap == 1)
     3619 +                advertised |= IXGBE_LINK_SPEED_10GB_FULL;
3314 3620  
3315      -        if (ixgbe->param_adv_1000fdx_cap == 1)
3316      -                autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
     3621 +        if (ixgbe->param_en_5000fdx_cap == 1)
     3622 +                advertised |= IXGBE_LINK_SPEED_5GB_FULL;
3317 3623  
3318      -        if (ixgbe->param_adv_100fdx_cap == 1)
3319      -                autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
     3624 +        if (ixgbe->param_en_2500fdx_cap == 1)
     3625 +                advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
3320 3626  
3321      -        if (ixgbe->param_adv_autoneg_cap == 1 && autoneg_advertised == 0) {
3322      -                ixgbe_notice(ixgbe, "Invalid link settings. Setup link "
3323      -                    "to autonegotiation with full link capabilities.");
     3627 +        if (ixgbe->param_en_1000fdx_cap == 1)
     3628 +                advertised |= IXGBE_LINK_SPEED_1GB_FULL;
3324 3629  
3325      -                autoneg_advertised = IXGBE_LINK_SPEED_10GB_FULL |
3326      -                    IXGBE_LINK_SPEED_1GB_FULL |
3327      -                    IXGBE_LINK_SPEED_100_FULL;
     3630 +        if (ixgbe->param_en_100fdx_cap == 1)
     3631 +                advertised |= IXGBE_LINK_SPEED_100_FULL;
     3632 +
     3633 +        /*
     3634 +         * As a last resort, autoneg with a default list of speeds.
     3635 +         */
     3636 +        if (ixgbe->param_adv_autoneg_cap == 1 && advertised == 0) {
     3637 +                ixgbe_notice(ixgbe, "Invalid link settings. Setting link "
     3638 +                    "to autonegotiate with full capabilities.");
     3639 +
     3640 +                if (hw->mac.type == ixgbe_mac_82598EB)
     3641 +                        advertised = IXGBE_LINK_SPEED_82598_AUTONEG;
     3642 +                else
     3643 +                        advertised = IXGBE_LINK_SPEED_82599_AUTONEG;
3328 3644          }
3329 3645  
3330 3646          if (setup_hw) {
3331      -                if (ixgbe_setup_link(&ixgbe->hw, autoneg_advertised,
3332      -                    ixgbe->param_adv_autoneg_cap, B_TRUE) != IXGBE_SUCCESS) {
     3647 +                if (ixgbe_setup_link(&ixgbe->hw, advertised,
     3648 +                    ixgbe->param_adv_autoneg_cap) != IXGBE_SUCCESS) {
3333 3649                          ixgbe_notice(ixgbe, "Setup link failed on this "
3334 3650                              "device.");
3335 3651                          return (IXGBE_FAILURE);
3336 3652                  }
3337 3653          }
3338 3654  
3339 3655          return (IXGBE_SUCCESS);
3340 3656  }
3341 3657  
3342 3658  /*
↓ open down ↓ 4 lines elided ↑ open up ↑
3347 3663  static void
3348 3664  ixgbe_driver_link_check(ixgbe_t *ixgbe)
3349 3665  {
3350 3666          struct ixgbe_hw *hw = &ixgbe->hw;
3351 3667          ixgbe_link_speed speed = IXGBE_LINK_SPEED_UNKNOWN;
3352 3668          boolean_t link_up = B_FALSE;
3353 3669          boolean_t link_changed = B_FALSE;
3354 3670  
3355 3671          ASSERT(mutex_owned(&ixgbe->gen_lock));
3356 3672  
3357      -        (void) ixgbe_check_link(hw, &speed, &link_up, false);
     3673 +        (void) ixgbe_check_link(hw, &speed, &link_up, B_FALSE);
3358 3674          if (link_up) {
3359 3675                  ixgbe->link_check_complete = B_TRUE;
3360 3676  
3361 3677                  /* Link is up, enable flow control settings */
3362 3678                  (void) ixgbe_fc_enable(hw);
3363 3679  
3364 3680                  /*
3365 3681                   * The Link is up, check whether it was marked as down earlier
3366 3682                   */
3367 3683                  if (ixgbe->link_state != LINK_STATE_UP) {
3368 3684                          switch (speed) {
3369 3685                          case IXGBE_LINK_SPEED_10GB_FULL:
3370 3686                                  ixgbe->link_speed = SPEED_10GB;
3371 3687                                  break;
     3688 +                        case IXGBE_LINK_SPEED_5GB_FULL:
     3689 +                                ixgbe->link_speed = SPEED_5GB;
     3690 +                                break;
     3691 +                        case IXGBE_LINK_SPEED_2_5GB_FULL:
     3692 +                                ixgbe->link_speed = SPEED_2_5GB;
     3693 +                                break;
3372 3694                          case IXGBE_LINK_SPEED_1GB_FULL:
3373 3695                                  ixgbe->link_speed = SPEED_1GB;
3374 3696                                  break;
3375 3697                          case IXGBE_LINK_SPEED_100_FULL:
3376 3698                                  ixgbe->link_speed = SPEED_100;
3377 3699                          }
3378 3700                          ixgbe->link_duplex = LINK_DUPLEX_FULL;
3379 3701                          ixgbe->link_state = LINK_STATE_UP;
3380 3702                          link_changed = B_TRUE;
3381 3703                  }
↓ open down ↓ 33 lines elided ↑ open up ↑
3415 3737   * ixgbe_sfp_check - sfp module processing done in taskq only for 82599.
3416 3738   */
3417 3739  static void
3418 3740  ixgbe_sfp_check(void *arg)
3419 3741  {
3420 3742          ixgbe_t *ixgbe = (ixgbe_t *)arg;
3421 3743          uint32_t eicr = ixgbe->eicr;
3422 3744          struct ixgbe_hw *hw = &ixgbe->hw;
3423 3745  
3424 3746          mutex_enter(&ixgbe->gen_lock);
3425      -        if (eicr & IXGBE_EICR_GPI_SDP1) {
     3747 +        if (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw)) {
3426 3748                  /* clear the interrupt */
3427      -                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1);
     3749 +                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
3428 3750  
3429 3751                  /* if link up, do multispeed fiber setup */
3430 3752                  (void) ixgbe_setup_link(hw, IXGBE_LINK_SPEED_82599_AUTONEG,
3431      -                    B_TRUE, B_TRUE);
     3753 +                    B_TRUE);
3432 3754                  ixgbe_driver_link_check(ixgbe);
3433 3755                  ixgbe_get_hw_state(ixgbe);
3434      -        } else if (eicr & IXGBE_EICR_GPI_SDP2) {
     3756 +        } else if (eicr & IXGBE_EICR_GPI_SDP2_BY_MAC(hw)) {
3435 3757                  /* clear the interrupt */
3436      -                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2);
     3758 +                IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2_BY_MAC(hw));
3437 3759  
3438 3760                  /* if link up, do sfp module setup */
3439 3761                  (void) hw->mac.ops.setup_sfp(hw);
3440 3762  
3441 3763                  /* do multispeed fiber setup */
3442 3764                  (void) ixgbe_setup_link(hw, IXGBE_LINK_SPEED_82599_AUTONEG,
3443      -                    B_TRUE, B_TRUE);
     3765 +                    B_TRUE);
3444 3766                  ixgbe_driver_link_check(ixgbe);
3445 3767                  ixgbe_get_hw_state(ixgbe);
3446 3768          }
3447 3769          mutex_exit(&ixgbe->gen_lock);
3448 3770  
3449 3771          /*
3450 3772           * We need to fully re-check the link later.
3451 3773           */
3452 3774          ixgbe->link_check_complete = B_FALSE;
3453 3775          ixgbe->link_check_hrtime = gethrtime() +
↓ open down ↓ 12 lines elided ↑ open up ↑
3466 3788  {
3467 3789          ixgbe_t *ixgbe = (ixgbe_t *)arg;
3468 3790          struct ixgbe_hw *hw = &ixgbe->hw;
3469 3791          uint32_t eicr = ixgbe->eicr;
3470 3792          ixgbe_link_speed speed;
3471 3793          boolean_t link_up;
3472 3794  
3473 3795          mutex_enter(&ixgbe->gen_lock);
3474 3796  
3475 3797          /* make sure we know current state of link */
3476      -        (void) ixgbe_check_link(hw, &speed, &link_up, false);
     3798 +        (void) ixgbe_check_link(hw, &speed, &link_up, B_FALSE);
3477 3799  
3478 3800          /* check over-temp condition */
3479      -        if (((eicr & IXGBE_EICR_GPI_SDP0) && (!link_up)) ||
     3801 +        if (((eicr & IXGBE_EICR_GPI_SDP0_BY_MAC(hw)) && (!link_up)) ||
3480 3802              (eicr & IXGBE_EICR_LSC)) {
3481 3803                  if (hw->phy.ops.check_overtemp(hw) == IXGBE_ERR_OVERTEMP) {
3482 3804                          atomic_or_32(&ixgbe->ixgbe_state, IXGBE_OVERTEMP);
3483 3805  
3484 3806                          /*
3485 3807                           * Disable the adapter interrupts
3486 3808                           */
3487 3809                          ixgbe_disable_adapter_interrupts(ixgbe);
3488 3810  
3489 3811                          /*
↓ open down ↓ 12 lines elided ↑ open up ↑
3502 3824                  }
3503 3825          }
3504 3826  
3505 3827          /* write to clear the interrupt */
3506 3828          IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
3507 3829  
3508 3830          mutex_exit(&ixgbe->gen_lock);
3509 3831  }
3510 3832  
3511 3833  /*
     3834 + * ixgbe_phy_check - taskq to process interrupts from an external PHY
     3835 + *
     3836 + * This routine will only be called on adapters with external PHYs
     3837 + * (such as X550) that may be trying to raise our attention to some event.
     3838 + * Currently, this is limited to claiming PHY overtemperature and link status
     3839 + * change (LSC) events, however this may expand to include other things in
     3840 + * future adapters.
     3841 + */
     3842 +static void
     3843 +ixgbe_phy_check(void *arg)
     3844 +{
     3845 +        ixgbe_t *ixgbe = (ixgbe_t *)arg;
     3846 +        struct ixgbe_hw *hw = &ixgbe->hw;
     3847 +        int rv;
     3848 +
     3849 +        mutex_enter(&ixgbe->gen_lock);
     3850 +
     3851 +        /*
     3852 +         * X550 baseT PHY overtemp and LSC events are handled here.
     3853 +         *
     3854 +         * If an overtemp event occurs, it will be reflected in the
     3855 +         * return value of phy.ops.handle_lasi() and the common code will
     3856 +         * automatically power off the baseT PHY. This is our cue to trigger
     3857 +         * an FMA event.
     3858 +         *
     3859 +         * If a link status change event occurs, phy.ops.handle_lasi() will
     3860 +         * automatically initiate a link setup between the integrated KR PHY
     3861 +         * and the external X557 PHY to ensure that the link speed between
     3862 +         * them matches the link speed of the baseT link.
     3863 +         */
     3864 +        rv = ixgbe_handle_lasi(hw);
     3865 +
     3866 +        if (rv == IXGBE_ERR_OVERTEMP) {
     3867 +                atomic_or_32(&ixgbe->ixgbe_state, IXGBE_OVERTEMP);
     3868 +
     3869 +                /*
     3870 +                 * Disable the adapter interrupts
     3871 +                 */
     3872 +                ixgbe_disable_adapter_interrupts(ixgbe);
     3873 +
     3874 +                /*
     3875 +                 * Disable Rx/Tx units
     3876 +                 */
     3877 +                (void) ixgbe_stop_adapter(hw);
     3878 +
     3879 +                ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
     3880 +                ixgbe_error(ixgbe,
     3881 +                    "Problem: Network adapter has been stopped due to a "
     3882 +                    "overtemperature event being detected.");
     3883 +                ixgbe_error(ixgbe,
     3884 +                    "Action: Shut down or restart the computer. If the issue "
     3885 +                    "persists, please take action in accordance with the "
     3886 +                    "recommendations from your system vendor.");
     3887 +        }
     3888 +
     3889 +        mutex_exit(&ixgbe->gen_lock);
     3890 +}
     3891 +
     3892 +/*
3512 3893   * ixgbe_link_timer - timer for link status detection
3513 3894   */
3514 3895  static void
3515 3896  ixgbe_link_timer(void *arg)
3516 3897  {
3517 3898          ixgbe_t *ixgbe = (ixgbe_t *)arg;
3518 3899  
3519 3900          mutex_enter(&ixgbe->gen_lock);
3520 3901          ixgbe_driver_link_check(ixgbe);
3521 3902          mutex_exit(&ixgbe->gen_lock);
↓ open down ↓ 143 lines elided ↑ open up ↑
3665 4046                                  found = B_TRUE;
3666 4047                          }
3667 4048                  }
3668 4049                  ddi_prop_free(bytes);
3669 4050          }
3670 4051  
3671 4052          /*
3672 4053           * Finally(!), if there's a valid "mac-address" property (created
3673 4054           * if we netbooted from this interface), we must use this instead
3674 4055           * of any of the above to ensure that the NFS/install server doesn't
3675      -         * get confused by the address changing as Solaris takes over!
     4056 +         * get confused by the address changing as illumos takes over!
3676 4057           */
3677 4058          err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip,
3678 4059              DDI_PROP_DONTPASS, "mac-address", &bytes, &nelts);
3679 4060          if (err == DDI_PROP_SUCCESS) {
3680 4061                  if (nelts == ETHERADDRL) {
3681 4062                          while (nelts--)
3682 4063                                  hw->mac.addr[nelts] = bytes[nelts];
3683 4064                          found = B_TRUE;
3684 4065                  }
3685 4066                  ddi_prop_free(bytes);
↓ open down ↓ 169 lines elided ↑ open up ↑
3855 4236          /*
3856 4237           * non-msi-x mode
3857 4238           */
3858 4239          } else {
3859 4240  
3860 4241                  /* disable autoclear, leave gpie at default */
3861 4242                  eiac = 0;
3862 4243  
3863 4244                  /*
3864 4245                   * General purpose interrupt enable.
3865      -                 * For 82599 or X540, extended interrupt automask enable
3866      -                 * only in MSI or MSI-X mode
     4246 +                 * For 82599, X540 and X550, extended interrupt
     4247 +                 * automask enable only in MSI or MSI-X mode
3867 4248                   */
3868 4249                  if ((hw->mac.type == ixgbe_mac_82598EB) ||
3869 4250                      (ixgbe->intr_type == DDI_INTR_TYPE_MSI)) {
3870 4251                          gpie |= IXGBE_GPIE_EIAME;
3871 4252                  }
3872 4253          }
3873 4254  
3874 4255          /* Enable specific "other" interrupt types */
3875 4256          switch (hw->mac.type) {
3876 4257          case ixgbe_mac_82598EB:
3877 4258                  gpie |= ixgbe->capab->other_gpie;
3878 4259                  break;
3879 4260  
3880 4261          case ixgbe_mac_82599EB:
3881 4262          case ixgbe_mac_X540:
     4263 +        case ixgbe_mac_X550:
     4264 +        case ixgbe_mac_X550EM_x:
3882 4265                  gpie |= ixgbe->capab->other_gpie;
3883 4266  
3884 4267                  /* Enable RSC Delay 8us when LRO enabled  */
3885 4268                  if (ixgbe->lro_enable) {
3886 4269                          gpie |= (1 << IXGBE_GPIE_RSC_DELAY_SHIFT);
3887 4270                  }
3888 4271                  break;
3889 4272  
3890 4273          default:
3891 4274                  break;
↓ open down ↓ 174 lines elided ↑ open up ↑
4066 4449  
4067 4450                  (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
4068 4451                      &atlas);
4069 4452                  atlas |= IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
4070 4453                  (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
4071 4454                      atlas);
4072 4455                  break;
4073 4456  
4074 4457          case ixgbe_mac_82599EB:
4075 4458          case ixgbe_mac_X540:
     4459 +        case ixgbe_mac_X550:
     4460 +        case ixgbe_mac_X550EM_x:
4076 4461                  reg = IXGBE_READ_REG(&ixgbe->hw, IXGBE_AUTOC);
4077 4462                  reg |= (IXGBE_AUTOC_FLU |
4078 4463                      IXGBE_AUTOC_10G_KX4);
4079 4464                  IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_AUTOC, reg);
4080 4465  
4081 4466                  (void) ixgbe_setup_link(&ixgbe->hw, IXGBE_LINK_SPEED_10GB_FULL,
4082      -                    B_FALSE, B_TRUE);
     4467 +                    B_FALSE);
4083 4468                  break;
4084 4469  
4085 4470          default:
4086 4471                  break;
4087 4472          }
4088 4473  }
4089 4474  
4090 4475  #pragma inline(ixgbe_intr_rx_work)
4091 4476  /*
4092 4477   * ixgbe_intr_rx_work - RX processing of ISR.
↓ open down ↓ 39 lines elided ↑ open up ↑
4132 4517          }
4133 4518  }
4134 4519  
4135 4520  #pragma inline(ixgbe_intr_other_work)
4136 4521  /*
4137 4522   * ixgbe_intr_other_work - Process interrupt types other than tx/rx
4138 4523   */
4139 4524  static void
4140 4525  ixgbe_intr_other_work(ixgbe_t *ixgbe, uint32_t eicr)
4141 4526  {
     4527 +        struct ixgbe_hw *hw = &ixgbe->hw;
     4528 +
4142 4529          ASSERT(mutex_owned(&ixgbe->gen_lock));
4143 4530  
4144 4531          /*
4145 4532           * handle link status change
4146 4533           */
4147 4534          if (eicr & IXGBE_EICR_LSC) {
4148 4535                  ixgbe_driver_link_check(ixgbe);
4149 4536                  ixgbe_get_hw_state(ixgbe);
4150 4537          }
4151 4538  
↓ open down ↓ 22 lines elided ↑ open up ↑
4174 4561                      "Action: Replace the adapter.\n");
4175 4562  
4176 4563                  /* re-enable the interrupt, which was automasked */
4177 4564                  ixgbe->eims |= IXGBE_EICR_GPI_SDP1;
4178 4565          }
4179 4566  
4180 4567          /*
4181 4568           * Do SFP check for adapters with hot-plug capability
4182 4569           */
4183 4570          if ((ixgbe->capab->flags & IXGBE_FLAG_SFP_PLUG_CAPABLE) &&
4184      -            ((eicr & IXGBE_EICR_GPI_SDP1) || (eicr & IXGBE_EICR_GPI_SDP2))) {
     4571 +            ((eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw)) ||
     4572 +            (eicr & IXGBE_EICR_GPI_SDP2_BY_MAC(hw)))) {
4185 4573                  ixgbe->eicr = eicr;
4186 4574                  if ((ddi_taskq_dispatch(ixgbe->sfp_taskq,
4187 4575                      ixgbe_sfp_check, (void *)ixgbe,
4188 4576                      DDI_NOSLEEP)) != DDI_SUCCESS) {
4189 4577                          ixgbe_log(ixgbe, "No memory available to dispatch "
4190 4578                              "taskq for SFP check");
4191 4579                  }
4192 4580          }
4193 4581  
4194 4582          /*
4195 4583           * Do over-temperature check for adapters with temp sensor
4196 4584           */
4197 4585          if ((ixgbe->capab->flags & IXGBE_FLAG_TEMP_SENSOR_CAPABLE) &&
4198      -            ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC))) {
     4586 +            ((eicr & IXGBE_EICR_GPI_SDP0_BY_MAC(hw)) ||
     4587 +            (eicr & IXGBE_EICR_LSC))) {
4199 4588                  ixgbe->eicr = eicr;
4200 4589                  if ((ddi_taskq_dispatch(ixgbe->overtemp_taskq,
4201 4590                      ixgbe_overtemp_check, (void *)ixgbe,
4202 4591                      DDI_NOSLEEP)) != DDI_SUCCESS) {
4203 4592                          ixgbe_log(ixgbe, "No memory available to dispatch "
4204 4593                              "taskq for overtemp check");
4205 4594                  }
4206 4595          }
     4596 +
     4597 +        /*
     4598 +         * Process an external PHY interrupt
     4599 +         */
     4600 +        if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T &&
     4601 +            (eicr & IXGBE_EICR_GPI_SDP0_X540)) {
     4602 +                ixgbe->eicr = eicr;
     4603 +                if ((ddi_taskq_dispatch(ixgbe->phy_taskq,
     4604 +                    ixgbe_phy_check, (void *)ixgbe,
     4605 +                    DDI_NOSLEEP)) != DDI_SUCCESS) {
     4606 +                        ixgbe_log(ixgbe, "No memory available to dispatch "
     4607 +                            "taskq for PHY check");
     4608 +                }
     4609 +        }
4207 4610  }
4208 4611  
4209 4612  /*
4210 4613   * ixgbe_intr_legacy - Interrupt handler for legacy interrupts.
4211 4614   */
4212 4615  static uint_t
4213 4616  ixgbe_intr_legacy(void *arg1, void *arg2)
4214 4617  {
4215 4618          ixgbe_t *ixgbe = (ixgbe_t *)arg1;
4216 4619          struct ixgbe_hw *hw = &ixgbe->hw;
↓ open down ↓ 68 lines elided ↑ open up ↑
4285 4688  
4286 4689                  /* any interrupt type other than tx/rx */
4287 4690                  if (eicr & ixgbe->capab->other_intr) {
4288 4691                          switch (hw->mac.type) {
4289 4692                          case ixgbe_mac_82598EB:
4290 4693                                  ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
4291 4694                                  break;
4292 4695  
4293 4696                          case ixgbe_mac_82599EB:
4294 4697                          case ixgbe_mac_X540:
     4698 +                        case ixgbe_mac_X550:
     4699 +                        case ixgbe_mac_X550EM_x:
4295 4700                                  ixgbe->eimc = IXGBE_82599_OTHER_INTR;
4296 4701                                  IXGBE_WRITE_REG(hw, IXGBE_EIMC, ixgbe->eimc);
4297 4702                                  break;
4298 4703  
4299 4704                          default:
4300 4705                                  break;
4301 4706                          }
4302 4707                          ixgbe_intr_other_work(ixgbe, eicr);
4303 4708                          ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
4304 4709                  }
↓ open down ↓ 74 lines elided ↑ open up ↑
4379 4784          /* any interrupt type other than tx/rx */
4380 4785          if (eicr & ixgbe->capab->other_intr) {
4381 4786                  mutex_enter(&ixgbe->gen_lock);
4382 4787                  switch (hw->mac.type) {
4383 4788                  case ixgbe_mac_82598EB:
4384 4789                          ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
4385 4790                          break;
4386 4791  
4387 4792                  case ixgbe_mac_82599EB:
4388 4793                  case ixgbe_mac_X540:
     4794 +                case ixgbe_mac_X550:
     4795 +                case ixgbe_mac_X550EM_x:
4389 4796                          ixgbe->eimc = IXGBE_82599_OTHER_INTR;
4390 4797                          IXGBE_WRITE_REG(hw, IXGBE_EIMC, ixgbe->eimc);
4391 4798                          break;
4392 4799  
4393 4800                  default:
4394 4801                          break;
4395 4802                  }
4396 4803                  ixgbe_intr_other_work(ixgbe, eicr);
4397 4804                  ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
4398 4805                  mutex_exit(&ixgbe->gen_lock);
↓ open down ↓ 60 lines elided ↑ open up ↑
4459 4866                  if (eicr & ixgbe->capab->other_intr) {
4460 4867                          mutex_enter(&ixgbe->gen_lock);
4461 4868                          switch (hw->mac.type) {
4462 4869                          case ixgbe_mac_82598EB:
4463 4870                                  ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
4464 4871                                  ixgbe_intr_other_work(ixgbe, eicr);
4465 4872                                  break;
4466 4873  
4467 4874                          case ixgbe_mac_82599EB:
4468 4875                          case ixgbe_mac_X540:
     4876 +                        case ixgbe_mac_X550:
     4877 +                        case ixgbe_mac_X550EM_x:
4469 4878                                  ixgbe->eims |= IXGBE_EICR_RTX_QUEUE;
4470 4879                                  ixgbe_intr_other_work(ixgbe, eicr);
4471 4880                                  break;
4472 4881  
4473 4882                          default:
4474 4883                                  break;
4475 4884                          }
4476 4885                          mutex_exit(&ixgbe->gen_lock);
4477 4886                  }
4478 4887  
↓ open down ↓ 69 lines elided ↑ open up ↑
4548 4957                          return (IXGBE_SUCCESS);
4549 4958  
4550 4959                  ixgbe_log(ixgbe,
4551 4960                      "Allocate MSI failed, trying Legacy interrupts...");
4552 4961          }
4553 4962  
4554 4963          /*
4555 4964           * Install legacy interrupts
4556 4965           */
4557 4966          if (intr_types & DDI_INTR_TYPE_FIXED) {
     4967 +                /*
     4968 +                 * Disallow legacy interrupts for X550. X550 has a silicon
     4969 +                 * bug which prevents Shared Legacy interrupts from working.
     4970 +                 * For details, please reference:
     4971 +                 *
     4972 +                 * Intel Ethernet Controller X550 Specification Update rev. 2.1
     4973 +                 * May 2016, erratum 22: PCIe Interrupt Status Bit
     4974 +                 */
     4975 +                if (ixgbe->hw.mac.type == ixgbe_mac_X550 ||
     4976 +                    ixgbe->hw.mac.type == ixgbe_mac_X550EM_x ||
     4977 +                    ixgbe->hw.mac.type == ixgbe_mac_X550_vf ||
     4978 +                    ixgbe->hw.mac.type == ixgbe_mac_X550EM_x_vf) {
     4979 +                        ixgbe_log(ixgbe,
     4980 +                            "Legacy interrupts are not supported on this "
     4981 +                            "adapter. Please use MSI or MSI-X instead.");
     4982 +                        return (IXGBE_FAILURE);
     4983 +                }
4558 4984                  rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_FIXED);
4559 4985                  if (rc == IXGBE_SUCCESS)
4560 4986                          return (IXGBE_SUCCESS);
4561 4987  
4562 4988                  ixgbe_log(ixgbe,
4563 4989                      "Allocate Legacy interrupts failed");
4564 4990          }
4565 4991  
4566 4992          /*
4567 4993           * If none of the 3 types succeeded, return failure
↓ open down ↓ 292 lines elided ↑ open up ↑
4860 5286                  }
4861 5287                  index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
4862 5288                  ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
4863 5289                  ivar &= ~(0xFF << (8 * (intr_alloc_entry & 0x3)));
4864 5290                  ivar |= (msix_vector << (8 * (intr_alloc_entry & 0x3)));
4865 5291                  IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
4866 5292                  break;
4867 5293  
4868 5294          case ixgbe_mac_82599EB:
4869 5295          case ixgbe_mac_X540:
     5296 +        case ixgbe_mac_X550:
     5297 +        case ixgbe_mac_X550EM_x:
4870 5298                  if (cause == -1) {
4871 5299                          /* other causes */
4872 5300                          msix_vector |= IXGBE_IVAR_ALLOC_VAL;
4873 5301                          index = (intr_alloc_entry & 1) * 8;
4874 5302                          ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
4875 5303                          ivar &= ~(0xFF << index);
4876 5304                          ivar |= (msix_vector << index);
4877 5305                          IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
4878 5306                  } else {
4879 5307                          /* tx or rx causes */
↓ open down ↓ 34 lines elided ↑ open up ↑
4914 5342                  }
4915 5343                  index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
4916 5344                  ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
4917 5345                  ivar |= (IXGBE_IVAR_ALLOC_VAL << (8 *
4918 5346                      (intr_alloc_entry & 0x3)));
4919 5347                  IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
4920 5348                  break;
4921 5349  
4922 5350          case ixgbe_mac_82599EB:
4923 5351          case ixgbe_mac_X540:
     5352 +        case ixgbe_mac_X550:
     5353 +        case ixgbe_mac_X550EM_x:
4924 5354                  if (cause == -1) {
4925 5355                          /* other causes */
4926 5356                          index = (intr_alloc_entry & 1) * 8;
4927 5357                          ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
4928 5358                          ivar |= (IXGBE_IVAR_ALLOC_VAL << index);
4929 5359                          IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
4930 5360                  } else {
4931 5361                          /* tx or rx causes */
4932 5362                          index = ((16 * (intr_alloc_entry & 1)) + (8 * cause));
4933 5363                          ivar = IXGBE_READ_REG(hw,
↓ open down ↓ 30 lines elided ↑ open up ↑
4964 5394                  }
4965 5395                  index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
4966 5396                  ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
4967 5397                  ivar &= ~(IXGBE_IVAR_ALLOC_VAL<< (8 *
4968 5398                      (intr_alloc_entry & 0x3)));
4969 5399                  IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
4970 5400                  break;
4971 5401  
4972 5402          case ixgbe_mac_82599EB:
4973 5403          case ixgbe_mac_X540:
     5404 +        case ixgbe_mac_X550:
     5405 +        case ixgbe_mac_X550EM_x:
4974 5406                  if (cause == -1) {
4975 5407                          /* other causes */
4976 5408                          index = (intr_alloc_entry & 1) * 8;
4977 5409                          ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
4978 5410                          ivar &= ~(IXGBE_IVAR_ALLOC_VAL << index);
4979 5411                          IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
4980 5412                  } else {
4981 5413                          /* tx or rx causes */
4982 5414                          index = ((16 * (intr_alloc_entry & 1)) + (8 * cause));
4983 5415                          ivar = IXGBE_READ_REG(hw,
↓ open down ↓ 23 lines elided ↑ open up ↑
5007 5439          if (ixgbe->classify_mode == IXGBE_CLASSIFY_RSS ||
5008 5440              ixgbe->classify_mode == IXGBE_CLASSIFY_NONE) {
5009 5441                  return (sw_rx_index);
5010 5442          } else if (ixgbe->classify_mode == IXGBE_CLASSIFY_VMDQ) {
5011 5443                  switch (hw->mac.type) {
5012 5444                  case ixgbe_mac_82598EB:
5013 5445                          return (sw_rx_index);
5014 5446  
5015 5447                  case ixgbe_mac_82599EB:
5016 5448                  case ixgbe_mac_X540:
     5449 +                case ixgbe_mac_X550:
     5450 +                case ixgbe_mac_X550EM_x:
5017 5451                          return (sw_rx_index * 2);
5018 5452  
5019 5453                  default:
5020 5454                          break;
5021 5455                  }
5022 5456          } else if (ixgbe->classify_mode == IXGBE_CLASSIFY_VMDQ_RSS) {
5023 5457                  rx_ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
5024 5458  
5025 5459                  switch (hw->mac.type) {
5026 5460                  case ixgbe_mac_82598EB:
5027 5461                          hw_rx_index = (sw_rx_index / rx_ring_per_group) *
5028 5462                              16 + (sw_rx_index % rx_ring_per_group);
5029 5463                          return (hw_rx_index);
5030 5464  
5031 5465                  case ixgbe_mac_82599EB:
5032 5466                  case ixgbe_mac_X540:
     5467 +                case ixgbe_mac_X550:
     5468 +                case ixgbe_mac_X550EM_x:
5033 5469                          if (ixgbe->num_rx_groups > 32) {
5034 5470                                  hw_rx_index = (sw_rx_index /
5035 5471                                      rx_ring_per_group) * 2 +
5036 5472                                      (sw_rx_index % rx_ring_per_group);
5037 5473                          } else {
5038 5474                                  hw_rx_index = (sw_rx_index /
5039 5475                                      rx_ring_per_group) * 4 +
5040 5476                                      (sw_rx_index % rx_ring_per_group);
5041 5477                          }
5042 5478                          return (hw_rx_index);
↓ open down ↓ 85 lines elided ↑ open up ↑
5128 5564           * Clear any previous entries
5129 5565           */
5130 5566          switch (hw->mac.type) {
5131 5567          case ixgbe_mac_82598EB:
5132 5568                  for (v_idx = 0; v_idx < 25; v_idx++)
5133 5569                          IXGBE_WRITE_REG(hw, IXGBE_IVAR(v_idx), 0);
5134 5570                  break;
5135 5571  
5136 5572          case ixgbe_mac_82599EB:
5137 5573          case ixgbe_mac_X540:
     5574 +        case ixgbe_mac_X550:
     5575 +        case ixgbe_mac_X550EM_x:
5138 5576                  for (v_idx = 0; v_idx < 64; v_idx++)
5139 5577                          IXGBE_WRITE_REG(hw, IXGBE_IVAR(v_idx), 0);
5140 5578                  IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, 0);
5141 5579                  break;
5142 5580  
5143 5581          default:
5144 5582                  break;
5145 5583          }
5146 5584  
5147 5585          /*
↓ open down ↓ 155 lines elided ↑ open up ↑
5303 5741          return (IXGBE_SUCCESS);
5304 5742  }
5305 5743  
5306 5744  /*
5307 5745   * ixgbe_get_hw_state - Get and save parameters related to adapter hardware.
5308 5746   */
5309 5747  static void
5310 5748  ixgbe_get_hw_state(ixgbe_t *ixgbe)
5311 5749  {
5312 5750          struct ixgbe_hw *hw = &ixgbe->hw;
5313      -        ixgbe_link_speed speed = IXGBE_LINK_SPEED_UNKNOWN;
     5751 +        ixgbe_link_speed speed = 0;
5314 5752          boolean_t link_up = B_FALSE;
5315 5753          uint32_t pcs1g_anlp = 0;
5316      -        uint32_t pcs1g_ana = 0;
5317      -        boolean_t autoneg = B_FALSE;
5318 5754  
5319 5755          ASSERT(mutex_owned(&ixgbe->gen_lock));
5320 5756          ixgbe->param_lp_1000fdx_cap = 0;
5321 5757          ixgbe->param_lp_100fdx_cap  = 0;
5322 5758  
5323 5759          /* check for link, don't wait */
5324      -        (void) ixgbe_check_link(hw, &speed, &link_up, false);
5325      -        pcs1g_ana = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
     5760 +        (void) ixgbe_check_link(hw, &speed, &link_up, B_FALSE);
5326 5761  
     5762 +        /*
     5763 +         * Update the observed Link Partner's capabilities. Not all adapters
     5764 +         * can provide full information on the LP's capable speeds, so we
     5765 +         * provide what we can.
     5766 +         */
5327 5767          if (link_up) {
5328 5768                  pcs1g_anlp = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
5329 5769  
5330 5770                  ixgbe->param_lp_1000fdx_cap =
5331 5771                      (pcs1g_anlp & IXGBE_PCS1GANLP_LPFD) ? 1 : 0;
5332 5772                  ixgbe->param_lp_100fdx_cap =
5333 5773                      (pcs1g_anlp & IXGBE_PCS1GANLP_LPFD) ? 1 : 0;
5334 5774          }
5335 5775  
5336      -        (void) ixgbe_get_link_capabilities(hw, &speed, &autoneg);
     5776 +        /*
     5777 +         * Update GLD's notion of the adapter's currently advertised speeds.
     5778 +         * Since the common code doesn't always record the current autonegotiate
     5779 +         * settings in the phy struct for all parts (specifically, adapters with
     5780 +         * SFPs) we first test to see if it is 0, and if so, we fall back to
     5781 +         * using the adapter's speed capabilities which we saved during instance
     5782 +         * init in ixgbe_init_params().
     5783 +         *
     5784 +         * Adapters with SFPs will always be shown as advertising all of their
     5785 +         * supported speeds, and adapters with baseT PHYs (where the phy struct
     5786 +         * is maintained by the common code) will always have a factual view of
     5787 +         * their currently-advertised speeds. In the case of SFPs, this is
     5788 +         * acceptable as we default to advertising all speeds that the adapter
     5789 +         * claims to support, and those properties are immutable; unlike on
     5790 +         * baseT (copper) PHYs, where speeds can be enabled or disabled at will.
     5791 +         */
     5792 +        speed = hw->phy.autoneg_advertised;
     5793 +        if (speed == 0)
     5794 +                speed = ixgbe->speeds_supported;
5337 5795  
5338      -        ixgbe->param_adv_1000fdx_cap = ((pcs1g_ana & IXGBE_PCS1GANA_FDC) &&
5339      -            (speed & IXGBE_LINK_SPEED_1GB_FULL)) ? 1 : 0;
5340      -        ixgbe->param_adv_100fdx_cap = ((pcs1g_ana & IXGBE_PCS1GANA_FDC) &&
5341      -            (speed & IXGBE_LINK_SPEED_100_FULL)) ? 1 : 0;
     5796 +        ixgbe->param_adv_10000fdx_cap =
     5797 +            (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 1 : 0;
     5798 +        ixgbe->param_adv_5000fdx_cap =
     5799 +            (speed & IXGBE_LINK_SPEED_5GB_FULL) ? 1 : 0;
     5800 +        ixgbe->param_adv_2500fdx_cap =
     5801 +            (speed & IXGBE_LINK_SPEED_2_5GB_FULL) ? 1 : 0;
     5802 +        ixgbe->param_adv_1000fdx_cap =
     5803 +            (speed & IXGBE_LINK_SPEED_1GB_FULL) ? 1 : 0;
     5804 +        ixgbe->param_adv_100fdx_cap =
     5805 +            (speed & IXGBE_LINK_SPEED_100_FULL) ? 1 : 0;
5342 5806  }
5343 5807  
5344 5808  /*
5345 5809   * ixgbe_get_driver_control - Notify that driver is in control of device.
5346 5810   */
5347 5811  static void
5348 5812  ixgbe_get_driver_control(struct ixgbe_hw *hw)
5349 5813  {
5350 5814          uint32_t ctrl_ext;
5351 5815  
↓ open down ↓ 504 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX