net/ice/base: add parser create and destroy skeleton
authorQi Zhang <qi.z.zhang@intel.com>
Fri, 17 Sep 2021 14:43:03 +0000 (22:43 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 21 Sep 2021 12:43:23 +0000 (14:43 +0200)
Add new parser module which can parse a packet in binary
and generate information like ptype, protocol/offset pairs
and flags which can be used to feed the FXP profile creation
directly.

The patch added skeleton of the parser instance create and
destroy APIs:
ice_parser_create
ice_parser_destroy

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
drivers/net/ice/base/ice_common.h
drivers/net/ice/base/ice_flex_pipe.c
drivers/net/ice/base/ice_flex_pipe.h
drivers/net/ice/base/ice_parser.c [new file with mode: 0644]
drivers/net/ice/base/ice_parser.h [new file with mode: 0644]
drivers/net/ice/base/meson.build

index 1d8882c..a3cbf4f 100644 (file)
@@ -8,6 +8,7 @@
 #include "ice_type.h"
 #include "ice_nvm.h"
 #include "ice_flex_pipe.h"
+#include "ice_parser.h"
 #include "ice_switch.h"
 #include "ice_fdir.h"
 
index 3631ddb..703c3e0 100644 (file)
@@ -284,7 +284,7 @@ ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
  * indicates a base offset of 10, and the index for the entry is 2, then
  * section handler function should set the offset to 10 + 2 = 12.
  */
-static void *
+void *
 ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
                   u32 sect_type, u32 *offset,
                   void *(*handler)(u32 sect_type, void *section,
index b690be7..045a77c 100644 (file)
@@ -94,4 +94,9 @@ void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build *bld);
 enum ice_status
 ice_set_key(u8 *key, u16 size, u8 *val, u8 *upd, u8 *dc, u8 *nm, u16 off,
            u16 len);
+void *
+ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+                  u32 sect_type, u32 *offset,
+                  void *(*handler)(u32 sect_type, void *section,
+                                   u32 index, u32 *offset));
 #endif /* _ICE_FLEX_PIPE_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
new file mode 100644 (file)
index 0000000..c08deca
--- /dev/null
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+
+/**
+ * ice_parser_create - create a parser instance
+ * @hw: pointer to the hardware structure
+ * @psr: output parameter for a new parser instance be created
+ */
+enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
+{
+       struct ice_parser *p;
+
+       p = (struct ice_parser *)ice_malloc(hw, sizeof(struct ice_parser));
+
+       if (!p)
+               return ICE_ERR_NO_MEMORY;
+
+       p->hw = hw;
+
+       *psr = p;
+       return ICE_SUCCESS;
+}
+
+/**
+ * ice_parser_destroy - destroy a parser instance
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_destroy(struct ice_parser *psr)
+{
+       ice_free(psr->hw, psr);
+}
diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h
new file mode 100644 (file)
index 0000000..5964bf4
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_PARSER_H_
+#define _ICE_PARSER_H_
+
+struct ice_parser {
+       struct ice_hw *hw; /* pointer to the hardware structure */
+};
+
+enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
+void ice_parser_destroy(struct ice_parser *psr);
+#endif /* _ICE_PARSER_H_ */
index be9713d..3051b47 100644 (file)
@@ -15,6 +15,7 @@ sources = [
         'ice_acl_ctrl.c',
         'ice_vlan_mode.c',
         'ice_ptp_hw.c',
+        'ice_parser.c',
 ]
 
 error_cflags = [