net: ena: complete host info to match latest ENA spec
authorArthur Kiyanovski <akiyano@amazon.com>
Thu, 11 Oct 2018 08:26:17 +0000 (11:26 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Oct 2018 17:13:50 +0000 (10:13 -0700)
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>
drivers/net/ethernet/amazon/ena/ena_admin_defs.h
drivers/net/ethernet/amazon/ena/ena_com.c
drivers/net/ethernet/amazon/ena/ena_common_defs.h
drivers/net/ethernet/amazon/ena/ena_netdev.c

index 4532e57..d735164 100644 (file)
@@ -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)
index 7635c38..b6e6a47 100644 (file)
@@ -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;
 }
 
index bb8d736..23beb7e 100644 (file)
@@ -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 {
index 13eb6a4..86fd01d 100644 (file)
@@ -2201,7 +2201,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;
@@ -2215,6 +2216,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,
@@ -2225,7 +2227,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) {
@@ -2449,7 +2453,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);