ena module for Driver Update Program
CentOS Sources
2019-01-09 fc384122a7a805dde4dbbf3c4c4ef94a5ca0f2fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Date: Tue, 30 Oct 2018 13:25:31 -0400
From: linville@redhat.com
To: rhkernel-list@redhat.com
Cc: Lin Liu <linl@redhat.com>
Subject: [RHEL7 16/28] net: ena: complete host info to match latest ENA spec
 
From: "John W. Linville" <linville@redhat.com>
 
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1633418
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18850510
 
Add new fields and definitions to host info and fill them
according to the latest ENA spec version.
 
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 095f2f1facba0c78f23750dba65c78cef722c1ea)
Signed-off-by: John W. Linville <linville@redhat.com>
---
 .../net/ethernet/amazon/ena/ena_admin_defs.h  | 31 ++++++++++++++++++-
 drivers/net/ethernet/amazon/ena/ena_com.c     | 12 +++----
 .../net/ethernet/amazon/ena/ena_common_defs.h |  4 +--
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 10 ++++--
 4 files changed, 43 insertions(+), 14 deletions(-)
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_admin_defs.h b/drivers/net/ethernet/amazon/ena/ena_admin_defs.h
index 4532e574ebcd..d735164efea3 100644
--- a/drivers/net/ethernet/amazon/ena/ena_admin_defs.h
+++ b/drivers/net/ethernet/amazon/ena/ena_admin_defs.h
@@ -63,6 +63,8 @@ enum ena_admin_aq_completion_status {
     ENA_ADMIN_ILLEGAL_PARAMETER        = 5,
 
     ENA_ADMIN_UNKNOWN_ERROR            = 6,
+
+    ENA_ADMIN_RESOURCE_BUSY                 = 7,
 };
 
 enum ena_admin_aq_feature_id {
@@ -702,6 +704,10 @@ enum ena_admin_os_type {
     ENA_ADMIN_OS_FREEBSD    = 4,
 
     ENA_ADMIN_OS_IPXE    = 5,
+
+    ENA_ADMIN_OS_ESXI       = 6,
+
+    ENA_ADMIN_OS_GROUPS_NUM = 6,
 };
 
 struct ena_admin_host_info {
@@ -723,11 +729,27 @@ struct ena_admin_host_info {
     /* 7:0 : major
      * 15:8 : minor
      * 23:16 : sub_minor
+     * 31:24 : module_type
      */
     u32 driver_version;
 
     /* features bitmap */
-    u32 supported_network_features[4];
+    u32 supported_network_features[2];
+
+    /* ENA spec version of driver */
+    u16 ena_spec_version;
+
+    /* ENA device's Bus, Device and Function
+     * 2:0 : function
+     * 7:3 : device
+     * 15:8 : bus
+     */
+    u16 bdf;
+
+    /* Number of CPUs */
+    u16 num_cpus;
+
+    u16 reserved;
 };
 
 struct ena_admin_rss_ind_table_entry {
@@ -1008,6 +1030,13 @@ struct ena_admin_ena_mmio_req_read_less_resp {
 #define ENA_ADMIN_HOST_INFO_MINOR_MASK GENMASK(15, 8)
 #define ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT 16
 #define ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK GENMASK(23, 16)
+#define ENA_ADMIN_HOST_INFO_MODULE_TYPE_SHIFT 24
+#define ENA_ADMIN_HOST_INFO_MODULE_TYPE_MASK GENMASK(31, 24)
+#define ENA_ADMIN_HOST_INFO_FUNCTION_MASK GENMASK(2, 0)
+#define ENA_ADMIN_HOST_INFO_DEVICE_SHIFT 3
+#define ENA_ADMIN_HOST_INFO_DEVICE_MASK GENMASK(7, 3)
+#define ENA_ADMIN_HOST_INFO_BUS_SHIFT 8
+#define ENA_ADMIN_HOST_INFO_BUS_MASK GENMASK(15, 8)
 
 /* aenq_common_desc */
 #define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 7635c38e77dd..b6e6a4721931 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -41,9 +41,6 @@
 #define ENA_ASYNC_QUEUE_DEPTH 16
 #define ENA_ADMIN_QUEUE_DEPTH 32
 
-#define MIN_ENA_VER (((ENA_COMMON_SPEC_VERSION_MAJOR) << \
-        ENA_REGS_VERSION_MAJOR_VERSION_SHIFT) \
-        | (ENA_COMMON_SPEC_VERSION_MINOR))
 
 #define ENA_CTRL_MAJOR        0
 #define ENA_CTRL_MINOR        0
@@ -1400,11 +1397,6 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
             ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
         ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
 
-    if (ver < MIN_ENA_VER) {
-        pr_err("ENA version is lower than the minimal version the driver supports\n");
-        return -1;
-    }
-
     pr_info("ena controller version: %d.%d.%d implementation version %d\n",
         (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) >>
             ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
@@ -2441,6 +2433,10 @@ int ena_com_allocate_host_info(struct ena_com_dev *ena_dev)
     if (unlikely(!host_attr->host_info))
         return -ENOMEM;
 
+    host_attr->host_info->ena_spec_version =
+        ((ENA_COMMON_SPEC_VERSION_MAJOR << ENA_REGS_VERSION_MAJOR_VERSION_SHIFT) |
+        (ENA_COMMON_SPEC_VERSION_MINOR));
+
     return 0;
 }
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_common_defs.h b/drivers/net/ethernet/amazon/ena/ena_common_defs.h
index bb8d73676eab..23beb7e7ed7b 100644
--- a/drivers/net/ethernet/amazon/ena/ena_common_defs.h
+++ b/drivers/net/ethernet/amazon/ena/ena_common_defs.h
@@ -32,8 +32,8 @@
 #ifndef _ENA_COMMON_H_
 #define _ENA_COMMON_H_
 
-#define ENA_COMMON_SPEC_VERSION_MAJOR    0 /*  */
-#define ENA_COMMON_SPEC_VERSION_MINOR    10 /*  */
+#define ENA_COMMON_SPEC_VERSION_MAJOR        2
+#define ENA_COMMON_SPEC_VERSION_MINOR        0
 
 /* ENA operates with 48-bit memory addresses. ena_mem_addr_t */
 struct ena_common_mem_addr {
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index d7f050123f93..04a70b78091a 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2199,7 +2199,8 @@ static u16 ena_select_queue(struct net_device *dev, struct sk_buff *skb,
     return qid;
 }
 
-static void ena_config_host_info(struct ena_com_dev *ena_dev)
+static void ena_config_host_info(struct ena_com_dev *ena_dev,
+                 struct pci_dev *pdev)
 {
     struct ena_admin_host_info *host_info;
     int rc;
@@ -2213,6 +2214,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
 
     host_info = ena_dev->host_attr.host_info;
 
+    host_info->bdf = (pdev->bus->number << 8) | pdev->devfn;
     host_info->os_type = ENA_ADMIN_OS_LINUX;
     host_info->kernel_ver = LINUX_VERSION_CODE;
     strncpy(host_info->kernel_ver_str, utsname()->version,
@@ -2223,7 +2225,9 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
     host_info->driver_version =
         (DRV_MODULE_VER_MAJOR) |
         (DRV_MODULE_VER_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) |
-        (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT);
+        (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT) |
+        ("K"[0] << ENA_ADMIN_HOST_INFO_MODULE_TYPE_SHIFT);
+    host_info->num_cpus = num_online_cpus();
 
     rc = ena_com_set_host_attributes(ena_dev);
     if (rc) {
@@ -2448,7 +2452,7 @@ static int ena_device_init(struct ena_com_dev *ena_dev, struct pci_dev *pdev,
      */
     ena_com_set_admin_polling_mode(ena_dev, true);
 
-    ena_config_host_info(ena_dev);
+    ena_config_host_info(ena_dev, pdev);
 
     /* Get Device Attributes*/
     rc = ena_com_get_dev_attr_feat(ena_dev, get_feat_ctx);
-- 
2.17.1