mlxsw: reg: Add Policy-Engine Rules Copy Register
authorJiri Pirko <jiri@mellanox.com>
Fri, 3 Feb 2017 09:28:58 +0000 (10:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Feb 2017 21:35:40 +0000 (16:35 -0500)
The PRCR register is used for accessing rules within a TCAM region.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/reg.h

index ce6d85a..555cb80 100644 (file)
@@ -2019,6 +2019,82 @@ static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
        mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
 }
 
+/* PRCR - Policy-Engine Rules Copy Register
+ * ----------------------------------------
+ * This register is used for accessing rules within a TCAM region.
+ */
+#define MLXSW_REG_PRCR_ID 0x300D
+#define MLXSW_REG_PRCR_LEN 0x40
+
+MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
+
+enum mlxsw_reg_prcr_op {
+       /* Move rules. Moves the rules from "tcam_region_info" starting
+        * at offset "offset" to "dest_tcam_region_info"
+        * at offset "dest_offset."
+        */
+       MLXSW_REG_PRCR_OP_MOVE,
+       /* Copy rules. Copies the rules from "tcam_region_info" starting
+        * at offset "offset" to "dest_tcam_region_info"
+        * at offset "dest_offset."
+        */
+       MLXSW_REG_PRCR_OP_COPY,
+};
+
+/* reg_prcr_op
+ * Access: OP
+ */
+MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
+
+/* reg_prcr_offset
+ * Offset within the source region to copy/move from.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
+
+/* reg_prcr_size
+ * The number of rules to copy/move.
+ * Access: WO
+ */
+MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
+
+/* reg_prcr_tcam_region_info
+ * Opaque object that represents the source TCAM region.
+ * Access: Index
+ */
+MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
+              MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
+
+/* reg_prcr_dest_offset
+ * Offset within the source region to copy/move to.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
+
+/* reg_prcr_dest_tcam_region_info
+ * Opaque object that represents the destination TCAM region.
+ * Access: Index
+ */
+MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
+              MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
+
+static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
+                                      const char *src_tcam_region_info,
+                                      u16 src_offset,
+                                      const char *dest_tcam_region_info,
+                                      u16 dest_offset, u16 size)
+{
+       MLXSW_REG_ZERO(prcr, payload);
+       mlxsw_reg_prcr_op_set(payload, op);
+       mlxsw_reg_prcr_offset_set(payload, src_offset);
+       mlxsw_reg_prcr_size_set(payload, size);
+       mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
+                                                 src_tcam_region_info);
+       mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
+       mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
+                                                      dest_tcam_region_info);
+}
+
 /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
  * -----------------------------------------------------
  * This register is used for accessing rules within a TCAM region.
@@ -5799,6 +5875,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
        MLXSW_REG(pacl),
        MLXSW_REG(pagt),
        MLXSW_REG(ptar),
+       MLXSW_REG(prcr),
        MLXSW_REG(ptce2),
        MLXSW_REG(qpcr),
        MLXSW_REG(qtct),