From: Kiran Kumar K <kirankum...@marvell.com>

Adding support to parse IPV6 routing ext flow type for cnxk.

Signed-off-by: Kiran Kumar K <kirankum...@marvell.com>
Reviewed-by: Satheesh Paul <psathe...@marvell.com>
Tested-by: Jerin Jacob <jer...@marvell.com>
---
 drivers/common/cnxk/roc_npc.h           | 17 +++++++++++++++++
 drivers/common/cnxk/roc_npc_mcam_dump.c |  3 +++
 drivers/common/cnxk/roc_npc_parse.c     | 15 +++++++++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h
index 07e6634aa7..2ada774934 100644
--- a/drivers/common/cnxk/roc_npc.h
+++ b/drivers/common/cnxk/roc_npc.h
@@ -40,6 +40,7 @@ enum roc_npc_item_type {
        ROC_NPC_ITEM_TYPE_RAW,
        ROC_NPC_ITEM_TYPE_MARK,
        ROC_NPC_ITEM_TYPE_TX_QUEUE,
+       ROC_NPC_ITEM_TYPE_IPV6_ROUTING_EXT,
        ROC_NPC_ITEM_TYPE_END,
 };
 
@@ -131,6 +132,22 @@ struct roc_ipv6_fragment_ext {
        uint32_t id;         /**< Packet ID */
 } __plt_packed;
 
+struct roc_ipv6_routing_ext {
+       uint8_t next_hdr;       /**< Protocol, next header. */
+       uint8_t hdr_len;        /**< Header length. */
+       uint8_t type;           /**< Extension header type. */
+       uint8_t segments_left;  /**< Valid segments number. */
+       union {
+               uint32_t flags; /**< Packet control data per type. */
+               struct {
+                       uint8_t last_entry; /**< The last_entry field of SRH */
+                       uint8_t flag;       /**< Packet flag. */
+                       uint16_t tag;       /**< Packet tag. */
+               };
+       };
+       /* Next are 128-bit IPv6 address fields to describe segments. */
+} __plt_packed;
+
 struct roc_flow_item_ipv6_ext {
        uint8_t next_hdr; /**< Next header. */
 };
diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c 
b/drivers/common/cnxk/roc_npc_mcam_dump.c
index a88e166fbe..01c4212567 100644
--- a/drivers/common/cnxk/roc_npc_mcam_dump.c
+++ b/drivers/common/cnxk/roc_npc_mcam_dump.c
@@ -645,6 +645,7 @@ npc_flow_hw_mcam_entry_dump(FILE *file, struct npc *npc, 
struct roc_npc_flow *fl
        struct nix_inl_dev *inl_dev = NULL;
        struct idev_cfg *idev;
        struct mbox *mbox;
+       uint8_t enabled;
        int rc = 0, i;
 
        idev = idev_get_cfg();
@@ -673,6 +674,7 @@ npc_flow_hw_mcam_entry_dump(FILE *file, struct npc *npc, 
struct roc_npc_flow *fl
 
        mbox_memcpy(mcam_data, mcam_read_rsp->entry_data.kw, sizeof(mcam_data));
        mbox_memcpy(mcam_mask, mcam_read_rsp->entry_data.kw_mask, 
sizeof(mcam_data));
+       enabled = mcam_read_rsp->enable;
 
        fprintf(file, "HW MCAM Data :\n");
 
@@ -680,6 +682,7 @@ npc_flow_hw_mcam_entry_dump(FILE *file, struct npc *npc, 
struct roc_npc_flow *fl
                fprintf(file, "\tDW%d     :%016lX\n", i, mcam_data[i]);
                fprintf(file, "\tDW%d_Mask:%016lX\n", i, mcam_mask[i]);
        }
+       fprintf(file, "\tEnabled = 0x%x\n", enabled);
 
        fprintf(file, "\n");
        mbox_put(mbox);
diff --git a/drivers/common/cnxk/roc_npc_parse.c 
b/drivers/common/cnxk/roc_npc_parse.c
index acaebaed21..ecd1b3e13b 100644
--- a/drivers/common/cnxk/roc_npc_parse.c
+++ b/drivers/common/cnxk/roc_npc_parse.c
@@ -719,8 +719,8 @@ npc_handle_ipv6ext_attr(const struct roc_npc_flow_item_ipv6 
*ipv6_spec,
 static int
 npc_process_ipv6_item(struct npc_parse_state *pst)
 {
-       uint8_t ipv6_hdr_mask[sizeof(struct roc_ipv6_hdr) + sizeof(struct 
roc_ipv6_fragment_ext)];
-       uint8_t ipv6_hdr_buf[sizeof(struct roc_ipv6_hdr) + sizeof(struct 
roc_ipv6_fragment_ext)];
+       uint8_t ipv6_hdr_mask[2 * sizeof(struct roc_ipv6_hdr)];
+       uint8_t ipv6_hdr_buf[2 * sizeof(struct roc_ipv6_hdr)];
        const struct roc_npc_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
        const struct roc_npc_item_info *pattern = pst->pattern;
        int offset = 0, rc = 0, lid, item_count = 0;
@@ -804,6 +804,16 @@ npc_process_ipv6_item(struct npc_parse_state *pst)
                                       sizeof(struct roc_ipv6_fragment_ext));
 
                        break;
+               } else if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6_ROUTING_EXT) 
{
+                       item_count++;
+                       ltype = NPC_LT_LC_IP6_EXT;
+                       parse_info.len = sizeof(struct roc_ipv6_hdr) + 
pattern->size;
+
+                       if (pattern->spec)
+                               memcpy(ipv6_hdr_buf + offset, pattern->spec, 
pattern->size);
+                       if (pattern->mask)
+                               memcpy(ipv6_hdr_mask + offset, pattern->mask, 
pattern->size);
+                       break;
                }
 
                pattern++;
@@ -867,6 +877,7 @@ npc_parse_lc(struct npc_parse_state *pst)
        case ROC_NPC_ITEM_TYPE_IPV6:
        case ROC_NPC_ITEM_TYPE_IPV6_EXT:
        case ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT:
+       case ROC_NPC_ITEM_TYPE_IPV6_ROUTING_EXT:
                return npc_process_ipv6_item(pst);
        case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4:
                lt = NPC_LT_LC_ARP;
-- 
2.39.2

Reply via email to