Print this page
Update i40e for new devices, prototype changes
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
  14  * Copyright (c) 2018, Joyent, Inc.
  15  * Copyright 2017 Tegile Systems, Inc.  All rights reserved.
  16  * Copyright 2020 Ryan Zezeski
  17  * Copyright 2020 RackTop Systems, Inc.

  18  */
  19 
  20 /*
  21  * For more information, please see the big theory statement in i40e_main.c.
  22  */
  23 
  24 #include "i40e_sw.h"
  25 
  26 #define I40E_PROP_RX_DMA_THRESH "_rx_dma_threshold"
  27 #define I40E_PROP_TX_DMA_THRESH "_tx_dma_threshold"
  28 #define I40E_PROP_RX_ITR        "_rx_intr_throttle"
  29 #define I40E_PROP_TX_ITR        "_tx_intr_throttle"
  30 #define I40E_PROP_OTHER_ITR     "_other_intr_throttle"
  31 
  32 char *i40e_priv_props[] = {
  33         I40E_PROP_RX_DMA_THRESH,
  34         I40E_PROP_TX_DMA_THRESH,
  35         I40E_PROP_RX_ITR,
  36         I40E_PROP_TX_ITR,
  37         I40E_PROP_OTHER_ITR,


 653                 mutex_exit(&i40e->i40e_general_lock);
 654                 return (ENOTSUP);
 655         }
 656 
 657         /*
 658          * Make sure we have a sufficiently new firmware version to run this
 659          * command. This was introduced in firmware API 1.7. This is apparently
 660          * only supported on the XL710 MAC, not the XL722.
 661          */
 662         if (hw->mac.type != I40E_MAC_XL710 || hw->aq.api_maj_ver != 1 ||
 663             hw->aq.api_min_ver < 7) {
 664                 mutex_exit(&i40e->i40e_general_lock);
 665                 return (ENOTSUP);
 666         }
 667 
 668         for (i = 0; i < nbytes; i++, offset++) {
 669                 enum i40e_status_code status;
 670                 uint32_t val;
 671 
 672                 status = i40e_aq_get_phy_register(hw,
 673                     I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE, page, offset,
 674                     &val, NULL);
 675                 if (status != I40E_SUCCESS) {
 676                         mutex_exit(&i40e->i40e_general_lock);
 677                         return (EIO);
 678                 }
 679 
 680                 buf8[i] = (uint8_t)val;
 681         }
 682 
 683         mutex_exit(&i40e->i40e_general_lock);
 684         *nread = nbytes;
 685 
 686         return (0);
 687 }
 688 
 689 static int
 690 i40e_gld_led_set(void *arg, mac_led_mode_t mode, uint_t flags)
 691 {
 692         i40e_t *i40e = arg;
 693         struct i40e_hw *hw = &i40e->i40e_hw_space;


1040         uint32_t new_mtu;
1041         link_fec_t fec;
1042         i40e_t *i40e = arg;
1043         int ret = 0;
1044 
1045         mutex_enter(&i40e->i40e_general_lock);
1046         if (i40e->i40e_state & I40E_SUSPENDED) {
1047                 mutex_exit(&i40e->i40e_general_lock);
1048                 return (ECANCELED);
1049         }
1050 
1051         switch (pr_num) {
1052         /*
1053          * These properties are always read-only across every device.
1054          */
1055         case MAC_PROP_DUPLEX:
1056         case MAC_PROP_SPEED:
1057         case MAC_PROP_STATUS:
1058         case MAC_PROP_ADV_100FDX_CAP:
1059         case MAC_PROP_ADV_1000FDX_CAP:


1060         case MAC_PROP_ADV_10GFDX_CAP:
1061         case MAC_PROP_ADV_25GFDX_CAP:
1062         case MAC_PROP_ADV_40GFDX_CAP:
1063                 ret = ENOTSUP;
1064                 break;
1065         /*
1066          * These are read-only at this time as we don't support configuring
1067          * auto-negotiation. See the theory statement in i40e_main.c.
1068          */
1069         case MAC_PROP_EN_100FDX_CAP:
1070         case MAC_PROP_EN_1000FDX_CAP:


1071         case MAC_PROP_EN_10GFDX_CAP:
1072         case MAC_PROP_EN_25GFDX_CAP:
1073         case MAC_PROP_EN_40GFDX_CAP:
1074         case MAC_PROP_AUTONEG:
1075         case MAC_PROP_FLOWCTRL:
1076                 ret = ENOTSUP;
1077                 break;
1078 
1079         case MAC_PROP_MTU:
1080                 bcopy(pr_val, &new_mtu, sizeof (new_mtu));
1081                 if (new_mtu == i40e->i40e_sdu)
1082                         break;
1083 
1084                 if (new_mtu < I40E_MIN_MTU ||
1085                     new_mtu > I40E_MAX_MTU) {
1086                         ret = EINVAL;
1087                         break;
1088                 }
1089 
1090                 if (i40e->i40e_state & I40E_STARTED) {


1214          * to, the values of the ADV_ and EN_ will always be the same.
1215          */
1216         case MAC_PROP_ADV_100FDX_CAP:
1217         case MAC_PROP_EN_100FDX_CAP:
1218                 if (pr_valsize < sizeof (uint8_t)) {
1219                         ret = EOVERFLOW;
1220                         break;
1221                 }
1222                 u8 = pr_val;
1223                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
1224                 break;
1225         case MAC_PROP_ADV_1000FDX_CAP:
1226         case MAC_PROP_EN_1000FDX_CAP:
1227                 if (pr_valsize < sizeof (uint8_t)) {
1228                         ret = EOVERFLOW;
1229                         break;
1230                 }
1231                 u8 = pr_val;
1232                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
1233                 break;


















1234         case MAC_PROP_ADV_10GFDX_CAP:
1235         case MAC_PROP_EN_10GFDX_CAP:
1236                 if (pr_valsize < sizeof (uint8_t)) {
1237                         ret = EOVERFLOW;
1238                         break;
1239                 }
1240                 u8 = pr_val;
1241                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
1242                 break;
1243         case MAC_PROP_ADV_25GFDX_CAP:
1244         case MAC_PROP_EN_25GFDX_CAP:
1245                 if (pr_valsize < sizeof (uint8_t)) {
1246                         ret = EOVERFLOW;
1247                         break;
1248                 }
1249                 u8 = pr_val;
1250                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
1251                 break;
1252         case MAC_PROP_ADV_40GFDX_CAP:
1253         case MAC_PROP_EN_40GFDX_CAP:


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
  14  * Copyright (c) 2018, Joyent, Inc.
  15  * Copyright 2017 Tegile Systems, Inc.  All rights reserved.
  16  * Copyright 2020 Ryan Zezeski
  17  * Copyright 2020 RackTop Systems, Inc.
  18  * Copyright 2021 Oxide Computer Company
  19  */
  20 
  21 /*
  22  * For more information, please see the big theory statement in i40e_main.c.
  23  */
  24 
  25 #include "i40e_sw.h"
  26 
  27 #define I40E_PROP_RX_DMA_THRESH "_rx_dma_threshold"
  28 #define I40E_PROP_TX_DMA_THRESH "_tx_dma_threshold"
  29 #define I40E_PROP_RX_ITR        "_rx_intr_throttle"
  30 #define I40E_PROP_TX_ITR        "_tx_intr_throttle"
  31 #define I40E_PROP_OTHER_ITR     "_other_intr_throttle"
  32 
  33 char *i40e_priv_props[] = {
  34         I40E_PROP_RX_DMA_THRESH,
  35         I40E_PROP_TX_DMA_THRESH,
  36         I40E_PROP_RX_ITR,
  37         I40E_PROP_TX_ITR,
  38         I40E_PROP_OTHER_ITR,


 654                 mutex_exit(&i40e->i40e_general_lock);
 655                 return (ENOTSUP);
 656         }
 657 
 658         /*
 659          * Make sure we have a sufficiently new firmware version to run this
 660          * command. This was introduced in firmware API 1.7. This is apparently
 661          * only supported on the XL710 MAC, not the XL722.
 662          */
 663         if (hw->mac.type != I40E_MAC_XL710 || hw->aq.api_maj_ver != 1 ||
 664             hw->aq.api_min_ver < 7) {
 665                 mutex_exit(&i40e->i40e_general_lock);
 666                 return (ENOTSUP);
 667         }
 668 
 669         for (i = 0; i < nbytes; i++, offset++) {
 670                 enum i40e_status_code status;
 671                 uint32_t val;
 672 
 673                 status = i40e_aq_get_phy_register(hw,
 674                     I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE, page, TRUE, offset,
 675                     &val, NULL);
 676                 if (status != I40E_SUCCESS) {
 677                         mutex_exit(&i40e->i40e_general_lock);
 678                         return (EIO);
 679                 }
 680 
 681                 buf8[i] = (uint8_t)val;
 682         }
 683 
 684         mutex_exit(&i40e->i40e_general_lock);
 685         *nread = nbytes;
 686 
 687         return (0);
 688 }
 689 
 690 static int
 691 i40e_gld_led_set(void *arg, mac_led_mode_t mode, uint_t flags)
 692 {
 693         i40e_t *i40e = arg;
 694         struct i40e_hw *hw = &i40e->i40e_hw_space;


1041         uint32_t new_mtu;
1042         link_fec_t fec;
1043         i40e_t *i40e = arg;
1044         int ret = 0;
1045 
1046         mutex_enter(&i40e->i40e_general_lock);
1047         if (i40e->i40e_state & I40E_SUSPENDED) {
1048                 mutex_exit(&i40e->i40e_general_lock);
1049                 return (ECANCELED);
1050         }
1051 
1052         switch (pr_num) {
1053         /*
1054          * These properties are always read-only across every device.
1055          */
1056         case MAC_PROP_DUPLEX:
1057         case MAC_PROP_SPEED:
1058         case MAC_PROP_STATUS:
1059         case MAC_PROP_ADV_100FDX_CAP:
1060         case MAC_PROP_ADV_1000FDX_CAP:
1061         case MAC_PROP_ADV_2500FDX_CAP:
1062         case MAC_PROP_ADV_5000FDX_CAP:
1063         case MAC_PROP_ADV_10GFDX_CAP:
1064         case MAC_PROP_ADV_25GFDX_CAP:
1065         case MAC_PROP_ADV_40GFDX_CAP:
1066                 ret = ENOTSUP;
1067                 break;
1068         /*
1069          * These are read-only at this time as we don't support configuring
1070          * auto-negotiation. See the theory statement in i40e_main.c.
1071          */
1072         case MAC_PROP_EN_100FDX_CAP:
1073         case MAC_PROP_EN_1000FDX_CAP:
1074         case MAC_PROP_EN_2500FDX_CAP:
1075         case MAC_PROP_EN_5000FDX_CAP:
1076         case MAC_PROP_EN_10GFDX_CAP:
1077         case MAC_PROP_EN_25GFDX_CAP:
1078         case MAC_PROP_EN_40GFDX_CAP:
1079         case MAC_PROP_AUTONEG:
1080         case MAC_PROP_FLOWCTRL:
1081                 ret = ENOTSUP;
1082                 break;
1083 
1084         case MAC_PROP_MTU:
1085                 bcopy(pr_val, &new_mtu, sizeof (new_mtu));
1086                 if (new_mtu == i40e->i40e_sdu)
1087                         break;
1088 
1089                 if (new_mtu < I40E_MIN_MTU ||
1090                     new_mtu > I40E_MAX_MTU) {
1091                         ret = EINVAL;
1092                         break;
1093                 }
1094 
1095                 if (i40e->i40e_state & I40E_STARTED) {


1219          * to, the values of the ADV_ and EN_ will always be the same.
1220          */
1221         case MAC_PROP_ADV_100FDX_CAP:
1222         case MAC_PROP_EN_100FDX_CAP:
1223                 if (pr_valsize < sizeof (uint8_t)) {
1224                         ret = EOVERFLOW;
1225                         break;
1226                 }
1227                 u8 = pr_val;
1228                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_100MB) != 0;
1229                 break;
1230         case MAC_PROP_ADV_1000FDX_CAP:
1231         case MAC_PROP_EN_1000FDX_CAP:
1232                 if (pr_valsize < sizeof (uint8_t)) {
1233                         ret = EOVERFLOW;
1234                         break;
1235                 }
1236                 u8 = pr_val;
1237                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_1GB) != 0;
1238                 break;
1239         case MAC_PROP_ADV_2500FDX_CAP:
1240         case MAC_PROP_EN_2500FDX_CAP:
1241                 if (pr_valsize < sizeof (uint8_t)) {
1242                         ret = EOVERFLOW;
1243                         break;
1244                 }
1245                 u8 = pr_val;
1246                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_2_5GB) != 0;
1247                 break;
1248         case MAC_PROP_ADV_5000FDX_CAP:
1249         case MAC_PROP_EN_5000FDX_CAP:
1250                 if (pr_valsize < sizeof (uint8_t)) {
1251                         ret = EOVERFLOW;
1252                         break;
1253                 }
1254                 u8 = pr_val;
1255                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_5GB) != 0;
1256                 break;
1257         case MAC_PROP_ADV_10GFDX_CAP:
1258         case MAC_PROP_EN_10GFDX_CAP:
1259                 if (pr_valsize < sizeof (uint8_t)) {
1260                         ret = EOVERFLOW;
1261                         break;
1262                 }
1263                 u8 = pr_val;
1264                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_10GB) != 0;
1265                 break;
1266         case MAC_PROP_ADV_25GFDX_CAP:
1267         case MAC_PROP_EN_25GFDX_CAP:
1268                 if (pr_valsize < sizeof (uint8_t)) {
1269                         ret = EOVERFLOW;
1270                         break;
1271                 }
1272                 u8 = pr_val;
1273                 *u8 = (i40e->i40e_phy.link_speed & I40E_LINK_SPEED_25GB) != 0;
1274                 break;
1275         case MAC_PROP_ADV_40GFDX_CAP:
1276         case MAC_PROP_EN_40GFDX_CAP: