net/bnxt: support creating SMAC and inner DMAC filters
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index b3a37e1..7cd3213 100644 (file)
@@ -189,7 +189,7 @@ int is_bnxt_in_error(struct bnxt *bp)
  * High level utility functions
  */
 
-static uint16_t bnxt_rss_ctxts(const struct bnxt *bp)
+uint16_t bnxt_rss_ctxts(const struct bnxt *bp)
 {
        if (!BNXT_CHIP_THOR(bp))
                return 1;
@@ -318,17 +318,10 @@ static int bnxt_init_chip(struct bnxt *bp)
        for (i = 0; i < bp->nr_vnics; i++) {
                struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
-               uint32_t size = sizeof(*vnic->fw_grp_ids) * bp->max_ring_grps;
 
-               vnic->fw_grp_ids = rte_zmalloc("vnic_fw_grp_ids", size, 0);
-               if (!vnic->fw_grp_ids) {
-                       PMD_DRV_LOG(ERR,
-                                   "Failed to alloc %d bytes for group ids\n",
-                                   size);
-                       rc = -ENOMEM;
+               rc = bnxt_vnic_grp_alloc(bp, vnic);
+               if (rc)
                        goto err_out;
-               }
-               memset(vnic->fw_grp_ids, -1, size);
 
                PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
                            i, vnic, vnic->fw_grp_ids);
@@ -384,7 +377,7 @@ static int bnxt_init_chip(struct bnxt *bp)
                        goto err_out;
                }
 
-               for (j = 0; j < bp->rx_nr_rings; j++) {
+               for (j = 0; j < bp->rx_num_qs_per_vnic; j++) {
                        rxq = bp->eth_dev->data->rx_queues[j];
 
                        PMD_DRV_LOG(DEBUG,
@@ -1046,6 +1039,7 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev,
 
        filter->mac_index = index;
        memcpy(filter->l2_addr, mac_addr, RTE_ETHER_ADDR_LEN);
+       filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
 
        rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter);
        if (!rc) {
@@ -1118,7 +1112,7 @@ static int bnxt_promiscuous_enable_op(struct rte_eth_dev *eth_dev)
        if (bp->vnic_info == NULL)
                return 0;
 
-       vnic = &bp->vnic_info[0];
+       vnic = BNXT_GET_DEFAULT_VNIC(bp);
 
        old_flags = vnic->flags;
        vnic->flags |= BNXT_VNIC_INFO_PROMISC;
@@ -1143,7 +1137,7 @@ static int bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
        if (bp->vnic_info == NULL)
                return 0;
 
-       vnic = &bp->vnic_info[0];
+       vnic = BNXT_GET_DEFAULT_VNIC(bp);
 
        old_flags = vnic->flags;
        vnic->flags &= ~BNXT_VNIC_INFO_PROMISC;
@@ -1168,7 +1162,7 @@ static int bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev)
        if (bp->vnic_info == NULL)
                return 0;
 
-       vnic = &bp->vnic_info[0];
+       vnic = BNXT_GET_DEFAULT_VNIC(bp);
 
        old_flags = vnic->flags;
        vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
@@ -1193,7 +1187,7 @@ static int bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev)
        if (bp->vnic_info == NULL)
                return 0;
 
-       vnic = &bp->vnic_info[0];
+       vnic = BNXT_GET_DEFAULT_VNIC(bp);
 
        old_flags = vnic->flags;
        vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI;
@@ -1353,8 +1347,6 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
        struct bnxt *bp = eth_dev->data->dev_private;
        struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
        struct bnxt_vnic_info *vnic;
-       uint16_t hash_type = 0;
-       unsigned int i;
        int rc;
 
        rc = is_bnxt_in_error(bp);
@@ -1376,35 +1368,20 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
        bp->flags |= BNXT_FLAG_UPDATE_HASH;
        memcpy(&bp->rss_conf, rss_conf, sizeof(*rss_conf));
 
-       if (rss_conf->rss_hf & ETH_RSS_IPV4)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
-       if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
-       if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
-       if (rss_conf->rss_hf & ETH_RSS_IPV6)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
-       if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
-       if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
-               hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
-
-       /* Update the RSS VNIC(s) */
-       for (i = 0; i < bp->nr_vnics; i++) {
-               vnic = &bp->vnic_info[i];
-               vnic->hash_type = hash_type;
+       /* Update the default RSS VNIC(s) */
+       vnic = &bp->vnic_info[0];
+       vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf);
 
-               /*
-                * Use the supplied key if the key length is
-                * acceptable and the rss_key is not NULL
-                */
-               if (rss_conf->rss_key &&
-                   rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
-                       memcpy(vnic->rss_hash_key, rss_conf->rss_key,
-                              rss_conf->rss_key_len);
+       /*
+        * Use the supplied key if the key length is
+        * acceptable and the rss_key is not NULL
+        */
+       if (rss_conf->rss_key && rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
+               memcpy(vnic->rss_hash_key,
+                      rss_conf->rss_key,
+                      rss_conf->rss_key_len);
 
-               bnxt_hwrm_vnic_rss_cfg(bp, vnic);
-       }
+       bnxt_hwrm_vnic_rss_cfg(bp, vnic);
        return 0;
 }
 
@@ -1763,6 +1740,7 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)
        filter->l2_ivlan = vlan_id;
        filter->l2_ivlan_mask = 0x0FFF;
        filter->enables |= en;
+       filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
        rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter);
        if (rc) {
                /* Free the newly allocated filter as we were
@@ -1928,7 +1906,8 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,
 
                memcpy(filter->l2_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
                memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
-               filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+               filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX |
+                       HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
                filter->enables |=
                        HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
                        HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK;
@@ -1960,7 +1939,7 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev,
        if (rc)
                return rc;
 
-       vnic = &bp->vnic_info[0];
+       vnic = BNXT_GET_DEFAULT_VNIC(bp);
 
        if (nb_mc_addr > BNXT_MAX_MC_ADDRS) {
                vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
@@ -4457,6 +4436,10 @@ static int bnxt_init_fw(struct bnxt *bp)
        if (rc)
                return -EIO;
 
+       rc = bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(bp);
+       if (rc)
+               return rc;
+
        rc = bnxt_hwrm_queue_qportcfg(bp);
        if (rc)
                return rc;