]> git.droids-corp.org - dpdk.git/commitdiff
net/cnxk: keep flow rules across restart
authorKiran Kumar K <kirankumark@marvell.com>
Mon, 14 Feb 2022 04:33:51 +0000 (10:03 +0530)
committerJerin Jacob <jerinj@marvell.com>
Fri, 18 Feb 2022 07:39:50 +0000 (08:39 +0100)
Adding changes to enable keep flow rule device capability.
With this change, flow rules will be kept across device restart.

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
Reviewed-by: Satheesh Paul <psatheesh@marvell.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
drivers/common/cnxk/roc_npc.c
drivers/common/cnxk/roc_npc.h
drivers/common/cnxk/roc_npc_mcam.c
drivers/common/cnxk/roc_npc_priv.h
drivers/common/cnxk/version.map
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev_ops.c

index 245eb8b74f470ed61d18a25ed68412a6f44d0e6d..34c393f496c62f243d5980c5953c5490512798be 100644 (file)
@@ -74,6 +74,14 @@ roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry,
                                      priority, resp_count);
 }
 
+int
+roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable)
+{
+       struct npc *npc = roc_npc_to_npc_priv(roc_npc);
+
+       return npc_flow_enable_all_entries(npc, enable);
+}
+
 int
 roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam,
                         struct roc_npc_flow *ref_mcam, int prio,
index b836e264c65c51f3826ac2c817921d6ee11b6676..f9e5028cab6a1d9c381b7e5c4ae438ddd029cc4c 100644 (file)
@@ -309,6 +309,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc,
                                   struct roc_npc_flow *flow);
 int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry);
+int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc,
+                                             bool enable);
 int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc,
                                       struct roc_npc_flow *mcam,
                                       struct roc_npc_flow *ref_mcam, int prio,
index 7a3a8944f55c3eb7489b75719679db2a27564600..9c5ff5e60a88e8cf80fe2139c3adc4fe56011e03 100644 (file)
@@ -780,6 +780,26 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc)
                return 0;
 }
 
+int
+npc_flow_enable_all_entries(struct npc *npc, bool enable)
+{
+       struct npc_flow_list *list;
+       struct roc_npc_flow *flow;
+       int rc = 0, idx;
+
+       /* Free any MCAM counters and delete flow list */
+       for (idx = 0; idx < npc->flow_max_priority; idx++) {
+               list = &npc->flow_list[idx];
+               TAILQ_FOREACH(flow, list, next) {
+                       flow->enable = enable;
+                       rc = npc_mcam_write_entry(npc, flow);
+                       if (rc)
+                               return rc;
+               }
+       }
+       return rc;
+}
+
 int
 npc_flow_free_all_resources(struct npc *npc)
 {
index afd11add9aee39754d32a96eb7f7f441b433bacb..23e8675253c472fe3ec537fa8a901ca84316d807 100644 (file)
@@ -413,6 +413,7 @@ int npc_mcam_alloc_entries(struct npc *npc, int ref_mcam, int *alloc_entry,
 int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam,
                           bool enable);
 int npc_mcam_write_entry(struct npc *npc, struct roc_npc_flow *mcam);
+int npc_flow_enable_all_entries(struct npc *npc, bool enable);
 int npc_update_parse_state(struct npc_parse_state *pst,
                           struct npc_parse_item_info *info, int lid, int lt,
                           uint8_t flags);
index ad1b5e8476c2d01cbbdbbaf281c9ee8582b2858e..75a260f11e1d463c0c2e46c08eaf0722b99ac340 100644 (file)
@@ -312,6 +312,7 @@ INTERNAL {
        roc_npc_mcam_alloc_entries;
        roc_npc_mcam_alloc_entry;
        roc_npc_mcam_clear_counter;
+       roc_npc_mcam_enable_all_entries;
        roc_npc_mcam_ena_dis_entry;
        roc_npc_mcam_free_all_resources;
        roc_npc_mcam_free_counter;
index 4ab87e49ead07b9b151884bb76e65b547a87ec36..3468aab3296091c3a5226ddedb5e8377c6d7a7bf 100644 (file)
@@ -1395,8 +1395,10 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev)
        int count, i, j, rc;
        void *rxq;
 
-       /* Disable switch hdr pkind */
-       roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0);
+       /* Disable all the NPC entries */
+       rc = roc_npc_mcam_enable_all_entries(&dev->npc, 0);
+       if (rc)
+               return rc;
 
        /* Stop link change events */
        if (!roc_nix_is_vf_or_sdp(&dev->nix))
@@ -1471,6 +1473,12 @@ cnxk_nix_dev_start(struct rte_eth_dev *eth_dev)
                return rc;
        }
 
+       rc = roc_npc_mcam_enable_all_entries(&dev->npc, 1);
+       if (rc) {
+               plt_err("Failed to enable NPC entries %d", rc);
+               return rc;
+       }
+
        cnxk_nix_toggle_flag_link_cfg(dev, true);
 
        /* Start link change events */
@@ -1721,6 +1729,9 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
        struct roc_nix *nix = &dev->nix;
        int rc, i;
 
+       /* Disable switch hdr pkind */
+       roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0);
+
        plt_free(eth_dev->security_ctx);
        eth_dev->security_ctx = NULL;
 
index f20f201db263a9fa6e1d1afb5f19f407cc3ca351..1ae90092d636493020f5eb745e0217c5fb14c2de 100644 (file)
@@ -67,8 +67,8 @@ cnxk_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *devinfo)
 
        devinfo->speed_capa = dev->speed_capa;
        devinfo->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
-                           RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
-       devinfo->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
+                           RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP |
+                           RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
        return 0;
 }