net/i40e/base: fix Geneve VNI for HW use
authorHelin Zhang <helin.zhang@intel.com>
Tue, 24 May 2016 06:22:59 +0000 (14:22 +0800)
committerBruce Richardson <bruce.richardson@intel.com>
Mon, 20 Jun 2016 15:21:50 +0000 (17:21 +0200)
The hardware doesn't layout the Geneve VNI (Virtual Network
Identifier) quite the same as the VxLAN VNI, so it needs to
adjust it before sending through the Admin Queue commands as the
workaround.

Fixes: 8db9e2a1b232 ("i40e: base driver")

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/i40e/base/i40e_common.c
drivers/net/i40e/base/i40e_osdep.h

index f7dff12..e958099 100644 (file)
@@ -5421,6 +5421,35 @@ void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
                DEBUGOUT("Ethtype Filter Add failed: Error pruning Tx flow control frames\n");
 }
 
+/**
+ * i40e_fix_up_geneve_vni - adjust Geneve VNI for HW issue
+ * @filters: list of cloud filters
+ * @filter_count: length of list
+ *
+ * There's an issue in the device where the Geneve VNI layout needs
+ * to be shifted 1 byte over from the VxLAN VNI
+ **/
+STATIC void i40e_fix_up_geneve_vni(
+       struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
+       u8 filter_count)
+{
+       struct i40e_aqc_add_remove_cloud_filters_element_data *f = filters;
+       int i;
+
+       for (i = 0; i < filter_count; i++) {
+               u16 tnl_type;
+               u32 ti;
+
+               tnl_type = (le16_to_cpu(f[i].flags) &
+                          I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+                          I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+               if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+                       ti = le32_to_cpu(f[i].tenant_id);
+                       f[i].tenant_id = cpu_to_le32(ti << 8);
+               }
+       }
+}
+
 /**
  * i40e_aq_add_cloud_filters
  * @hw: pointer to the hardware structure
@@ -5441,8 +5470,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
        struct i40e_aq_desc desc;
        struct i40e_aqc_add_remove_cloud_filters *cmd =
        (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
-       u16 buff_len;
        enum i40e_status_code status;
+       u16 buff_len;
 
        i40e_fill_default_direct_cmd_desc(&desc,
                                          i40e_aqc_opc_add_cloud_filters);
@@ -5453,6 +5482,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
        cmd->num_filters = filter_count;
        cmd->seid = CPU_TO_LE16(seid);
 
+       i40e_fix_up_geneve_vni(filters, filter_count);
+
        status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
 
        return status;
@@ -5490,6 +5521,8 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
        cmd->num_filters = filter_count;
        cmd->seid = CPU_TO_LE16(seid);
 
+       i40e_fix_up_geneve_vni(filters, filter_count);
+
        status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
 
        return status;
index 8c84ed8..38e7ba5 100644 (file)
@@ -204,6 +204,13 @@ struct i40e_virt_mem {
 #define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
 #define LE64_TO_CPU(k) rte_le_to_cpu_64(k)
 
+#define cpu_to_le16(o) rte_cpu_to_le_16(o)
+#define cpu_to_le32(s) rte_cpu_to_le_32(s)
+#define cpu_to_le64(h) rte_cpu_to_le_64(h)
+#define le16_to_cpu(a) rte_le_to_cpu_16(a)
+#define le32_to_cpu(c) rte_le_to_cpu_32(c)
+#define le64_to_cpu(k) rte_le_to_cpu_64(k)
+
 /* SW spinlock */
 struct i40e_spinlock {
        rte_spinlock_t spinlock;