|
@@ -542,6 +542,134 @@ error_alloc_vsi_res:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * i40e_enable_vf_mappings
|
|
|
|
+ * @vf: pointer to the vf info
|
|
|
|
+ *
|
|
|
|
+ * enable vf mappings
|
|
|
|
+ **/
|
|
|
|
+static void i40e_enable_vf_mappings(struct i40e_vf *vf)
|
|
|
|
+{
|
|
|
|
+ struct i40e_pf *pf = vf->pf;
|
|
|
|
+ struct i40e_hw *hw = &pf->hw;
|
|
|
|
+ u32 reg, total_queue_pairs = 0;
|
|
|
|
+ int j;
|
|
|
|
+
|
|
|
|
+ /* Tell the hardware we're using noncontiguous mapping. HW requires
|
|
|
|
+ * that VF queues be mapped using this method, even when they are
|
|
|
|
+ * contiguous in real life
|
|
|
|
+ */
|
|
|
|
+ wr32(hw, I40E_VSILAN_QBASE(vf->lan_vsi_id),
|
|
|
|
+ I40E_VSILAN_QBASE_VSIQTABLE_ENA_MASK);
|
|
|
|
+
|
|
|
|
+ /* enable VF vplan_qtable mappings */
|
|
|
|
+ reg = I40E_VPLAN_MAPENA_TXRX_ENA_MASK;
|
|
|
|
+ wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), reg);
|
|
|
|
+
|
|
|
|
+ /* map PF queues to VF queues */
|
|
|
|
+ for (j = 0; j < pf->vsi[vf->lan_vsi_index]->num_queue_pairs; j++) {
|
|
|
|
+ u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index, j);
|
|
|
|
+ reg = (qid & I40E_VPLAN_QTABLE_QINDEX_MASK);
|
|
|
|
+ wr32(hw, I40E_VPLAN_QTABLE(total_queue_pairs, vf->vf_id), reg);
|
|
|
|
+ total_queue_pairs++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* map PF queues to VSI */
|
|
|
|
+ for (j = 0; j < 7; j++) {
|
|
|
|
+ if (j * 2 >= pf->vsi[vf->lan_vsi_index]->num_queue_pairs) {
|
|
|
|
+ reg = 0x07FF07FF; /* unused */
|
|
|
|
+ } else {
|
|
|
|
+ u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index,
|
|
|
|
+ j * 2);
|
|
|
|
+ reg = qid;
|
|
|
|
+ qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index,
|
|
|
|
+ (j * 2) + 1);
|
|
|
|
+ reg |= qid << 16;
|
|
|
|
+ }
|
|
|
|
+ wr32(hw, I40E_VSILAN_QTABLE(j, vf->lan_vsi_id), reg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ i40e_flush(hw);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * i40e_disable_vf_mappings
|
|
|
|
+ * @vf: pointer to the vf info
|
|
|
|
+ *
|
|
|
|
+ * disable vf mappings
|
|
|
|
+ **/
|
|
|
|
+static void i40e_disable_vf_mappings(struct i40e_vf *vf)
|
|
|
|
+{
|
|
|
|
+ struct i40e_pf *pf = vf->pf;
|
|
|
|
+ struct i40e_hw *hw = &pf->hw;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ /* disable qp mappings */
|
|
|
|
+ wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), 0);
|
|
|
|
+ for (i = 0; i < I40E_MAX_VSI_QP; i++)
|
|
|
|
+ wr32(hw, I40E_VPLAN_QTABLE(i, vf->vf_id),
|
|
|
|
+ I40E_QUEUE_END_OF_LIST);
|
|
|
|
+ i40e_flush(hw);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * i40e_free_vf_res
|
|
|
|
+ * @vf: pointer to the vf info
|
|
|
|
+ *
|
|
|
|
+ * free vf resources
|
|
|
|
+ **/
|
|
|
|
+static void i40e_free_vf_res(struct i40e_vf *vf)
|
|
|
|
+{
|
|
|
|
+ struct i40e_pf *pf = vf->pf;
|
|
|
|
+
|
|
|
|
+ /* free vsi & disconnect it from the parent uplink */
|
|
|
|
+ if (vf->lan_vsi_index) {
|
|
|
|
+ i40e_vsi_release(pf->vsi[vf->lan_vsi_index]);
|
|
|
|
+ vf->lan_vsi_index = 0;
|
|
|
|
+ vf->lan_vsi_id = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* reset some of the state varibles keeping
|
|
|
|
+ * track of the resources
|
|
|
|
+ */
|
|
|
|
+ vf->num_queue_pairs = 0;
|
|
|
|
+ vf->vf_states = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * i40e_alloc_vf_res
|
|
|
|
+ * @vf: pointer to the vf info
|
|
|
|
+ *
|
|
|
|
+ * allocate vf resources
|
|
|
|
+ **/
|
|
|
|
+static int i40e_alloc_vf_res(struct i40e_vf *vf)
|
|
|
|
+{
|
|
|
|
+ struct i40e_pf *pf = vf->pf;
|
|
|
|
+ int total_queue_pairs = 0;
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ /* allocate hw vsi context & associated resources */
|
|
|
|
+ ret = i40e_alloc_vsi_res(vf, I40E_VSI_SRIOV);
|
|
|
|
+ if (ret)
|
|
|
|
+ goto error_alloc;
|
|
|
|
+ total_queue_pairs += pf->vsi[vf->lan_vsi_index]->num_queue_pairs;
|
|
|
|
+ set_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);
|
|
|
|
+
|
|
|
|
+ /* store the total qps number for the runtime
|
|
|
|
+ * vf req validation
|
|
|
|
+ */
|
|
|
|
+ vf->num_queue_pairs = total_queue_pairs;
|
|
|
|
+
|
|
|
|
+ /* vf is now completely initialized */
|
|
|
|
+ set_bit(I40E_VF_STAT_INIT, &vf->vf_states);
|
|
|
|
+
|
|
|
|
+error_alloc:
|
|
|
|
+ if (ret)
|
|
|
|
+ i40e_free_vf_res(vf);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* i40e_reset_vf
|
|
* i40e_reset_vf
|
|
* @vf: pointer to the vf structure
|
|
* @vf: pointer to the vf structure
|
|
@@ -672,134 +800,6 @@ int i40e_reset_vf(struct i40e_vf *vf, bool flr)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * i40e_enable_vf_mappings
|
|
|
|
- * @vf: pointer to the vf info
|
|
|
|
- *
|
|
|
|
- * enable vf mappings
|
|
|
|
- **/
|
|
|
|
-static void i40e_enable_vf_mappings(struct i40e_vf *vf)
|
|
|
|
-{
|
|
|
|
- struct i40e_pf *pf = vf->pf;
|
|
|
|
- struct i40e_hw *hw = &pf->hw;
|
|
|
|
- u32 reg, total_queue_pairs = 0;
|
|
|
|
- int j;
|
|
|
|
-
|
|
|
|
- /* Tell the hardware we're using noncontiguous mapping. HW requires
|
|
|
|
- * that VF queues be mapped using this method, even when they are
|
|
|
|
- * contiguous in real life
|
|
|
|
- */
|
|
|
|
- wr32(hw, I40E_VSILAN_QBASE(vf->lan_vsi_id),
|
|
|
|
- I40E_VSILAN_QBASE_VSIQTABLE_ENA_MASK);
|
|
|
|
-
|
|
|
|
- /* enable VF vplan_qtable mappings */
|
|
|
|
- reg = I40E_VPLAN_MAPENA_TXRX_ENA_MASK;
|
|
|
|
- wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), reg);
|
|
|
|
-
|
|
|
|
- /* map PF queues to VF queues */
|
|
|
|
- for (j = 0; j < pf->vsi[vf->lan_vsi_index]->num_queue_pairs; j++) {
|
|
|
|
- u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index, j);
|
|
|
|
- reg = (qid & I40E_VPLAN_QTABLE_QINDEX_MASK);
|
|
|
|
- wr32(hw, I40E_VPLAN_QTABLE(total_queue_pairs, vf->vf_id), reg);
|
|
|
|
- total_queue_pairs++;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* map PF queues to VSI */
|
|
|
|
- for (j = 0; j < 7; j++) {
|
|
|
|
- if (j * 2 >= pf->vsi[vf->lan_vsi_index]->num_queue_pairs) {
|
|
|
|
- reg = 0x07FF07FF; /* unused */
|
|
|
|
- } else {
|
|
|
|
- u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index,
|
|
|
|
- j * 2);
|
|
|
|
- reg = qid;
|
|
|
|
- qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index,
|
|
|
|
- (j * 2) + 1);
|
|
|
|
- reg |= qid << 16;
|
|
|
|
- }
|
|
|
|
- wr32(hw, I40E_VSILAN_QTABLE(j, vf->lan_vsi_id), reg);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- i40e_flush(hw);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * i40e_disable_vf_mappings
|
|
|
|
- * @vf: pointer to the vf info
|
|
|
|
- *
|
|
|
|
- * disable vf mappings
|
|
|
|
- **/
|
|
|
|
-static void i40e_disable_vf_mappings(struct i40e_vf *vf)
|
|
|
|
-{
|
|
|
|
- struct i40e_pf *pf = vf->pf;
|
|
|
|
- struct i40e_hw *hw = &pf->hw;
|
|
|
|
- int i;
|
|
|
|
-
|
|
|
|
- /* disable qp mappings */
|
|
|
|
- wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), 0);
|
|
|
|
- for (i = 0; i < I40E_MAX_VSI_QP; i++)
|
|
|
|
- wr32(hw, I40E_VPLAN_QTABLE(i, vf->vf_id),
|
|
|
|
- I40E_QUEUE_END_OF_LIST);
|
|
|
|
- i40e_flush(hw);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * i40e_free_vf_res
|
|
|
|
- * @vf: pointer to the vf info
|
|
|
|
- *
|
|
|
|
- * free vf resources
|
|
|
|
- **/
|
|
|
|
-static void i40e_free_vf_res(struct i40e_vf *vf)
|
|
|
|
-{
|
|
|
|
- struct i40e_pf *pf = vf->pf;
|
|
|
|
-
|
|
|
|
- /* free vsi & disconnect it from the parent uplink */
|
|
|
|
- if (vf->lan_vsi_index) {
|
|
|
|
- i40e_vsi_release(pf->vsi[vf->lan_vsi_index]);
|
|
|
|
- vf->lan_vsi_index = 0;
|
|
|
|
- vf->lan_vsi_id = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* reset some of the state varibles keeping
|
|
|
|
- * track of the resources
|
|
|
|
- */
|
|
|
|
- vf->num_queue_pairs = 0;
|
|
|
|
- vf->vf_states = 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * i40e_alloc_vf_res
|
|
|
|
- * @vf: pointer to the vf info
|
|
|
|
- *
|
|
|
|
- * allocate vf resources
|
|
|
|
- **/
|
|
|
|
-static int i40e_alloc_vf_res(struct i40e_vf *vf)
|
|
|
|
-{
|
|
|
|
- struct i40e_pf *pf = vf->pf;
|
|
|
|
- int total_queue_pairs = 0;
|
|
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- /* allocate hw vsi context & associated resources */
|
|
|
|
- ret = i40e_alloc_vsi_res(vf, I40E_VSI_SRIOV);
|
|
|
|
- if (ret)
|
|
|
|
- goto error_alloc;
|
|
|
|
- total_queue_pairs += pf->vsi[vf->lan_vsi_index]->num_queue_pairs;
|
|
|
|
- set_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);
|
|
|
|
-
|
|
|
|
- /* store the total qps number for the runtime
|
|
|
|
- * vf req validation
|
|
|
|
- */
|
|
|
|
- vf->num_queue_pairs = total_queue_pairs;
|
|
|
|
-
|
|
|
|
- /* vf is now completely initialized */
|
|
|
|
- set_bit(I40E_VF_STAT_INIT, &vf->vf_states);
|
|
|
|
-
|
|
|
|
-error_alloc:
|
|
|
|
- if (ret)
|
|
|
|
- i40e_free_vf_res(vf);
|
|
|
|
-
|
|
|
|
- return ret;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* i40e_vfs_are_assigned
|
|
* i40e_vfs_are_assigned
|
|
* @pf: pointer to the pf structure
|
|
* @pf: pointer to the pf structure
|