|
@@ -330,6 +330,12 @@ static int hclgevf_set_handle_info(struct hclgevf_dev *hdev)
|
|
|
|
|
|
static void hclgevf_free_vector(struct hclgevf_dev *hdev, int vector_id)
|
|
|
{
|
|
|
+ if (hdev->vector_status[vector_id] == HCLGEVF_INVALID_VPORT) {
|
|
|
+ dev_warn(&hdev->pdev->dev,
|
|
|
+ "vector(vector_id %d) has been freed.\n", vector_id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
hdev->vector_status[vector_id] = HCLGEVF_INVALID_VPORT;
|
|
|
hdev->num_msi_left += 1;
|
|
|
hdev->num_msi_used -= 1;
|
|
@@ -547,24 +553,18 @@ static int hclgevf_get_tc_size(struct hnae3_handle *handle)
|
|
|
}
|
|
|
|
|
|
static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en,
|
|
|
- int vector,
|
|
|
+ int vector_id,
|
|
|
struct hnae3_ring_chain_node *ring_chain)
|
|
|
{
|
|
|
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
|
|
struct hnae3_ring_chain_node *node;
|
|
|
struct hclge_mbx_vf_to_pf_cmd *req;
|
|
|
struct hclgevf_desc desc;
|
|
|
- int i = 0, vector_id;
|
|
|
+ int i = 0;
|
|
|
int status;
|
|
|
u8 type;
|
|
|
|
|
|
req = (struct hclge_mbx_vf_to_pf_cmd *)desc.data;
|
|
|
- vector_id = hclgevf_get_vector_index(hdev, vector);
|
|
|
- if (vector_id < 0) {
|
|
|
- dev_err(&handle->pdev->dev,
|
|
|
- "Get vector index fail. ret =%d\n", vector_id);
|
|
|
- return vector_id;
|
|
|
- }
|
|
|
|
|
|
for (node = ring_chain; node; node = node->next) {
|
|
|
int idx_offset = HCLGE_MBX_RING_MAP_BASIC_MSG_NUM +
|
|
@@ -617,7 +617,17 @@ static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en,
|
|
|
static int hclgevf_map_ring_to_vector(struct hnae3_handle *handle, int vector,
|
|
|
struct hnae3_ring_chain_node *ring_chain)
|
|
|
{
|
|
|
- return hclgevf_bind_ring_to_vector(handle, true, vector, ring_chain);
|
|
|
+ struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
|
|
+ int vector_id;
|
|
|
+
|
|
|
+ vector_id = hclgevf_get_vector_index(hdev, vector);
|
|
|
+ if (vector_id < 0) {
|
|
|
+ dev_err(&handle->pdev->dev,
|
|
|
+ "Get vector index fail. ret =%d\n", vector_id);
|
|
|
+ return vector_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ return hclgevf_bind_ring_to_vector(handle, true, vector_id, ring_chain);
|
|
|
}
|
|
|
|
|
|
static int hclgevf_unmap_ring_from_vector(
|
|
@@ -635,7 +645,7 @@ static int hclgevf_unmap_ring_from_vector(
|
|
|
return vector_id;
|
|
|
}
|
|
|
|
|
|
- ret = hclgevf_bind_ring_to_vector(handle, false, vector, ring_chain);
|
|
|
+ ret = hclgevf_bind_ring_to_vector(handle, false, vector_id, ring_chain);
|
|
|
if (ret)
|
|
|
dev_err(&handle->pdev->dev,
|
|
|
"Unmap ring from vector fail. vector=%d, ret =%d\n",
|
|
@@ -1582,9 +1592,10 @@ static void hclgevf_misc_irq_uninit(struct hclgevf_dev *hdev)
|
|
|
hclgevf_free_vector(hdev, 0);
|
|
|
}
|
|
|
|
|
|
-static int hclgevf_init_instance(struct hclgevf_dev *hdev,
|
|
|
- struct hnae3_client *client)
|
|
|
+static int hclgevf_init_client_instance(struct hnae3_client *client,
|
|
|
+ struct hnae3_ae_dev *ae_dev)
|
|
|
{
|
|
|
+ struct hclgevf_dev *hdev = ae_dev->priv;
|
|
|
int ret;
|
|
|
|
|
|
switch (client->type) {
|
|
@@ -1635,9 +1646,11 @@ static int hclgevf_init_instance(struct hclgevf_dev *hdev,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void hclgevf_uninit_instance(struct hclgevf_dev *hdev,
|
|
|
- struct hnae3_client *client)
|
|
|
+static void hclgevf_uninit_client_instance(struct hnae3_client *client,
|
|
|
+ struct hnae3_ae_dev *ae_dev)
|
|
|
{
|
|
|
+ struct hclgevf_dev *hdev = ae_dev->priv;
|
|
|
+
|
|
|
/* un-init roce, if it exists */
|
|
|
if (hdev->roce_client)
|
|
|
hdev->roce_client->ops->uninit_instance(&hdev->roce, 0);
|
|
@@ -1648,22 +1661,6 @@ static void hclgevf_uninit_instance(struct hclgevf_dev *hdev,
|
|
|
client->ops->uninit_instance(&hdev->nic, 0);
|
|
|
}
|
|
|
|
|
|
-static int hclgevf_register_client(struct hnae3_client *client,
|
|
|
- struct hnae3_ae_dev *ae_dev)
|
|
|
-{
|
|
|
- struct hclgevf_dev *hdev = ae_dev->priv;
|
|
|
-
|
|
|
- return hclgevf_init_instance(hdev, client);
|
|
|
-}
|
|
|
-
|
|
|
-static void hclgevf_unregister_client(struct hnae3_client *client,
|
|
|
- struct hnae3_ae_dev *ae_dev)
|
|
|
-{
|
|
|
- struct hclgevf_dev *hdev = ae_dev->priv;
|
|
|
-
|
|
|
- hclgevf_uninit_instance(hdev, client);
|
|
|
-}
|
|
|
-
|
|
|
static int hclgevf_pci_init(struct hclgevf_dev *hdev)
|
|
|
{
|
|
|
struct pci_dev *pdev = hdev->pdev;
|
|
@@ -1924,8 +1921,8 @@ void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
|
|
|
static const struct hnae3_ae_ops hclgevf_ops = {
|
|
|
.init_ae_dev = hclgevf_init_ae_dev,
|
|
|
.uninit_ae_dev = hclgevf_uninit_ae_dev,
|
|
|
- .init_client_instance = hclgevf_register_client,
|
|
|
- .uninit_client_instance = hclgevf_unregister_client,
|
|
|
+ .init_client_instance = hclgevf_init_client_instance,
|
|
|
+ .uninit_client_instance = hclgevf_uninit_client_instance,
|
|
|
.start = hclgevf_ae_start,
|
|
|
.stop = hclgevf_ae_stop,
|
|
|
.map_ring_to_vector = hclgevf_map_ring_to_vector,
|