net: add rte prefix to ether defines
[dpdk.git] / drivers / net / i40e / rte_pmd_i40e.c
index 921dfc0..0fbf79c 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_tailq.h>
 
@@ -338,7 +339,7 @@ i40e_vsi_set_tx_loopback(struct i40e_vsi *vsi, uint8_t on)
        hw = I40E_VSI_TO_HW(vsi);
 
        /* Use the FW API if FW >= v5.0 */
-       if (hw->aq.fw_maj_ver < 5) {
+       if (hw->aq.fw_maj_ver < 5 && hw->mac.type != I40E_MAC_X722) {
                PMD_INIT_LOG(ERR, "FW < v5.0, cannot enable loopback");
                return -ENOTSUP;
        }
@@ -528,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;
@@ -559,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)
@@ -570,11 +571,11 @@ 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;
@@ -603,9 +604,9 @@ 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);
@@ -662,7 +663,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;
        }
@@ -723,7 +724,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;
 
@@ -764,7 +765,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 {
@@ -892,7 +893,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;
        }
@@ -1709,6 +1710,7 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
                                PMD_DRV_LOG(ERR, "Profile of group 0 already exists.");
                        else if (is_exist == 3)
                                PMD_DRV_LOG(ERR, "Profile of different group already exists");
+                       i40e_update_customized_info(dev, buff, size, op);
                        rte_free(profile_info_sec);
                        return -EEXIST;
                }
@@ -1982,8 +1984,8 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
                tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
                for (i = j = 0; i < nb_rec; j++) {
                        pinfo[j].proto_id = tlv->data[0];
-                       snprintf(pinfo[j].name, I40E_DDP_NAME_SIZE, "%s",
-                                (const char *)&tlv->data[1]);
+                       strlcpy(pinfo[j].name, (const char *)&tlv->data[1],
+                               I40E_DDP_NAME_SIZE);
                        i += tlv->len;
                        tlv = &tlv[tlv->len];
                }
@@ -2353,7 +2355,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;
@@ -2385,7 +2387,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.");
@@ -2490,10 +2492,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;
@@ -2512,7 +2515,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;
        }
 
@@ -2817,13 +2820,23 @@ i40e_queue_region_dcb_configure(struct i40e_hw *hw,
        struct i40e_dcbx_config *old_cfg = &hw->local_dcbx_config;
        int32_t ret = -EINVAL;
        uint16_t i, j, prio_index, region_index;
-       uint8_t tc_map, tc_bw, bw_lf;
+       uint8_t tc_map, tc_bw, bw_lf, dcb_flag = 0;
 
        if (!info->queue_region_number) {
                PMD_DRV_LOG(ERR, "No queue region been set before");
                return ret;
        }
 
+       for (i = 0; i < info->queue_region_number; i++) {
+               if (info->region[i].user_priority_num) {
+                       dcb_flag = 1;
+                       break;
+               }
+       }
+
+       if (dcb_flag == 0)
+               return 0;
+
        dcb_cfg = &dcb_cfg_local;
        memset(dcb_cfg, 0, sizeof(struct i40e_dcbx_config));