net/ice/base: fix build with GCC 12
[dpdk.git] / drivers / net / ice / ice_dcf.c
index 084f7a5..885d58c 100644 (file)
@@ -166,7 +166,7 @@ ice_dcf_handle_virtchnl_msg(struct ice_dcf_hw *hw)
        info.buf_len = ICE_DCF_AQ_BUF_SZ;
        info.msg_buf = hw->arq_buf;
 
-       while (pending) {
+       while (pending && !hw->resetting) {
                ret = iavf_clean_arq_element(&hw->avf, &info, &pending);
                if (ret != IAVF_SUCCESS)
                        break;
@@ -587,12 +587,37 @@ ice_dcf_get_supported_rxdid(struct ice_dcf_hw *hw)
        return 0;
 }
 
+static int
+dcf_get_vlan_offload_caps_v2(struct ice_dcf_hw *hw)
+{
+       struct virtchnl_vlan_caps vlan_v2_caps;
+       struct dcf_virtchnl_cmd args;
+       int ret;
+
+       memset(&args, 0, sizeof(args));
+       args.v_op = VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS;
+       args.rsp_msgbuf = (uint8_t *)&vlan_v2_caps;
+       args.rsp_buflen = sizeof(vlan_v2_caps);
+
+       ret = ice_dcf_execute_virtchnl_cmd(hw, &args);
+       if (ret) {
+               PMD_DRV_LOG(ERR,
+                           "Failed to execute command of VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS");
+               return ret;
+       }
+
+       rte_memcpy(&hw->vlan_v2_caps, &vlan_v2_caps, sizeof(vlan_v2_caps));
+       return 0;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        int ret, size;
 
+       hw->resetting = false;
+
        hw->avf.hw_addr = pci_dev->mem_resource[0].addr;
        hw->avf.back = hw;
 
@@ -699,6 +724,10 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
        rte_intr_enable(pci_dev->intr_handle);
        ice_dcf_enable_irq0(hw);
 
+       if ((hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2) &&
+           dcf_get_vlan_offload_caps_v2(hw))
+               goto err_rss;
+
        return 0;
 
 err_rss:
@@ -756,7 +785,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
        hw->ets_config = NULL;
 }
 
-static int
+int
 ice_dcf_configure_rss_key(struct ice_dcf_hw *hw)
 {
        struct virtchnl_rss_key *rss_key;
@@ -788,7 +817,7 @@ ice_dcf_configure_rss_key(struct ice_dcf_hw *hw)
        return err;
 }
 
-static int
+int
 ice_dcf_configure_rss_lut(struct ice_dcf_hw *hw)
 {
        struct virtchnl_rss_lut *rss_lut;
@@ -862,7 +891,7 @@ ice_dcf_init_rss(struct ice_dcf_hw *hw)
                        j = 0;
                hw->rss_lut[i] = j;
        }
-       /* send virtchnnl ops to configure rss*/
+       /* send virtchnl ops to configure RSS */
        ret = ice_dcf_configure_rss_lut(hw);
        if (ret)
                return ret;
@@ -1087,10 +1116,11 @@ ice_dcf_query_stats(struct ice_dcf_hw *hw,
 }
 
 int
-ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add)
+ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw,
+                            struct rte_ether_addr *addr,
+                            bool add, uint8_t type)
 {
        struct virtchnl_ether_addr_list *list;
-       struct rte_ether_addr *addr;
        struct dcf_virtchnl_cmd args;
        int len, err = 0;
 
@@ -1103,7 +1133,6 @@ ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add)
        }
 
        len = sizeof(struct virtchnl_ether_addr_list);
-       addr = hw->eth_dev->data->mac_addrs;
        len += sizeof(struct virtchnl_ether_addr);
 
        list = rte_zmalloc(NULL, len, 0);
@@ -1114,9 +1143,10 @@ ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add)
 
        rte_memcpy(list->list[0].addr, addr->addr_bytes,
                        sizeof(addr->addr_bytes));
+
        PMD_DRV_LOG(DEBUG, "add/rm mac:" RTE_ETHER_ADDR_PRT_FMT,
                            RTE_ETHER_ADDR_BYTES(addr));
-
+       list->list[0].type = type;
        list->vsi_id = hw->vsi_res->vsi_id;
        list->num_elements = 1;