net/ice/base: calculate logical PF ID
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 16 Sep 2021 09:52:53 +0000 (17:52 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 21 Sep 2021 12:33:18 +0000 (14:33 +0200)
In some devices, the function numbers used are non-contiguous. For
example, some two port devices will report as functions 0 and 2.

When distributing RSS and FDIR masks, which are global resources across
the active devices, it is required to have a contiguous PF id, which can
be described as a logical PF id. In the case above, function 0 would
have a logical PF id of 0, and function 2 would have a logical PF id of
1.

Using logical PF id can properly describe which slice of resources can
be used by a particular PF.

Cc: stable@dpdk.org
Signed-off-by: Dan Nowlin <dan.nowlin@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
drivers/net/ice/base/ice_common.c
drivers/net/ice/base/ice_flex_pipe.c
drivers/net/ice/base/ice_type.h

index 641859f..6004c95 100644 (file)
@@ -2535,6 +2535,23 @@ ice_parse_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
        ice_recalc_port_limited_caps(hw, &func_p->common_cap);
 }
 
+/**
+ * ice_func_id_to_logical_id - map from function id to logical pf id
+ * @active_function_bitmap: active function bitmap
+ * @pf_id: function number of device
+ */
+static int ice_func_id_to_logical_id(u32 active_function_bitmap, u8 pf_id)
+{
+       u8 logical_id = 0;
+       u8 i;
+
+       for (i = 0; i < pf_id; i++)
+               if (active_function_bitmap & BIT(i))
+                       logical_id++;
+
+       return logical_id;
+}
+
 /**
  * ice_parse_valid_functions_cap - Parse ICE_AQC_CAPS_VALID_FUNCTIONS caps
  * @hw: pointer to the HW struct
@@ -2552,6 +2569,8 @@ ice_parse_valid_functions_cap(struct ice_hw *hw, struct ice_hw_dev_caps *dev_p,
        dev_p->num_funcs = ice_hweight32(number);
        ice_debug(hw, ICE_DBG_INIT, "dev caps: num_funcs = %d\n",
                  dev_p->num_funcs);
+
+       hw->logical_pf_id = ice_func_id_to_logical_id(number, hw->pf_id);
 }
 
 /**
index fd98b38..8a6fc8a 100644 (file)
@@ -3432,7 +3432,7 @@ static void ice_init_prof_masks(struct ice_hw *hw, enum ice_block blk)
        per_pf = ICE_PROF_MASK_COUNT / hw->dev_caps.num_funcs;
 
        hw->blk[blk].masks.count = per_pf;
-       hw->blk[blk].masks.first = hw->pf_id * per_pf;
+       hw->blk[blk].masks.first = hw->logical_pf_id * per_pf;
 
        ice_memset(hw->blk[blk].masks.masks, 0,
                   sizeof(hw->blk[blk].masks.masks), ICE_NONDMA_MEM);
index 56ee628..b1e03b1 100644 (file)
@@ -1132,6 +1132,7 @@ struct ice_hw {
        u8 revision_id;
 
        u8 pf_id;               /* device profile info */
+       u8 logical_pf_id;
 
        u16 max_burst_size;     /* driver sets this value */