net/i40e/base: support LLDP agent
[dpdk.git] / drivers / net / i40e / rte_pmd_i40e.c
index 7ae78e4..b64f553 100644 (file)
@@ -529,7 +529,7 @@ rte_pmd_i40e_set_vf_multicast_promisc(uint16_t port, uint16_t vf_id, uint8_t on)
 
 int
 rte_pmd_i40e_set_vf_mac_addr(uint16_t port, uint16_t vf_id,
-                            struct ether_addr *mac_addr)
+                            struct rte_ether_addr *mac_addr)
 {
        struct i40e_mac_filter *f;
        struct rte_eth_dev *dev;
@@ -560,7 +560,7 @@ rte_pmd_i40e_set_vf_mac_addr(uint16_t port, uint16_t vf_id,
                return -EINVAL;
        }
 
-       ether_addr_copy(mac_addr, &vf->mac_addr);
+       rte_ether_addr_copy(mac_addr, &vf->mac_addr);
 
        /* Remove all existing mac */
        TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp)
@@ -571,16 +571,17 @@ rte_pmd_i40e_set_vf_mac_addr(uint16_t port, uint16_t vf_id,
        return 0;
 }
 
-static const struct ether_addr null_mac_addr;
+static const struct rte_ether_addr null_mac_addr;
 
 int
 rte_pmd_i40e_remove_vf_mac_addr(uint16_t port, uint16_t vf_id,
-       struct ether_addr *mac_addr)
+       struct rte_ether_addr *mac_addr)
 {
        struct rte_eth_dev *dev;
        struct i40e_pf_vf *vf;
        struct i40e_vsi *vsi;
        struct i40e_pf *pf;
+       int ret;
 
        if (i40e_validate_mac_addr((u8 *)mac_addr) != I40E_SUCCESS)
                return -EINVAL;
@@ -604,13 +605,14 @@ rte_pmd_i40e_remove_vf_mac_addr(uint16_t port, uint16_t vf_id,
                return -EINVAL;
        }
 
-       if (is_same_ether_addr(mac_addr, &vf->mac_addr))
+       if (rte_is_same_ether_addr(mac_addr, &vf->mac_addr))
                /* Reset the mac with NULL address */
-               ether_addr_copy(&null_mac_addr, &vf->mac_addr);
+               rte_ether_addr_copy(&null_mac_addr, &vf->mac_addr);
 
        /* Remove the mac */
-       i40e_vsi_delete_mac(vsi, mac_addr);
-
+       ret = i40e_vsi_delete_mac(vsi, mac_addr);
+       if (ret != I40E_SUCCESS)
+               return ret;
        return 0;
 }
 
