|
9 | 9 | #include <linux/types.h>
|
10 | 10 | #include <linux/avf/virtchnl.h>
|
11 | 11 | #include <linux/net/intel/i40e_client.h>
|
| 12 | +#include <net/devlink.h> |
12 | 13 | #include <net/pkt_cls.h>
|
13 | 14 | #include <net/udp_tunnel.h>
|
14 | 15 | #include "i40e_dcb.h"
|
15 | 16 | #include "i40e_debug.h"
|
| 17 | +#include "i40e_devlink.h" |
16 | 18 | #include "i40e_io.h"
|
17 | 19 | #include "i40e_prototype.h"
|
18 | 20 | #include "i40e_register.h"
|
|
47 | 49 | #define I40E_QUEUE_WAIT_RETRY_LIMIT 10
|
48 | 50 | #define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 16)
|
49 | 51 |
|
50 |
| -#define I40E_NVM_VERSION_LO_SHIFT 0 |
51 |
| -#define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT) |
52 |
| -#define I40E_NVM_VERSION_HI_SHIFT 12 |
53 |
| -#define I40E_NVM_VERSION_HI_MASK (0xf << I40E_NVM_VERSION_HI_SHIFT) |
54 |
| -#define I40E_OEM_VER_BUILD_MASK 0xffff |
55 |
| -#define I40E_OEM_VER_PATCH_MASK 0xff |
56 |
| -#define I40E_OEM_VER_BUILD_SHIFT 8 |
57 |
| -#define I40E_OEM_VER_SHIFT 24 |
58 | 52 | #define I40E_PHY_DEBUG_ALL \
|
59 | 53 | (I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW | \
|
60 | 54 | I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW)
|
61 | 55 |
|
62 | 56 | #define I40E_OEM_EETRACK_ID 0xffffffff
|
63 |
| -#define I40E_OEM_GEN_SHIFT 24 |
64 |
| -#define I40E_OEM_SNAP_MASK 0x00ff0000 |
65 |
| -#define I40E_OEM_SNAP_SHIFT 16 |
66 |
| -#define I40E_OEM_RELEASE_MASK 0x0000ffff |
| 57 | +#define I40E_NVM_VERSION_LO_MASK GENMASK(7, 0) |
| 58 | +#define I40E_NVM_VERSION_HI_MASK GENMASK(15, 12) |
| 59 | +#define I40E_OEM_VER_BUILD_MASK GENMASK(23, 8) |
| 60 | +#define I40E_OEM_VER_PATCH_MASK GENMASK(7, 0) |
| 61 | +#define I40E_OEM_VER_MASK GENMASK(31, 24) |
| 62 | +#define I40E_OEM_GEN_MASK GENMASK(31, 24) |
| 63 | +#define I40E_OEM_SNAP_MASK GENMASK(23, 16) |
| 64 | +#define I40E_OEM_RELEASE_MASK GENMASK(15, 0) |
67 | 65 |
|
68 | 66 | #define I40E_RX_DESC(R, i) \
|
69 | 67 | (&(((union i40e_rx_desc *)((R)->desc))[i]))
|
@@ -411,6 +409,7 @@ static inline const u8 *i40e_channel_mac(struct i40e_channel *ch)
|
411 | 409 | /* struct that defines the Ethernet device */
|
412 | 410 | struct i40e_pf {
|
413 | 411 | struct pci_dev *pdev;
|
| 412 | + struct devlink_port devlink_port; |
414 | 413 | struct i40e_hw hw;
|
415 | 414 | DECLARE_BITMAP(state, __I40E_STATE_SIZE__);
|
416 | 415 | struct msix_entry *msix_entries;
|
@@ -951,43 +950,104 @@ struct i40e_device {
|
951 | 950 | };
|
952 | 951 |
|
953 | 952 | /**
|
954 |
| - * i40e_nvm_version_str - format the NVM version strings |
| 953 | + * i40e_info_nvm_ver - format the NVM version string |
955 | 954 | * @hw: ptr to the hardware info
|
| 955 | + * @buf: string buffer to store |
| 956 | + * @len: buffer size |
| 957 | + * |
| 958 | + * Formats NVM version string as: |
| 959 | + * <gen>.<snap>.<release> when eetrackid == I40E_OEM_EETRACK_ID |
| 960 | + * <nvm_major>.<nvm_minor> otherwise |
956 | 961 | **/
|
957 |
| -static inline char *i40e_nvm_version_str(struct i40e_hw *hw) |
| 962 | +static inline void i40e_info_nvm_ver(struct i40e_hw *hw, char *buf, size_t len) |
958 | 963 | {
|
959 |
| - static char buf[32]; |
960 |
| - u32 full_ver; |
| 964 | + struct i40e_nvm_info *nvm = &hw->nvm; |
961 | 965 |
|
962 |
| - full_ver = hw->nvm.oem_ver; |
963 |
| - |
964 |
| - if (hw->nvm.eetrack == I40E_OEM_EETRACK_ID) { |
| 966 | + if (nvm->eetrack == I40E_OEM_EETRACK_ID) { |
| 967 | + u32 full_ver = nvm->oem_ver; |
965 | 968 | u8 gen, snap;
|
966 | 969 | u16 release;
|
967 | 970 |
|
968 |
| - gen = (u8)(full_ver >> I40E_OEM_GEN_SHIFT); |
969 |
| - snap = (u8)((full_ver & I40E_OEM_SNAP_MASK) >> |
970 |
| - I40E_OEM_SNAP_SHIFT); |
971 |
| - release = (u16)(full_ver & I40E_OEM_RELEASE_MASK); |
972 |
| - |
973 |
| - snprintf(buf, sizeof(buf), "%x.%x.%x", gen, snap, release); |
| 971 | + gen = FIELD_GET(I40E_OEM_GEN_MASK, full_ver); |
| 972 | + snap = FIELD_GET(I40E_OEM_SNAP_MASK, full_ver); |
| 973 | + release = FIELD_GET(I40E_OEM_RELEASE_MASK, full_ver); |
| 974 | + snprintf(buf, len, "%x.%x.%x", gen, snap, release); |
974 | 975 | } else {
|
975 |
| - u8 ver, patch; |
| 976 | + u8 major, minor; |
| 977 | + |
| 978 | + major = FIELD_GET(I40E_NVM_VERSION_HI_MASK, nvm->version); |
| 979 | + minor = FIELD_GET(I40E_NVM_VERSION_LO_MASK, nvm->version); |
| 980 | + snprintf(buf, len, "%x.%02x", major, minor); |
| 981 | + } |
| 982 | +} |
| 983 | + |
| 984 | +/** |
| 985 | + * i40e_info_eetrack - format the EETrackID string |
| 986 | + * @hw: ptr to the hardware info |
| 987 | + * @buf: string buffer to store |
| 988 | + * @len: buffer size |
| 989 | + * |
| 990 | + * Returns hexadecimally formated EETrackID if it is |
| 991 | + * different from I40E_OEM_EETRACK_ID or empty string. |
| 992 | + **/ |
| 993 | +static inline void i40e_info_eetrack(struct i40e_hw *hw, char *buf, size_t len) |
| 994 | +{ |
| 995 | + struct i40e_nvm_info *nvm = &hw->nvm; |
| 996 | + |
| 997 | + buf[0] = '\0'; |
| 998 | + if (nvm->eetrack != I40E_OEM_EETRACK_ID) |
| 999 | + snprintf(buf, len, "0x%08x", nvm->eetrack); |
| 1000 | +} |
| 1001 | + |
| 1002 | +/** |
| 1003 | + * i40e_info_civd_ver - format the NVM version strings |
| 1004 | + * @hw: ptr to the hardware info |
| 1005 | + * @buf: string buffer to store |
| 1006 | + * @len: buffer size |
| 1007 | + * |
| 1008 | + * Returns formated combo image version if adapter's EETrackID is |
| 1009 | + * different from I40E_OEM_EETRACK_ID or empty string. |
| 1010 | + **/ |
| 1011 | +static inline void i40e_info_civd_ver(struct i40e_hw *hw, char *buf, size_t len) |
| 1012 | +{ |
| 1013 | + struct i40e_nvm_info *nvm = &hw->nvm; |
| 1014 | + |
| 1015 | + buf[0] = '\0'; |
| 1016 | + if (nvm->eetrack != I40E_OEM_EETRACK_ID) { |
| 1017 | + u32 full_ver = nvm->oem_ver; |
| 1018 | + u8 major, minor; |
976 | 1019 | u16 build;
|
977 | 1020 |
|
978 |
| - ver = (u8)(full_ver >> I40E_OEM_VER_SHIFT); |
979 |
| - build = (u16)((full_ver >> I40E_OEM_VER_BUILD_SHIFT) & |
980 |
| - I40E_OEM_VER_BUILD_MASK); |
981 |
| - patch = (u8)(full_ver & I40E_OEM_VER_PATCH_MASK); |
982 |
| - |
983 |
| - snprintf(buf, sizeof(buf), |
984 |
| - "%x.%02x 0x%x %d.%d.%d", |
985 |
| - (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >> |
986 |
| - I40E_NVM_VERSION_HI_SHIFT, |
987 |
| - (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >> |
988 |
| - I40E_NVM_VERSION_LO_SHIFT, |
989 |
| - hw->nvm.eetrack, ver, build, patch); |
| 1021 | + major = FIELD_GET(I40E_OEM_VER_MASK, full_ver); |
| 1022 | + build = FIELD_GET(I40E_OEM_VER_BUILD_MASK, full_ver); |
| 1023 | + minor = FIELD_GET(I40E_OEM_VER_PATCH_MASK, full_ver); |
| 1024 | + snprintf(buf, len, "%d.%d.%d", major, build, minor); |
990 | 1025 | }
|
| 1026 | +} |
| 1027 | + |
| 1028 | +/** |
| 1029 | + * i40e_nvm_version_str - format the NVM version strings |
| 1030 | + * @hw: ptr to the hardware info |
| 1031 | + * @buf: string buffer to store |
| 1032 | + * @len: buffer size |
| 1033 | + **/ |
| 1034 | +static inline char *i40e_nvm_version_str(struct i40e_hw *hw, char *buf, |
| 1035 | + size_t len) |
| 1036 | +{ |
| 1037 | + char ver[16] = " "; |
| 1038 | + |
| 1039 | + /* Get NVM version */ |
| 1040 | + i40e_info_nvm_ver(hw, buf, len); |
| 1041 | + |
| 1042 | + /* Append EETrackID if provided */ |
| 1043 | + i40e_info_eetrack(hw, &ver[1], sizeof(ver) - 1); |
| 1044 | + if (strlen(ver) > 1) |
| 1045 | + strlcat(buf, ver, len); |
| 1046 | + |
| 1047 | + /* Append combo image version if provided */ |
| 1048 | + i40e_info_civd_ver(hw, &ver[1], sizeof(ver) - 1); |
| 1049 | + if (strlen(ver) > 1) |
| 1050 | + strlcat(buf, ver, len); |
991 | 1051 |
|
992 | 1052 | return buf;
|
993 | 1053 | }
|
|
0 commit comments