@@ -663,7 +665,7 @@ int rte_pmd_i40e_set_vf_vlan_insert(uint16_t port, uint16_t vf_id,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-       if (vlan_id > ETHER_MAX_VLAN_ID) {
+       if (vlan_id > RTE_ETHER_MAX_VLAN_ID) {
                PMD_DRV_LOG(ERR, "Invalid VLAN ID.");
                return -EINVAL;
        }
@@ -724,7 +726,7 @@ int rte_pmd_i40e_set_vf_broadcast(uint16_t port, uint16_t vf_id,
        struct i40e_vsi *vsi;
        struct i40e_hw *hw;
        struct i40e_mac_filter_info filter;
-       struct ether_addr broadcast = {
+       struct rte_ether_addr broadcast = {
                .addr_bytes = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} };
        int ret;
 
@@ -765,7 +767,7 @@ int rte_pmd_i40e_set_vf_broadcast(uint16_t port, uint16_t vf_id,
        }
 
        if (on) {
-               rte_memcpy(&filter.mac_addr, &broadcast, ETHER_ADDR_LEN);
+               rte_memcpy(&filter.mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
                filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
                ret = i40e_vsi_add_mac(vsi, &filter);
        } else {
@@ -893,7 +895,7 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint16_t port, uint16_t vlan_id,
        if (!is_i40e_supported(dev))
                return -ENOTSUP;
 
-       if (vlan_id > ETHER_MAX_VLAN_ID || !vlan_id) {
+       if (vlan_id > RTE_ETHER_MAX_VLAN_ID || !vlan_id) {
                PMD_DRV_LOG(ERR, "Invalid VLAN ID.");
                return -EINVAL;
        }
@@ -1407,7 +1409,7 @@ rte_pmd_i40e_set_tc_strict_prio(uint16_t port, uint8_t tc_map)
 
        /* Disable DCBx if it's the first time to set strict priority. */
        if (!veb->strict_prio_tc) {
-               ret = i40e_aq_stop_lldp(hw, true, NULL);
+               ret = i40e_aq_stop_lldp(hw, true, true, NULL);
                if (ret)
                        PMD_DRV_LOG(INFO,
                                    "Failed to disable DCBx as it's already"
@@ -1462,7 +1464,7 @@ rte_pmd_i40e_set_tc_strict_prio(uint16_t port, uint8_t tc_map)
 
        /* Enable DCBx again, if all the TCs' strict priority disabled. */
        if (!tc_map) {
-               ret = i40e_aq_start_lldp(hw, NULL);
+               ret = i40e_aq_start_lldp(hw, true, NULL);
                if (ret) {
                        PMD_DRV_LOG(ERR,
                                    "Failed to enable DCBx, err(%d).", ret);
@@ -2355,7 +2357,7 @@ int rte_pmd_i40e_ptype_mapping_replace(uint16_t port,
 
 int
 rte_pmd_i40e_add_vf_mac_addr(uint16_t port, uint16_t vf_id,
-                            struct ether_addr *mac_addr)
+                            struct rte_ether_addr *mac_addr)
 {
        struct rte_eth_dev *dev;
        struct i40e_pf_vf *vf;
@@ -2387,7 +2389,7 @@ rte_pmd_i40e_add_vf_mac_addr(uint16_t port, uint16_t vf_id,
        }
 
        mac_filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
-       ether_addr_copy(mac_addr, &mac_filter.mac_addr);
+       rte_ether_addr_copy(mac_addr, &mac_filter.mac_addr);
        ret = i40e_vsi_add_mac(vsi, &mac_filter);
        if (ret != I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to add MAC filter.");
@@ -2405,7 +2407,8 @@ int rte_pmd_i40e_flow_type_mapping_reset(uint16_t port)
 
        dev = &rte_eth_devices[port];
 
-       if (!is_i40e_supported(dev))
+       if (!is_i40e_supported(dev) &&
+           !is_i40evf_supported(dev))
                return -ENOTSUP;
 
        i40e_set_default_pctype_table(dev);
@@ -2425,7 +2428,8 @@ int rte_pmd_i40e_flow_type_mapping_get(
 
        dev = &rte_eth_devices[port];
 
-       if (!is_i40e_supported(dev))
+       if (!is_i40e_supported(dev) &&
+           !is_i40evf_supported(dev))
                return -ENOTSUP;
 
        ad = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
@@ -2453,7 +2457,8 @@ rte_pmd_i40e_flow_type_mapping_update(
 
        dev = &rte_eth_devices[port];
 
-       if (!is_i40e_supported(dev))
+       if (!is_i40e_supported(dev) &&
+           !is_i40evf_supported(dev))
                return -ENOTSUP;
 
        if (count > I40E_FLOW_TYPE_MAX)
@@ -2492,10 +2497,11 @@ rte_pmd_i40e_flow_type_mapping_update(
 }
 
 int
-rte_pmd_i40e_query_vfid_by_mac(uint16_t port, const struct ether_addr *vf_mac)
+rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
+                       const struct rte_ether_addr *vf_mac)
 {
        struct rte_eth_dev *dev;
-       struct ether_addr *mac;
+       struct rte_ether_addr *mac;
        struct i40e_pf *pf;
        int vf_id;
        struct i40e_pf_vf *vf;
@@ -2514,7 +2520,7 @@ rte_pmd_i40e_query_vfid_by_mac(uint16_t port, const struct ether_addr *vf_mac)
                vf = &pf->vfs[vf_id];
                mac = &vf->mac_addr;
 
-               if (is_same_ether_addr(mac, vf_mac))
+               if (rte_is_same_ether_addr(mac, vf_mac))
                        return vf_id;
        }
 
@@ -3201,3 +3207,24 @@ rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
        I40E_WRITE_FLUSH(hw);
        return 0;
 }
+
+int
+rte_pmd_i40e_set_switch_dev(uint16_t port_id, struct rte_eth_dev *switch_dev)
+{
+       struct rte_eth_dev *i40e_dev;
+       struct i40e_hw *hw;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       i40e_dev = &rte_eth_devices[port_id];
+       if (!is_i40e_supported(i40e_dev))
+               return -ENOTSUP;
+
+       hw = I40E_DEV_PRIVATE_TO_HW(i40e_dev->data->dev_private);
+       if (!hw)
+               return -1;
+
+       hw->switch_dev = switch_dev;
+
+       return 0;
+}